Hi, I’m trying to write my own injective schedule for a custom accelerator.
I’m basing my schedule of off the generic injective schedule at /python/tvm/topi/generic/injective.py
However, I have difficulty understanding what te.schedule.AutoInlineInjective
actually does, and why it should be called.
Also, why is there a fuse operation done on this line?
Is this to make sure all operations that have the same bounds are executed within the same for loops?
How do you fuse all axes with that statement then?
Thanks!
Best regards!
Hi @JosseVanDelm, IMO, this is a way to remove the redundant operations and injective operations are always safe to be inlined because they are one to one functions. See tvm/auto_inline_elem_wise.cc at 7f969864d90ae3f57a9bad4ccf3eacd3c49e44d9 · apache/tvm · GitHub
@leeexyz thanks for your reply!
I’m not sure whether I understand what inlining means.
From Schedule Primitives in TVM — tvm 0.8.dev0 documentation
Do I get it correctly that the calculation of B is “moved in” the calculation of A, so that you have only one for loop instead of two for loops?
So
for{
operations_on_A
}
for{
operations_on_B
}
Would become
for{
operations_on_A; operations_on_B
}
With redundant operations, you mean removing the double for loop then?
Does this inlining interfere with tensorized operations? Let’s say i have tensorized A and inlined with B. Where both operations are on 2 dimensional tensors,
Would it produce:
for{
operation_A_tensorized.
for{
operation_B
}
}
?
Thanks!
Inline will remove the redundant operations and rewrite the data flow, not just simply remove for loops. See src/te/schedule/schedule_dataflow_rewrite.cc:InjectInline
I think inline does interfering with Tensorize operation like setting the shape of placeholder in intrinsic function, etc. 