Can I use topi operators in hybrid script?


#1

As title.
Besides, I also want to know if a python list can be used in hybrid script.


#2

CC: @were if you have bandwidth


#3

Generally speaking, in TVM, we want small ops instead of large ones, because the compiler could automatically do optimization for you (e.g. fuse some operators if possible).

In your particular case (use topi operators in hybrid script), I would suggest to built up a Relay IR.

Python tuple should be supported.


#4

Yes, you can use TOPI as an upstream op and it can be passed to hybrid script’s argument list.

Refer tests/python/unittest/test_hybrid_script's test_upstream function for more details.

For full language feature implemented by hybrid script, refer language manual for more details.

Generally speaking, yes and no.
If you want to use a Python list for software emulation, yes. You can pass it, as long as your code will not exceed the index.
If you want to use Python list as a constant tensor in compilation, no. You need to use tvm.convert to change it to tvm.container.Array.