Skip to content

Commit dd8fdf1

Browse files
committed
Favour t.to() over t.type() for dtype conversions
1 parent 6bc212f commit dd8fdf1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torch_np/_ndarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def clip(self, min, max, out=None):
415415
def _upcast_int_indices(index):
416416
if isinstance(index, torch.Tensor):
417417
if index.dtype in [torch.int8, torch.int16, torch.int32]:
418-
return index.type(torch.int64)
418+
return index.to(torch.int64)
419419
elif isinstance(index, tuple):
420420
return tuple(ndarray._upcast_int_indices(i) for i in index)
421421
return index
@@ -436,7 +436,7 @@ def __setitem__(self, index, value):
436436
torch.int64,
437437
torch.uint8,
438438
]:
439-
value = value.type(self.dtype.torch_dtype)
439+
value = value.to(self.dtype.torch_dtype)
440440
return self._tensor.__setitem__(index, value)
441441

442442

0 commit comments

Comments
 (0)