Skip to content

Commit ff75f7a

Browse files
committed
MAINT: address review comments
1 parent 6478709 commit ff75f7a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

torch_np/_detail/_ufunc_impl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def _absolute(x):
146146
def _matmul(x, y):
147147
# work around RuntimeError: expected scalar type Int but found Double
148148
dtype = _dtypes_impl.result_type_impl((x.dtype, y.dtype))
149-
x = x.to(dtype)
150-
y = y.to(dtype)
149+
x = _util.cast_if_needed(x, dtype)
150+
y = _util.cast_if_needed(y, dtype)
151151
result = torch.matmul(x, y)
152152
return result
153153

torch_np/_detail/implementations.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def arange(start=None, stop=None, step=1, dtype=None):
507507

508508
if (step > 0 and start > stop) or (step < 0 and start < stop):
509509
# empty range
510-
return torch.empty(0, dtype=target_type)
510+
return torch.empty(0, dtype=target_dtype)
511511

512512
try:
513513
result = torch.arange(start, stop, step, dtype=work_dtype)
@@ -797,6 +797,10 @@ def vdot(t_a, t_b, /):
797797

798798

799799
def dot(t_a, t_b):
800+
dtype = _dtypes_impl.result_type_impl((t_a.dtype, t_b.dtype))
801+
t_a = _util.cast_if_needed(t_a, dtype)
802+
t_b = _util.cast_if_needed(t_b, dtype)
803+
800804
if t_a.ndim == 0 or t_b.ndim == 0:
801805
result = t_a * t_b
802806
elif t_a.ndim == 1 and t_b.ndim == 1:

torch_np/_funcs.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ def vdot(a, b, /):
101101

102102
def dot(a, b, out=None):
103103
t_a, t_b = _helpers.to_tensors(a, b)
104-
dtype = _dtypes_impl.result_type_impl((t_a.dtype, t_b.dtype))
105-
t_a = t_a.to(dtype)
106-
t_b = t_b.to(dtype)
107104
result = _impl.dot(t_a, t_b)
108105
return _helpers.result_or_out(result, out)
109106

0 commit comments

Comments
 (0)