Using tvm.tir.ir_builder.create()
, I’ve been playing around with for ranges. However, I’ve found that it doesn’t allow for loop ranges that don’t start at zero.
E.g., what is a perfectly valid for loop range in Python:
for i in range(5, 10):
do_something()
Is invalid in the IR:
with irb.for_range(5, 10, name='i') as i:
do_something()
Failing with the error:
File "../src/target/llvm/codegen_cpu.cc", line 960
TVMError: Check failed: is_zero(op->min):
If we visit void CodeGenCPU::VisitStmt_
we see this check is indeed performed.
Of course, we can always sidestep this issue by having a for loop like:
with irb.for_range(0, 5, name='i') as i:
# add 5 to all usages of i
do_something()
However this opens us up to errors, and potentially more arithmetic depending on how the compilation works.
Is this a limitation of LLVM codegen, or an oversight on the TVM side?
If the former, this should be explained in the code via a comment.