NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TensorIR: An Abstraction for Automatic Tensorized Program Optimization

Siyuan Feng, Bohan Hou, Hongyi Jin, Wuwei Lin, Junru Shao, Ruihang Lai, Zihao Ye, Lianmin Zheng, Cody Hao Yu, Yong Yu, Tianqi Chen

TL;DR

TensorIR introduces a novel compiler abstraction called a block that treats specialized hardware tensor instructions (like NVIDIA Tensor Cores) as first-class citizens. By isolating tensorized computation from loop transformations, it enables an end-to-end framework to automatically generate programs that match or exceed the performance of hand-optimized vendor libraries across different hardware backends.

What Problem Does This Paper Address?

Modern hardware is increasingly specialized. To keep up with the computational demands of deep learning, chips now feature dedicated primitives for multi-dimensional tensor math—think NVIDIA’s Tensor Cores or Google’s TPU.

However, existing machine learning compilers (like TVM or Halide) were largely designed for scalar and vector operations. Bridging the gap between high-level model code and these low-level, specialized "intrinsics" usually requires massive manual engineering effort from domain experts to write custom kernel libraries (e.g., cuDNN). This creates a bottleneck: every time new hardware or a new model architecture arrives, experts must manually re-optimize the kernels. TensorIR aims to automate this process, providing a general way to represent and optimize programs for any tensor-accelerated hardware.

Methods

The authors propose a "divide and conquer" approach to compilation, centered around three main pillars:

  1. The Block Abstraction: This is the core innovation. A block encapsulates a region of tensor computation. Crucially, it includes a block signature that explicitly defines iterator domains and producer-consumer dependencies. This signature acts as an interface, allowing the compiler to transform outer loop nests (tiling, reordering) without needing to understand the complex, potentially opaque logic inside the block itself.

    Figure 5: Blocks contain complete signature for dependency analysis and we make it an isolation level between body computation and outer loop nesting.
  2. Tensorization-Aware Scheduling: The framework introduces new primitives like blockize, which groups scalar operations into blocks that match the shape of hardware intrinsics. It also uses a "characteristic vector" matching algorithm to automatically identify which parts of a high-level program can be mapped to specific hardware instructions.

  3. Automatic Search Pipeline: Building on the block abstraction, the authors developed an auto-scheduler that:
  4. Generates sketches (high-level optimization plans).
  5. Treats data movement as a first-class citizen, inserting AutoCopy blocks to manage memory bottlenecks.
  6. Uses an evolutionary search guided by a learned cost model to find the best parameters (like tile sizes) for a specific hardware target.

Datasets

The framework was evaluated using a suite of standard deep learning operators and end-to-end models:

  • Operators: 1D/2D/3D convolutions, depthwise/dilated/group convolutions, and GEMM (General Matrix Multiply).
  • Models: ResNet-50, MobileNet V2, BERT_large, and Vision Transformer (ViT).
  • Hardware Platforms: NVIDIA RTX 3080 (GPU with Tensor Cores) and AWS Graviton2 (ARM CPU with sdot instructions).

Key Insights and Ideas

  • Isolation is Power: By using blocks to isolate computation from scheduling, the compiler can perform aggressive loop transformations while maintaining correctness through simple dependency checks on the block signature.
  • Data Movement is the New Bottleneck: Because tensor intrinsics are so fast, the time spent moving data between memory tiers often dominates. TensorIR elevates data movement to a "first-class citizen" in its auto-scheduler, ensuring memory access is optimized alongside computation.
  • Unified Representation: The same block abstraction is used to describe both the high-level user program and the low-level hardware intrinsics, making the "matching" process mathematically cleaner.
  • Faster Tuning: The structured search space created by the block abstraction allows the auto-scheduler to find optimal configurations up to 2x faster than previous state-of-the-art compilers like TVM.

Key Results

TensorIR demonstrates significant performance gains and broad hardware applicability:

  • Speedups: On NVIDIA GPUs, it achieved up to a 7.5x speedup over existing compilers (TVM and AMOS) for heavy workloads like 3D convolution and GEMM.
  • Competitive with Experts: It reached 88%–100% of the throughput of heavily hand-optimized vendor libraries like NVIDIA’s TensorRT and ARM’s Compute Library.
  • End-to-End Performance: For full models, TensorIR outperformed PyTorch and TVM by 1.2x to 8.8x. Notably, it provided high performance for emerging models like Vision Transformers (ViT), which some vendor libraries did not yet fully support at the time of writing.
  • Cross-Platform: The same framework successfully optimized programs for both NVIDIA GPUs and ARM CPUs by simply swapping the hardware intrinsic descriptions.

Limitations and Future Work

While TensorIR is highly effective for dense tensor computations, the authors note that extending this abstraction to sparse tensor algebra (where many values are zero) is a promising but distinct challenge. Additionally, while the current cost model is effective, the authors believe that developing specialized cost models specifically for tensorized programs is a fertile ground for future research. Finally, the current implementation uses a default order for fusion during tensorization matching; generalizing this to explore different fusion orders could unlock even more performance.

Summary updated

BibTeX
@inproceedings{feng2023tensorir,
  author = {Siyuan Feng and Bohan Hou and Hongyi Jin and Wuwei Lin and Junru Shao and Ruihang Lai and Zihao Ye and Lianmin Zheng and Cody Hao Yu and Yong Yu and Tianqi Chen},
  title = {{TensorIR: An Abstraction for Automatic Tensorized Program Optimization}},
  booktitle = {ASPLOS},
  year = {2023},
  doi = {10.1145/3575693.3576933},
}
Figure