Skip to content

Commit

Permalink
[bugfix] Quick fix of #1547 (#1600)
Browse files Browse the repository at this point in the history
* upd

* upd
  • Loading branch information
yzh119 committed Jun 15, 2020
1 parent 57d111f commit 04522a7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion python/dgl/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def asnumpy(input):
"""
pass

def copy_to(input, ctx):
def copy_to(input, ctx, **kwargs):
"""Copy the given tensor to the context.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/backend/mxnet/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def astype(input, ty):
def asnumpy(input):
return input.asnumpy()

def copy_to(input, ctx):
def copy_to(input, ctx, **kwargs):
return input.as_in_context(ctx)

def sum(input, dim, keepdims=False):
Expand Down
4 changes: 2 additions & 2 deletions python/dgl/backend/pytorch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ def asnumpy(input):
else:
return input.cpu().detach().numpy()

def copy_to(input, ctx):
def copy_to(input, ctx, **kwargs):
if ctx.type == 'cpu':
return input.cpu()
elif ctx.type == 'cuda':
if ctx.index is not None:
th.cuda.set_device(ctx.index)
return input.cuda()
return input.cuda(**kwargs)
else:
raise RuntimeError('Invalid context', ctx)

Expand Down
2 changes: 1 addition & 1 deletion python/dgl/backend/tensorflow/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def asnumpy(input):
return input.numpy()


def copy_to(input, ctx):
def copy_to(input, ctx, **kwargs):
with tf.device(ctx):
new_tensor = tf.identity(input)
return new_tensor
Expand Down
6 changes: 3 additions & 3 deletions python/dgl/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3872,7 +3872,7 @@ def __repr__(self):
edata=str(self.edge_attr_schemes()))

# pylint: disable=invalid-name
def to(self, ctx):
def to(self, ctx, **kwargs):
"""Move both ndata and edata to the targeted mode (cpu/gpu)
Framework agnostic
Expand All @@ -3898,9 +3898,9 @@ def to(self, ctx):
>>> G = G.to(torch.device('cuda:0'))
"""
for k in self.ndata.keys():
self.ndata[k] = F.copy_to(self.ndata[k], ctx)
self.ndata[k] = F.copy_to(self.ndata[k], ctx, **kwargs)
for k in self.edata.keys():
self.edata[k] = F.copy_to(self.edata[k], ctx)
self.edata[k] = F.copy_to(self.edata[k], ctx, **kwargs)
return self
# pylint: enable=invalid-name

Expand Down
2 changes: 1 addition & 1 deletion python/dgl/heterograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4025,7 +4025,7 @@ def filter_edges(self, predicate, edges=ALL, etype=None):
edges = F.tensor(edges)
return F.boolean_mask(edges, e_mask)

def to(self, ctx): # pylint: disable=invalid-name
def to(self, ctx, **kwargs): # pylint: disable=invalid-name
"""Move both ndata and edata to the targeted mode (cpu/gpu)
Framework agnostic
Expand Down

0 comments on commit 04522a7

Please sign in to comment.