I have also tried bypassing this issue by passing the three tensor objects
inside a sparse array.
```python
from tvm.contrib import sparse
# create placeholder tensors
...
n = out_c
k = kdim_h * kdim_w * in_c
sparse_weights = sparse.placeholder((n,k), nonzeros=(1-sparsity)*n*k, name='W')
# weights
...
# create output using compositions of te.compute
conv = gemm_conv_sparse_alt(sparse_weights.data, sparse_weights.indices,
sparse_weights.indptr,
...)
# build function
s = te.create_schedule(conv.op)
dtype = 'float32'
func = tvm.build(s, [data, sparse_weights.data, sparse_weights.indices,
sparse_weights.indptr, conv], target=target, name='gemm_conv2d')
# ^ works
X = tvm.nd.array(inputs_np.astype(dtype), ctx)
W = tvm.contrib.sparse.array(weights_np.astype(dtype), shape=kernel_shape,
ctx=ctx)
c = tvm.nd.array(np.zeros(oshape, dtype=dtype), ctx)
func(X, W.data, W.indices, W.indptr, c)
```
The final line of this fails with:
```
File "../src/runtime/library_module.cc", line 78
TVMError: Check failed: ret == 0 (-1 vs. 0) : Assert fail: (1.6f ==
float32(arg1.shape[0])), Argument arg1.shape[0] has an unsatisfied constraint
```
My thought here is that we are passing a placeholder sparse tensor, with only
an estimate of our expected sparsity.
When we pass an actual sparse tensor to the function it will have patterns
different from what the module was built to expect.
It's not like we can pass the contents of the actual data W to the function
build, as they are NDarrays, rather than the Tensor type the function building
expects.
---
[Visit Topic](https://discuss.tvm.ai/t/pass-sparse-tensor-to-tvm-build/7739/2)
to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click
here](https://discuss.tvm.ai/email/unsubscribe/f2b2071c72b5f824a8da34e2d3a39c48c0f7474202f72b4a2a29a358fa46a8dd).