# Pure Tensor Program Rewriting via Access Patterns (Representation Pearl)

arXiv: https://arxiv.org/abs/2105.09377 · HTML: https://mlsanity.com/paper/2105.09377/

## Key facts

- Cited by 7 papers in the map (data through 14 Oct 2026).
- First posted on arXiv 19 May 2021.

## Built on by (most cited first, 7 of 7)

- [SmartMem: Layout Transformation Elimination and Adaptation for Efficient DNN Execution on Mobile](https://mlsanity.com/paper/2404.13528/) (2024)
- [DyCL: Dynamic Neural Network Compilation Via Program Rewriting and Graph Optimization](https://mlsanity.com/paper/2307.04963/) (2023)
- [Your Compiler is Backdooring Your Model: Understanding and Exploiting Compilation Inconsistency Vulnerabilities in Deep Learning Compilers](https://mlsanity.com/paper/2509.11173/) (2025)
- [e-boost: Boosted E-Graph Extraction with Adaptive Heuristics and Exact Solving](https://mlsanity.com/paper/2508.13020/) (2025)
- [SEER: Super-Optimization Explorer for HLS using E-graph Rewriting with MLIR](https://mlsanity.com/paper/2308.07654/) (2023)
- [nncase: An End-to-End Compiler for Efficient LLM Deployment on Heterogeneous Storage Architectures](https://mlsanity.com/paper/2512.21571/) (2025)
- [Meganeura: Portable GPU Training and Inference through Vulkan and Metal](https://mlsanity.com/paper/2608.01563/) (2026)

## Abstract (arXiv)

Tensor kernels in machine learning (ML) often correspond to pure mathematical expressions, making term rewriting an attractive strategy for optimization and mapping to specialized hardware accelerators. However, existing ML intermediate representations (IRs) tend to either be textitpure but high-level, making low-level rewrites to hardware targets inexpressible, or textitlow-level but impure, hampering the use of term rewriting altogether. This paper introduces Glenside, a pure IR whose core abstraction -- the textitaccess pattern -- enables low-level, layout-aware, hardware-centric program rewrites. We demonstrate how term rewriting in Glenside can be used to map program fragments to hardware accelerator invocations and automatically discover classic data layout transformations like textttim2col. Glenside establishes a new foundation for exploring further term rewriting techniques in optimizing low-level tensor programs.
