Skip to content

Commit 72575a8

Browse files
okakarpadnikolaev-amd
authored andcommitted
[AUTOGENERATED] [release/2.7] [release/2.6] Fix dtype before comparing torch and numpy tensors (ROCm#2362)
Cherry-pick of ROCm#2340 Co-authored-by: Dmitry Nikolaev <[email protected]> (cherry picked from commit 22c98ea)
1 parent ccea031 commit 72575a8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/test_binary_ufuncs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ def to_np(value):
14471447
try:
14481448
np_res = np.power(to_np(base), to_np(np_exponent))
14491449
expected = (
1450-
torch.from_numpy(np_res).to(dtype=base.dtype)
1450+
torch.from_numpy(np_res)
14511451
if isinstance(np_res, np.ndarray)
14521452
else torch.tensor(np_res, dtype=base.dtype)
14531453
)
@@ -1480,8 +1480,8 @@ def to_np(value):
14801480
self.assertRaisesRegex(RuntimeError, regex, base.pow_, exponent)
14811481
elif torch.can_cast(torch.result_type(base, exponent), base.dtype):
14821482
actual2 = actual.pow_(exponent)
1483-
self.assertEqual(actual, expected)
1484-
self.assertEqual(actual2, expected)
1483+
self.assertEqual(actual, expected.to(actual))
1484+
self.assertEqual(actual2, expected.to(actual))
14851485
else:
14861486
self.assertRaisesRegex(
14871487
RuntimeError,

0 commit comments

Comments
 (0)