ANSHUMAN87 commented on a change in pull request #6685: URL: https://github.com/apache/incubator-tvm/pull/6685#discussion_r507470035
########## File path: tests/python/frontend/tensorflow/test_forward.py ########## @@ -1750,6 +1750,64 @@ def test_forward_batch_matmul(): _test_batch_matmul((2, 3, 4, 2, 3, 4, 5, 6), (2, 3, 4, 2, 3, 4, 5, 6), "float32", False, True) +####################################################################### +# SparseTensorDenseMatMul +# ---------------------------------- + + +def _test_sparse_dense_matmul(indices, values, A_shape, B_shape, dtype, flip=False): + """ One iteration of sparse_dense_matmul """ + + # TODO: Support adjoint options too + for adjoint_a in [False]: + for adjoint_b in [False]: + with tf.Graph().as_default(): + A_sp = tf.sparse.SparseTensor( + indices=[[0, 0], [1, 2]], values=[4.0, 8.0], dense_shape=A_shape + ) + B = tf.placeholder(shape=B_shape, dtype=dtype, name="B") + + if flip: + result = tf.sparse.sparse_dense_matmul( + B, A_sp, adjoint_a=adjoint_a, adjoint_b=adjoint_b + ) + else: + result = tf.sparse.sparse_dense_matmul( + A_sp, B, adjoint_a=adjoint_a, adjoint_b=adjoint_b + ) + + B_np = np.random.uniform(high=5.0, size=B_shape).astype(dtype) + + # TODO: There is an issue in cuda scheduling for csr, work in progress + compare_tf_with_tvm([B_np], [B.name], result.name, no_gpu=True) + + +def test_forward_sparse_dense_matmul(): + """ sparse_dense_matmul op test""" + ################################################################### + # + # In order to create a SparseTensor, it requires 3 input as below: + # SparseTensor(indices=[[0, 0], [1, 2]], values=[1, 2], dense_shape=[3, 4]) + # + # Above Sparse can be represented in Dense as below : + # [[1, 0, 0, 0] + # [0, 0, 2, 0] + # [0, 0, 0, 0]] + # + # ------------------------------------------------------------------ + + # TODO: False case for flip need to be supported Review comment: As we need to implement new Op to support better, maybe we take it up in next PR! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org