I am planning to build another front end for TVM, because:
- some patterns, like triangular memory access, and fine-grained dependences, cannot be easily represented by TVM high-level language
- the current ir-builder, although works, makes code redundant
I propose a Python subset which can be lowered to Halide IR, and so far it only uses:
- for loop
for i in range(5):
# something
- TVM specialized array (Some TVM interface should be added)
a = tvm.allocate_array_with_shape((5, 5))
- if-then-else (no elif)
if cond1:
#then clause
else:
#else clause
- arithmetic operations (including sqrt, log, and etc)
- to simplify the type specification, maybe type annotation is required:
def func_module(a: tvm.Tensor, b: tvm.Tensor, c: tvm.Tensor) -> int:
Something I am not sure yet:
Halide IR does not support variable write, all the variables to be written are arrays with length one. I have 2 solutions to this issue so far:
- Let the compiler automatically detect the variable r/w and replace it with array declaration
- Add new function call intrinsics for variable declaration and write. The write function should be a non-side-effect-free intrinsic
All the comments and suggestions will be appreciated.