Is there a way to do flatten and reshape?

Hi,

Suppose I want to do an element-wise add function for arbitrary shaped tensor, is there a way to specify inside tvm.compute a flatten followed by reshape to original shape after addition? I can’t find either flatten or reshape in the doc.

Thanks!

reshape is implemented as part of topi library, see https://github.com/dmlc/tvm/blob/master/topi/python/topi/transform.py#L115

You can use reshape to implement the flatten. Note that we can also directly use topi to implement ewise add for any shaped tensor as long as their shape is known.

To manually flatten things, we can also describe a 1D computation, and construct DLTensor view outside the function before we pass into the constructed function