Memory tiling is a compiler optimization that partitions large multi-dimensional arrays or tensors into smaller, fixed-size blocks called tiles to exploit data locality and improve cache utilization during nested loop computations. By restructuring loops to operate on these smaller blocks, the technique ensures that data loaded into fast, on-chip memory (like CPU caches or an NPU's scratchpad) is reused extensively before being evicted, dramatically reducing costly accesses to slower main memory (DRAM). This transformation is fundamental for performance-critical operations like matrix multiplication and convolutional layers in neural networks.
Glossary
Memory Tiling

What is Memory Tiling?
A core compiler optimization for high-performance computing and edge AI, crucial for efficient execution on constrained hardware.
In edge AI compilers like TVM or MLIR, tiling is automated through polyhedral model analysis or heuristic-based schedulers to target specific hardware cache hierarchies. The compiler selects optimal tile sizes based on hardware constraints—such as cache capacity and memory bandwidth—to maximize data reuse. This optimization directly reduces power consumption and latency, which are paramount for deploying efficient models on resource-constrained edge devices. It is often combined with other loop transformations like loop unrolling and vectorization for further performance gains.
Key Characteristics of Memory Tiling
Memory tiling is a foundational compiler optimization that restructures nested loop computations to exploit data locality and cache hierarchy. Its effectiveness is defined by several interdependent characteristics.
Data Locality Exploitation
The primary goal of tiling is to maximize data reuse from fast, on-chip memory (caches). By partitioning large tensors into smaller tiles that fit within cache, the same data elements are accessed multiple times while "hot" in the cache before being evicted. This transforms memory access patterns from streaming (high bandwidth demand) to reusable, dramatically reducing pressure on the main memory bus and lowering effective latency.
Hierarchical Blocking
Effective tiling is often multi-level, mirroring the hardware's memory hierarchy. A compiler might create:
- Register tiles: Tiny blocks that fit in CPU/GPU registers for single-instruction multiple-data (SIMD) operations.
- L1 Cache tiles: Larger blocks that stay in the L1 data cache.
- Shared Memory/ L2 Cache tiles: Even larger blocks for GPU shared memory or CPU L2/L3 cache. Each level is sized to match the capacity and associativity of its corresponding hardware structure to minimize cache conflicts and thrashing.
Loop Nest Transformation
Tiling fundamentally restructures loop nests. For a matrix multiplication C[i][j] += A[i][k] * B[k][j], a tiled version adds two new outer loops over tile indices (Ti, Tj, Tk) and partitions the inner loops to iterate within a tile. This changes the loop order from, e.g., i,k,j to Ti,Tj,Tk,i,k,j, creating a blocked algorithm. The compiler must choose a tiling schedule that balances parallelism, locality, and hardware prefetching behavior.
Tile Size Selection
Choosing the optimal tile dimensions is critical and non-trivial. Factors include:
- Cache capacity and line size.
- Translation lookaside buffer (TLB) coverage to avoid page faults.
- Arithmetic intensity (FLOPs per byte) of the kernel.
- Hardware prefetcher characteristics. Compilers often use auto-tuning to empirically search the parameter space (tile height, width, depth) or employ polyhedral model analysis to derive optimal sizes analytically for regular loops.
Conflict with Parallelism
Tiling introduces a tension between locality and parallelism. Large tiles improve locality but reduce the number of parallel tiles available for distribution across cores or threads, potentially underutilizing the machine. Conversely, very small tiles maximize parallelism but hurt cache reuse. Compilers must perform a trade-off analysis, often using parallel tiling strategies that tile for shared caches (L3) while allowing inner tiles to be distributed across cores for private caches (L1/L2).
Application in Linear Algebra & Convolutions
Tiling is most famously applied in General Matrix Multiply (GEMM) kernels, which are the backbone of deep learning and scientific computing. It is equally crucial for convolutional neural network (CNN) layers. Here, tiling must handle multi-dimensional data (e.g., NCHW format) and sometimes involves implicit GEMM transformations where convolution is converted to a matrix multiplication before tiling. Libraries like BLAS, cuDNN, and compilers like TVM or MLIR heavily rely on advanced tiling schemes for these operations.
Memory Tiling vs. Related Optimizations
A comparison of memory tiling with other key compiler optimizations used to improve the performance of machine learning models, particularly on edge hardware.
| Optimization | Memory Tiling | Operator Fusion | Vectorization | Loop Unrolling |
|---|---|---|---|---|
Primary Goal | Improve data locality & cache reuse | Reduce kernel launch overhead & memory traffic | Exploit data-level parallelism (SIMD) | Reduce loop control overhead |
Key Mechanism | Partitions large tensors into smaller blocks (tiles) | Merges sequential ops into a single kernel | Transforms scalar ops to use vector instructions | Replicates loop body to decrease branch count |
Applicable Loop Structure | Nested loops (e.g., matmul, convolution) | Sequential operations in a dataflow graph | Inner loops over contiguous data | Loops with a fixed, small iteration count |
Memory Hierarchy Target | L1/L2/L3 CPU caches, shared memory (GPU) | Global/device memory bandwidth | Vector registers | Instruction cache & pipeline |
Impact on Instruction Count | Increases (adds tile loop overhead) | Decreases (reduces total kernels) | Decreases (fewer scalar instructions) | Increases (more instructions, less branching) |
Compilation Phase | Mid-level IR (loop transformation) | High-level graph optimization | Low-level code generation | Low-level code generation |
Hardware Agnostic | ||||
Requires Shape Information |
Compiler Frameworks Using Memory Tiling
Memory tiling is a foundational optimization implemented across major AI compiler stacks to maximize data locality and cache efficiency for compute-intensive operations like matrix multiplication and convolution.
Frequently Asked Questions
Memory tiling is a foundational compiler optimization for high-performance computing on edge hardware. These questions address its core mechanisms, benefits, and practical implementation.
Memory tiling is a compiler optimization that partitions large multi-dimensional arrays or tensors into smaller, fixed-size blocks called tiles to improve data locality and cache utilization during nested loop computations. It works by restructuring loop nests to operate on these sub-blocks, ensuring that data loaded into fast cache memory is reused extensively before being evicted. For example, in a naive matrix multiplication C[i][j] += A[i][k] * B[k][j], the inner loops stride through memory inefficiently. A tiled version introduces two additional loop levels to partition the i and j dimensions into blocks (e.g., TILE_SIZE x TILE_SIZE). The computation then proceeds block-by-block, where the tiles of A and B fit into the cache, dramatically reducing costly accesses to slower main memory (DRAM).
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Memory tiling is a foundational compiler optimization. It is closely related to other techniques that transform computational graphs and loops to maximize hardware efficiency for edge AI workloads.
Loop Unrolling
A compiler optimization that replicates the body of a loop multiple times, reducing the overhead of loop control instructions (e.g., increment and branch). This increases the basic block size, enabling more aggressive instruction scheduling and vectorization by exposing more independent operations to the compiler. For example, unrolling an inner loop in a matrix multiplication can allow the compiler to schedule multiple fused multiply-add (FMA) operations in parallel.
Vectorization
A compiler optimization that transforms scalar operations to execute simultaneously on multiple data points using Single Instruction, Multiple Data (SIMD) instructions. It is a critical follow-on optimization to tiling, as the smaller, regular blocks created by tiling are ideal candidates for SIMD lanes. For instance, a tiled 8x8 block of a matrix can be efficiently processed using 256-bit SIMD registers that operate on 8 single-precision floating-point numbers at once.
Operator Fusion
A compiler optimization that merges multiple sequential neural network operations into a single, compound kernel. This reduces intermediate tensor writes to slow main memory, complementing tiling's goal of improving data locality. A classic example is fusing a Convolution, Batch Normalization, and ReLU activation into one kernel, which allows the fused computation to occur entirely within fast cache registers after the initial data is tiled into the cache.
Static Memory Planning
A compiler optimization that pre-allocates and reuses memory buffers for all tensors at compile time. It works in concert with tiling by allowing the compiler to precisely plan the lifetime of each tile's buffer. This eliminates the runtime overhead of dynamic memory allocation (malloc/free) and can minimize the total peak memory footprint, which is critical for memory-constrained edge devices.
Graph Optimization
A high-level compiler pass that transforms a neural network's computational graph before low-level optimizations like tiling. It applies transformations such as constant folding, dead code elimination, and algebraic simplifications. These optimizations reduce the overall operation count and simplify the graph structure, making subsequent loop-based optimizations like tiling more effective and straightforward to apply.
Auto-Tuning
An automated compiler process that searches a space of possible configurations (like tile sizes, unroll factors, and vector widths) to find the optimal version for a specific workload and hardware target. Since the optimal tile size depends on cache hierarchy specifics, auto-tuning empirically tests different configurations to maximize performance, often using techniques like profile-guided optimization (PGO).

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us