Relax vs. TensorIR: TVM Unity's Dual IR Powerhouses
Relax functions as the high-level computational graph IR, crucial for symbolic shape support and whole-graph optimizations, while TensorIR is the low-level tensor program IR, detailing loops and hardware acceleration. This dual approach in TVM Unity enables fluid cross-layer interactions for comprehensive optimization.
The top 3
- Relax's Graph-Level vs. TensorIR's Kernel-Level Optimization: Relax, as a high-level graph IR, excels at model-wide transformations like operator fusion and dynamic shape optimization, while TensorIR specializes in low-level loop transformations, memory access patterns, and hardware-specific intrinsics for individual tensor operations. [1, 4, 9, 10, 17]
- The `call_tir` Intrinsic: TVM Unity's Cross-Layer Bridge: The `R.call_tir` function in Relax serves as a critical intrinsic, enabling high-level Relax functions to seamlessly invoke lower-level TensorIR primitive functions and external libraries, thereby bridging the abstraction gap for unified cross-layer optimization within TVM Unity. [1, 6, 9]
- Dynamic Shape Mastery: Relax's Symbolic Edge for LLMs: Relax significantly improves upon its predecessor, Relay, by providing first-class symbolic shape support, which is vital for expressing and optimizing dynamic shape workloads prevalent in Large Language Models (LLMs), allowing for more effective compiler analysis and optimization opportunities. [1, 2, 6]
Sources
Open the full topic