Commit 84e9867
authored
[release/2.6] Fix dtype before comparing torch and numpy tensors (#2340)
Cast numpy dtype result to torch dtype result before compare
Numpy returns `np.power(float32, int64) => float64` [Promotion rules for
Python scalars](https://numpy.org/neps/nep-0050-scalar-promotion.html)
Pytorch returns `torch.pow(float32, int64) => float32`
Reverts #2287 and fixes tests in a
different way
Fixes:
- SWDEV-538110 - `'dtype' do not match: torch.float32 != torch.float64`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_cuda_tensor_pow_scalar_tensor_cuda
- SWDEV-539171 - `AttributeError: 'float' object has no attribute
'dtype`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_long_tensor_pow_floats_cuda
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_complex_scalar_pow_tensor_cuda_*
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_float_scalar_pow_float_tensor_cuda_*1 parent 43000ca commit 84e9867
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1446 | 1446 | | |
1447 | 1447 | | |
1448 | 1448 | | |
1449 | | - | |
| 1449 | + | |
1450 | 1450 | | |
1451 | 1451 | | |
1452 | 1452 | | |
| |||
1479 | 1479 | | |
1480 | 1480 | | |
1481 | 1481 | | |
1482 | | - | |
1483 | | - | |
| 1482 | + | |
| 1483 | + | |
1484 | 1484 | | |
1485 | 1485 | | |
1486 | 1486 | | |
| |||
0 commit comments