[release/2.6] Fix dtype before comparing torch and numpy tensors#2340
Merged
pruthvistony merged 1 commit intorelease/2.6from Jul 14, 2025
Merged
Conversation
|
Jenkins build for ec94658d7c893ed63d2a9628615d0b179640540f commit is in progress |
Collaborator
|
@dnikolaev-amd Does this PR fix any more tests with the proposed changes as compared to #2287? |
These tests started failing after we introduced #2287 @jithunnair-amd |
pruthvistony
approved these changes
Jul 14, 2025
|
! cherry-pick --onto release/2.7 |
|
! cherry-pick --onto rocm7.0_internal_testing |
okakarpa
pushed a commit
that referenced
this pull request
Jul 14, 2025
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_*
Collaborator
|
Created branch autogenerated/release/2.7_cherry-pick_pr-2340 and #2362 |
okakarpa
pushed a commit
that referenced
this pull request
Jul 14, 2025
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_*
Collaborator
|
Created branch autogenerated/rocm7.0_internal_testing_cherry-pick_pr-2340 and #2363 |
pragupta
pushed a commit
that referenced
this pull request
Oct 8, 2025
jithunnair-amd
pushed a commit
that referenced
this pull request
Oct 10, 2025
jeffdaily
pushed a commit
that referenced
this pull request
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cast numpy dtype result to torch dtype result before compare
Numpy returns
np.power(float32, int64) => float64Promotion rules for Python scalarsPytorch returns
torch.pow(float32, int64) => float32Reverts #2287 and fixes tests in a different way
Fixes:
'dtype' do not match: torch.float32 != torch.float64AttributeError: 'float' object has no attribute 'dtypeCherry-picked to release/2.7 branch via #2362
Cherry-picked to rocm7.0_internal_testing branch via #2363