diff --git a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_dense_mat_mul_grad_test.py b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_dense_mat_mul_grad_test.py index c56ac88249f..5cd206ccbc1 100644 --- a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_dense_mat_mul_grad_test.py +++ b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_dense_mat_mul_grad_test.py @@ -106,7 +106,11 @@ class CSRSparseMatrixDenseMatMulGradTest(test.TestCase): # These tests are refactored from sparse_csr_matrix_grad_test to keep its size # "medium". -for dtype in (np.float32, np.complex64): +dtypes_to_test = [np.float32] +if not test.is_built_with_rocm: + # complex type is not supported on the ROCm platform + dtypes_to_test += [np.complex64] +for dtype in dtypes_to_test: for (t_a, t_b, adj_a, adj_b, t_out, conj_out) in itertools.product(*(([False, True],) * 6)): diff --git a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_grad_test.py b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_grad_test.py index e6425fcdc94..a8da71be4d9 100644 --- a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_grad_test.py +++ b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_grad_test.py @@ -84,6 +84,10 @@ class CSRSparseMatrixGradTest(test.TestCase): if not self._gpu_available: return + if test.is_built_with_rocm(): + # sparse-matrix-add op is not yet supported on the ROCm platform + self.skipTest("sparse-matrix-add op not supported on ROCm") + sparsify = lambda m: m * (m > 0) for dense_shape in ([53, 65, 127], [127, 65]): a_mats_val = sparsify(np.random.randn(*dense_shape)) diff --git a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py index c05e50664b2..958e413940d 100644 --- a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py +++ b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py @@ -432,6 +432,10 @@ class CSRSparseMatrixOpsTest(test.TestCase): if not self._gpu_available: return + if test.is_built_with_rocm(): + # sparse-matrix-add op is not yet supported on the ROCm platform + self.skipTest("sparse-matrix-add op not supported on ROCm") + a_indices = np.array([[0, 0], [2, 3]]) a_values = np.array([1.0, 5.0]).astype(np.float32) a_dense_shape = [5, 6] @@ -469,6 +473,10 @@ class CSRSparseMatrixOpsTest(test.TestCase): if not self._gpu_available: return + if test.is_built_with_rocm(): + # sparse-matrix-add op is not yet supported on the ROCm platform + self.skipTest("sparse-matrix-add op not supported on ROCm") + sparsify = lambda m: m * (m > 0) dense_shape = [53, 65, 127] a_mats = sparsify(np.random.randn(*dense_shape)).astype(np.float32) @@ -511,6 +519,10 @@ class CSRSparseMatrixOpsTest(test.TestCase): @test_util.run_in_graph_and_eager_modes def testSparseMatrixMatMulConjugateOutput(self): + if test.is_built_with_rocm(): + # complex types are not yet supported on the ROCm platform + self.skipTest("complex type not supported on ROCm") + for shapes in [[(5, 6), (6, 1)], [(5, 6), (6, 2)]]: a_indices = np.array([[0, 0], [2, 3]]) a_values = np.array([1.0 + 1.j, 5.0 - 2.j]).astype(np.complex64) @@ -533,8 +545,17 @@ class CSRSparseMatrixOpsTest(test.TestCase): @test_util.run_in_graph_and_eager_modes def testLargeBatchSparseMatrixMatMul(self): + dtypes_to_test = [np.float32] + if not test.is_built_with_rocm(): + # complex types is not supported on the ROCm platform + dtypes_to_test += [np.complex64] + + if test.is_built_with_rocm(): + # TODO(rocm): fix this + self.skipTest("hipSPARSE all failure on the ROCm platform") + sparsify = lambda m: m * (m > 0) - for dtype in np.float32, np.complex64: + for dtype in dtypes_to_test: for (transpose_a, transpose_b) in ((False, False), (False, True), (True, False), (True, True)): for (adjoint_a, adjoint_b) in ((False, False), (False, True), @@ -584,8 +605,17 @@ class CSRSparseMatrixOpsTest(test.TestCase): @test_util.run_in_graph_and_eager_modes def testLargeBatchSparseMatrixMatMulTransposed(self): + dtypes_to_test = [np.float32] + if not test.is_built_with_rocm(): + # complex types is not supported on the ROCm platform + dtypes_to_test += [np.complex64] + + if test.is_built_with_rocm(): + # TODO(rocm): fix this + self.skipTest("hipSPARSE all failure on the ROCm platform") + sparsify = lambda m: m * (m > 0) - for dtype in np.float32, np.complex64: + for dtype in dtypes_to_test: for (transpose_a, transpose_b) in ((False, False), (False, True), (True, False), (True, True)): for (adjoint_a, adjoint_b) in ((False, False), (False, True), @@ -636,6 +666,10 @@ class CSRSparseMatrixOpsTest(test.TestCase): @test_util.run_in_graph_and_eager_modes def testLargeBatchSparseMatrixMatMulConjugate(self): + if test.is_built_with_rocm(): + # complex types are not yet supported on the ROCm platform + self.skipTest("complex type not supported on ROCm") + sparsify = lambda m: m * (m > 0) a_dense_shape = [53, 65, 127] b_dense_shape = [53, 127, 67] @@ -767,6 +801,10 @@ class CSRSparseMatrixOpsTest(test.TestCase): if not self._gpu_available: return + if test.is_built_with_rocm(): + # sparse-matrix-add op is not yet supported on the ROCm platform + self.skipTest("sparse-matrix-add op not supported on ROCm") + sparsify = lambda m: m * (m > 0) dense_shape = [53, 65, 127] matrices = [ @@ -1154,9 +1192,10 @@ class CSRSparseMatrixOpsTest(test.TestCase): ] # ]).astype(np.complex128) - data_types = [ - dtypes.float32, dtypes.float64, dtypes.complex64, dtypes.complex128 - ] + data_types = [dtypes.float32, dtypes.float64] + if not test.is_built_with_rocm(): + # complex type is not supported on the ROCm platform + data_types += [dtypes.complex64, dtypes.complex128] for dtype in data_types: sparse_matrix = dense_to_csr_sparse_matrix( math_ops.cast(dense_mat, dtype)) diff --git a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_test.py b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_test.py index 74456229b49..66077f5b2d2 100644 --- a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_test.py +++ b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_test.py @@ -154,7 +154,11 @@ class SparseMatrixMatmulTest(test.TestCase): sparsify = lambda m: m * (m > 0) dense_shape_a = [5, 13, 7] if transpose_a or adjoint_a else [5, 7, 13] dense_shape_b = [5, 15, 13] if transpose_b or adjoint_b else [5, 13, 15] - for dtype in np.float32, np.complex64: + dtypes_to_test = [np.float32] + if not test.is_built_with_rocm(): + # complex type is not supported on the ROCm platform + dtypes_to_test += [np.complex64] + for dtype in dtypes_to_test: a_mats = sparsify((np.random.randn(*dense_shape_a) + 1.j * np.random.randn(*dense_shape_a))).astype(dtype) b_mats = sparsify((np.random.randn(*dense_shape_b) + @@ -194,7 +198,11 @@ class SparseMatrixMatmulTest(test.TestCase): sparsify = lambda m: m * (m > 0) dense_shape_a = [5, 13, 7] if transpose_a or adjoint_a else [5, 7, 13] dense_shape_b = [5, 15, 13] if transpose_b or adjoint_b else [5, 13, 15] - for dtype in np.float32, np.complex64: + dtypes_to_test = [np.float32] + if not test.is_built_with_rocm(): + # complex type is not supported on the ROCm platform + dtypes_to_test += [np.complex64] + for dtype in dtypes_to_test: a_mats = sparsify((np.random.randn(*dense_shape_a) + 1.j * np.random.randn(*dense_shape_a))).astype(dtype) b_mats = (np.random.randn(*dense_shape_b) + @@ -231,7 +239,11 @@ class SparseMatrixMatmulTest(test.TestCase): sparsify = lambda m: m * (m > 0) dense_shape_a = [5, 13, 7] if transpose_a or adjoint_a else [5, 7, 13] dense_shape_b = [5, 15, 13] if transpose_b or adjoint_b else [5, 13, 15] - for dtype in np.float32, np.complex64: + dtypes_to_test = [np.float32] + if not test.is_built_with_rocm(): + # complex type is not supported on the ROCm platform + dtypes_to_test += [np.complex64] + for dtype in dtypes_to_test: a_mats = (np.random.randn(*dense_shape_a) + 1.j * np.random.randn(*dense_shape_a)).astype(dtype) b_mats = sparsify((np.random.randn(*dense_shape_b) +