intel / torch-xpu-ops

Apache License 2.0
30 stars 21 forks source link

shapes are not equal with FakeTensor #1078

Open daisyden opened 1 week ago

daisyden commented 1 week ago

šŸ› Describe the bug

Run TestFakeTensor with xpu we got a lot of errors of shapes are not equal. For example:

====================================================================== ERROR: test_fake_crossref_backward_amp_nn_functional_multilabel_soft_margin_loss_xpu_float32 (main.TestFakeTensorXPU)

Traceback (most recent call last): File "/home/gta/miniforge3/envs/daisy_upstream/lib/python3.10/site-packages/torch/_subclasses/fake_utils.py", line 182, in __torch_dispatch torch._prims.utils.compare_tensor_meta( File "/home/gta/miniforge3/envs/daisy_upstream/lib/python3.10/site-packages/torch/_prims_common/init__.py", line 156, in compare_tensor_meta raise AssertionError(msg) AssertionError: Shapes torch.Size([0]) and torch.Size([5]) are not equal!

Another issue is in backward:

ERROR: test_fake_crossref_backward_amp_nn_functional_multilabel_soft_margin_loss_xpu_float32 (main.TestFakeTensorXPU)

Traceback (most recent call last): File "/home/gta/miniforge3/envs/daisy_upstream/lib/python3.10/site-packages/torch/_subclasses/fake_utils.py", line 182, in __torch_dispatch torch._prims.utils.compare_tensor_meta( File "/home/gta/miniforge3/envs/daisy_upstream/lib/python3.10/site-packages/torch/_prims_common/init__.py", line 156, in compare_tensor_meta raise AssertionError(msg) AssertionError: Shapes torch.Size([0]) and torch.Size([5]) are not equal!

To reproduce, change test/test_ops.py instantiate_device_type_tests(TestFakeTensor, globals()) ==> instantiate_device_type_tests(TestFakeTensor, globals(), allow_xpu=True) and run

PYTORCH_TEST_WITH_SLOW=1 python  test_ops.py -k TestTags

Versions

latest version