learning-chip opened a new issue #8413:
URL: https://github.com/apache/tvm/issues/8413


   ## Problem description
   
    `tvm.contrib.sparse.placeholder` is intended to be an input type for 
`topi.sparse.csrmv` (#1289, #1291). However, passing `sparse.placeholder` to 
`tvm.build` leads to `ValueError: don't know how to convert type <class 
'tvm.contrib.sparse.CSRPlaceholderOp'> to object`.
   
   This is because `tvm.contrib.sparse.CSRPlaceholderOp` cannot pass the check 
inside `tvm.runtime.object_generic.convert_to_object`:
   
   
https://github.com/apache/tvm/blob/26281792e92ae24ec7a14b11e8df8fbacf9c4882/python/tvm/runtime/object_generic.py#L57
   
   where `ObjectTypes` is defined as :
   
https://github.com/apache/tvm/blob/26281792e92ae24ec7a14b11e8df8fbacf9c4882/python/tvm/runtime/object_generic.py#L38
   
   ## Steps to reproduce
   
   Build TVM `0.8.dev` from the latest master branch, and then run:
   
   ```python
   # Adapted from 
https://github.com/apache/tvm/blob/main/tests/python/topi/python/test_topi_sparse.py
   import tvm
   from tvm import te
   from tvm import topi
   import tvm.contrib.sparse as tvmsp
   
   
   def build_csrmv(use_sparse=False, dtype='float32', target='llvm'):
       nr, nc, nnz = te.var("nr"), te.var("nc"), te.var("nnz")
       
       A = tvmsp.placeholder(shape=(nr, nc), nonzeros=nnz, dtype=dtype, 
name="A")
       B = te.placeholder((nc, 1), dtype=dtype, name="B")
       OUT = topi.sparse.csrmv(A, B)
       s = te.create_schedule(OUT.op)
       
       if use_sparse:
           f = tvm.build(
               s, [nr, A, B, OUT], 
               target=target, name="csrmv"
           )
       else:
           f = tvm.build(
               s, [nr, A.data, A.indices, A.indptr, B, OUT], 
               target=target, name="csrmv"
           )
       
       return f
   
   csrmv = build_csrmv()  # works, when passing separate components insides CSR 
matrix
   csrmv_sp = build_csrmv(use_sparse=True)  # failed, when passing the CSR 
matrix as a whole
   ```


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to