junrushao1994 commented on a change in pull request #5: URL: https://github.com/apache/tvm-rfcs/pull/5#discussion_r676989948
########## File path: rfcs/0001-meta-schedule-autotensorir.md ########## @@ -107,29 +128,64 @@ best schedule according to measurement results on their device. As introduced in the previous section, in TensorIR, each schedule primitive handles only a very basic transformation of the IR. For example, `split` only splits a loop into two new loops. In the real world, the over-fine granularity of those primitives usually leads to repetitive and verbose -scheduling code, as -[mentioned](https://discuss.tvm.apache.org/t/rfc-tensorir-a-schedulable-ir-for-tvm/7872/43?u=junrushao1994) -by developers in our community. +scheduling code. Take the code snippet in the previous section as an example, a sequence of `split`s +are invoked, followed by a `reorder`, and all these together are called "SSRSRS" tiling. + +To make it more convenient and modular, users are allowed to register **composite schedules** that apply +a sequence of schedule primitives according to certain analysis of the IR. The word *composite* here +is used against the word *primitive*, which means it is a transformation *composed* of those +*primitives*. + +For example, suppose there is a composite schedule called `Inline-All-Elementwise-Operations`, which Review comment: Yeah I added an explanation of `Inline-Elementwise-Operation`: ```python @tvm.script.tir def example_func(...): for i, j in ...: with tir.Block("B") ...: B[i, j] = A[i, j] + 1 for i, j in ...: with tir.Block("C") ...: C[i, j] = B[i, j] + 1 for i, j in ...: with tir.Block("D") ...: D[i, j] = C[i, j] + 1 sch = tir.Schedule(example_func) # `InlineElementwiseOperation` is a composite schedule rule that analyzes a given block. # If the block contains only elementwise computation, and can be inlined into its consumer, # then `sch.compute_inline` is called on that block. inliner = InlineElementwiseOperation() inliner.apply(schedule=sch, block=sch.get_block("B")) inliner.apply(schedule=sch, block=sch.get_block("C")) inliner.apply(schedule=sch, block=sch.get_block("D")) ``` Below is the result after applying this composite schedule and its corresponding trace: ```python >>> print(tvm.script.asscript(sch.mod)) @tvm.script.tir def example_func(...): for i, j in ...: with tir.Block("D") ...: D[i, j] = A[i, j] + 1 + 1 + 1 >>> print(sch.trace) # Block "B" is elementwise and inlinable, then `sch.compute_inline(B)` is called B = sch.get_block("B") sch.compute_inline(B) # Block "C" is elementwise and inlinable, then `sch.compute_inline(C)` is called C = sch.get_block("C") sch.compute_inline(C) # Block "D" is elementwise but does not have a consumer, # so the rule does not call `compute_inline` because it is not inlinable D = sch.get_block("D") ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
