About low_level_custom_pass.py


Frankly speaking, I can’t understand low_level_custom_pass.py, after read this tutorial, my self-confidence has been hit very hard, and I don’t know what to do now…

need yr help~


Can you describe in more detail which parts of the tutorial are confusing?

At a high level the tutorial begins by defining the computation for a 128-element vector add, and prints the TVM IR. The tutorial then defines an IR pass that identifies all loops with extent (iteration range) evenly divisible by 8. Next, the tutorial introduces a function that can transform an op (first checking that it was marked by the width8 identification pass), and replacing the marked loop with a pair of loops. This pair of loops is defined to have outer extent (original extent/8), and inner extent 8, with the inner loop vectorized. Putting this all together, the vectorize function first calls the first function to identify all loops with extent divisible by 8, and then calls vectorize8 to vectorize the identified loops. The tutorial wraps this up by adding this new pass to the lowering pass.

Note that it is possible to also do this directly by manipulating the schedule with schedule transformation calls; this tutorial presents a way of doing vectorization automatically.