已合并
test: adapt Tensor.indices upstream case for NPU #42805
Flipped创建于 7月26日
test: adapt Tensor.indices upstream case for NPU #42805
已合并
共 1 个文件变更+30-0
| @@ -0,0 +1,30 @@ | |||
| 1 | +diff --git a/test/test_sparse.py b/test/test_sparse.py | ||
| 2 | +index fcc4a7c..8b6b31d 100644 | ||
| 3 | +--- a/test/test_sparse.py | ||
| 4 | ++++ b/test/test_sparse.py | ||
| 5 | + from packaging import version | ||
| 6 | + from torch.testing._internal.common_cuda import \ | ||
| 7 | + (SM80OrLater, TEST_MULTIGPU) | ||
| 8 | + from torch.testing._internal.common_device_type import \ | ||
| 9 | +- (instantiate_device_type_tests, ops, dtypes, dtypesIfCUDA, dtypesIfMPS, onlyCPU, onlyCUDA, precisionOverride, | ||
| 10 | ++ (instantiate_device_type_tests, ops, dtypes, dtypesIfCUDA, dtypesIfMPS, dtypesIfPRIVATEUSE1, onlyCPU, onlyCUDA, precisionOverride, | ||
| 11 | + deviceCountAtLeast, OpDTypes, onlyNativeDeviceTypes, skipCUDAIf, expectedFailureMPS, | ||
| 12 | + expectedFailureMPSComplex, largeTensorTest) | ||
| 13 | + from torch.testing._internal.common_methods_invocations import \ | ||
| 14 | + from torch.testing._internal.opinfo.refs import ( | ||
| 15 | + ReductionPythonRefInfo | ||
| 16 | + ) | ||
| 17 | + | ||
| 18 | ++from torch_npu.contrib import transfer_to_npu # noqa: F401 | ||
| 19 | ++ | ||
| 20 | + def _op_supports_any_sparse(op): | ||
| 21 | + return (op.supports_sparse | ||
| 22 | + or op.supports_sparse_csr | ||
| 23 | + class TestSparse(TestSparseBase): | ||
| 24 | + @coalescedonoff | ||
| 25 | + @dtypes(torch.double, torch.cdouble) | ||
| 26 | + @dtypesIfMPS(torch.float32, torch.complex64) | ||
| 27 | ++ @dtypesIfPRIVATEUSE1(torch.float) | ||
| 28 | + def test_basic(self, device, dtype, coalesced): | ||
| 29 | + def test_shape(sparse_dims, nnz, with_size): | ||
| 30 | + if isinstance(with_size, Number): | ||