ANSHUMAN87 commented on pull request #7148:
URL: https://github.com/apache/tvm/pull/7148#issuecomment-760296703


   > So I just hit the bug that this fixes. Can we add a test to make sure we 
don't hit it again in the future. Here is the test I wrote:
   > 
   > ```python
   > @tvm.testing.requires_cuda
   > def test_sparse_dense_padded_alter_op():
   >     with tvm.target.Target("cuda"):
   >         M = 128
   >         N = 16
   >         K = 128
   >         X_np = np.random.randn(M, K).astype("float32")
   >         W_sp_np = random_bsr_matrix(N, K, 2, 2, density=0.01, 
dtype="float32")
   >         x = relay.var("x", relay.TensorType(X_np.shape,"float32"))
   >         mult = relay.op.nn.sparse_dense(
   >             x,
   >             (
   >                 relay.Constant(tvm.nd.array(W_sp_np.data)),
   >                 relay.Constant(tvm.nd.array(W_sp_np.indices)),
   >                 relay.Constant(tvm.nd.array(W_sp_np.indptr)),
   >             ),
   >         )
   >         f = relay.Function([x], mult)
   >         f_ = relay.transform.InferType()(tvm.IRModule.from_expr(f))
   >         f_ = relay.transform.AlterOpLayout()(f_)
   >         assert f_["main"].body.op.name == "nn.internal.sparse_dense_padded"
   > 
   >         # build with cuda and AlterOpLayout to ensure that 
sparse_dense_padded is has an implementation
   >         with tvm.transform.PassContext(opt_level=3, 
required_pass="AlterOpLayout"):
   >             x = relay.build(tvm.IRModule.from_expr(f), 
target=tvm.target.Target("cuda"))
   > ```
   > 
   > in `tests/python/topi/python/test_topi_sparse.py`
   
   Thanks @tkonolige ! The test case is added now.


----------------------------------------------------------------
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:
[email protected]


Reply via email to