IP Library Granted Patent US 12,572,341
Granted Patent B2
US 12,572,341 · App. 17/853,488 · Granted Mar 10, 2026

Compiling tensor operators for neural network models based on tensor tile configurations

Inventors: Jilong Xue (Beijing, CN); Lingxiao Ma (Beijing, CN); Yuqing Xia (Beijing, CN); Wei Cui (Beijing, CN); Fan Yang (Beijing, CN); Mao Yang (Beijing, CN); Lidong Zhou (Beijing, CN)
Assignee: Microsoft Technology Licensing, LLC.
G06F8/453G06F8/443G06F8/447G06F9/5072
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,572,341
App. No.
17/853,488
Granted
Mar 10, 2026
Kind
B2
Abstract

Embodiments of the present disclosure include systems and methods for compiling tensor operators for neural network models based on tensor tile configurations. A tensor expression for a neural network model is received. A tensor tile configuration for the tensor expression is determined based on specifications associated with a set of hardware devices. Based on the tensor tile configuration, a set of code for implementing the tensor expression for the neural network model is generated. The set of code is for execution on the set of hardware.

Claims (31)

1 . A non-transitory machine-readable medium storing a program executable by at least one processing unit of a device, the program comprising sets of instructions for:

receiving a tensor expression for a neural network model, wherein the tensor expression specifies an operator that takes a set of input tensors, performs computations on the set of input tensors, and stores a result of the computations in an output tensor;

determining a tensor tile configuration for the tensor expression based on specifications associated with a set of hardware devices, the tensor tile configuration comprising a plurality of tensor tile shapes associated with the set of input tensors and the output tensor, the plurality of tensor tile shapes optimized for a plurality of memory layers of a memory architecture of a particular hardware device, wherein a different valid tensor tile shape with a highest memory metric is determined for each memory layer of the plurality of memory layers, wherein each tensor tile shape of the plurality of tensor tile shapes is associated with dimensions inferred from a tensor tile shape definition, the tensor tile shape definition associated with the tensor expression, and wherein the different valid tensor tile shape is determined based on a set of defined rules; and

based on the tensor tile configuration comprising the plurality of tensor tile shapes, generating a set of code for implementing the tensor expression for the neural network model, the set of code for execution on the plurality of memory layers of the particular hardware device of the set of hardware devices.

2 . The non-transitory machine-readable medium of claim 1 , wherein the specifications associated with the set of hardware devices include a number of threads that can be processed concurrently by the particular hardware device in the set of hardware devices, wherein determining the tensor tile configuration for the tensor expression comprises determining a size of a shape of a tensor tile in the tensor tile configuration that is a multiple of the number of threads that can be processed concurrently by the particular hardware device.

3 . The non-transitory machine-readable medium of claim 1 , wherein the specifications associated with the set of hardware devices include a length of a memory transaction utilized by a hardware device in the set of hardware devices, wherein determining the tensor tile configuration for the tensor expression comprises determining a size of an inner-most dimension of a tensor tile that is a multiple of the length of a memory transaction.

4 . The non-transitory machine-readable medium of claim 1 , wherein the specifications associated with the set of hardware devices include a number of memory banks into which memory included in a hardware device is divided and a width of memory banks, wherein the program further comprises instructions for determining an amount of padding for the tensor expression based on the number of memory banks and the width of memory banks.

5 . The non-transitory machine-readable medium of claim 1 , wherein the tensor expression specifying a set of shapes for the set of input tensors, a shape for the output tensor, and a set of tensor operations operating on the set of input tensors to generate the output tensor.

6 . The non-transitory machine-readable medium of claim 5 , wherein determining the tensor tile configuration for the tensor expression comprises determining a shape of a tensor tile into which the shape of an input tensor in the set of input tensors can be evenly partitioned.

7 . The non-transitory machine-readable medium of claim 1 , wherein determining the tensor tile configuration for the tensor expression comprises replicating the tensor tile configuration for each hardware device in the set of hardware devices other than the particular hardware device.

8 . A method comprising:

receiving a tensor expression for a neural network model, wherein the tensor expression specifies an operator that takes a set of input tensors, performs computations on the set of input tensors, and stores a result of the computations in an output tensor;

determining a tensor tile configuration for the tensor expression based on specifications associated with a set of hardware devices, the tensor tile configuration comprising a plurality of tensor tile shapes associated with the set of input tensors and the output tensor, the plurality of tensor tile shapes optimized for a plurality of memory layers of a memory architecture of a particular hardware device of the set of hardware devices, wherein a different valid tensor tile shape with a highest memory metric is determined for each memory layer of the plurality of memory layers, wherein each tensor tile shape of the plurality of tensor tile shapes is associated with dimensions inferred from a tensor tile shape definition, the tensor tile shape definition associated with the tensor expression, and wherein the different valid tensor tile shape is determined based on a set of defined rules; and

based on the tensor tile configuration comprising the plurality of tensor tile shapes, generating a set of code for implementing the tensor expression for the neural network model, the set of code for execution on the plurality of memory layers of the particular hardware device of the set of hardware devices.

9 . The method of claim 8 , wherein the specifications associated with the set of hardware devices include a number of threads that can be processed concurrently by the particular hardware device in the set of hardware devices, wherein determining the tensor tile configuration for the tensor expression comprises determining a size of a shape of a tensor tile in the tensor tile configuration that is a multiple of the number of threads that can be processed concurrently by the particular hardware device.

10 . The method of claim 8 , wherein the specifications associated with the set of hardware devices include a length of a memory transaction utilized by a hardware device in the set of hardware devices, wherein determining the tensor tile configuration for the tensor expression comprises determining a size of an inner-most dimension of a tensor tile that is a multiple of the length of a memory transaction.

11 . The method of claim 8 , wherein the specifications associated with the set of hardware devices include a number of memory banks into which memory included in a hardware device is divided and a width of memory banks, the method further comprising determining an amount of padding for the tensor expression based on the number of memory banks and the width of memory banks.

12 . The method of claim 8 , wherein the tensor expression specifying a set of shapes for the set of input tensors, a shape for the output tensor, and a set of tensor operations operating on the set of input tensors to generate the output tensor.

13 . The method of claim 12 , wherein determining the tensor tile configuration for the tensor expression comprises determining a shape of a tensor tile into which the shape of an input tensor in the set of input tensors can be evenly partitioned.

14 . The method of claim 8 , wherein determining the tensor tile configuration for the tensor expression comprises replicating the tensor tile configuration for each hardware device in the set of hardware devices other than the particular hardware device.

15 . A system comprising:

a set of processing units; and

a non-transitory machine-readable medium storing instructions that when executed by at least one processing unit in the set of processing units cause the at least one processing unit to:

receive a tensor expression for a neural network model, wherein the tensor expression specifies an operator that takes a set of input tensors, performs computations on the set of input tensors, and stores a result of the computations in an output tensor;

determine a tensor tile configuration for the tensor expression based on specifications associated with a set of hardware devices, the tensor tile configuration comprising a plurality of tensor tile shapes associated with the set of input tensors and the output tensor, the plurality of tensor tile shapes optimized for a plurality of memory layers of a memory architecture of a particular hardware device of the set of hardware devices, wherein a different valid tensor tile shape with a highest memory metric is determined for each memory layer of the plurality of memory layers, wherein each tensor tile shape of the plurality of tensor tile shapes is associated with dimensions inferred from a tensor tile shape definition, the tensor tile shape definition associated with the tensor expression, and wherein the different valid tensor tile shape is determined based on a set of defined rules; and

based on the tensor tile configuration comprising the plurality of tensor tile shapes, generate a set of code for implementing the tensor expression for the neural network model, the set of code for execution on the plurality of memory layers of the particular hardware device of the set of hardware devices.

16 . The system of claim 15 , wherein the specifications associated with the set of hardware devices include a number of threads that can be processed concurrently by the particular hardware device in the set of hardware devices, wherein determining the tensor tile configuration for the tensor expression comprises determining a size of a shape of a tensor tile in the tensor tile configuration that is a multiple of the number of threads that can be processed concurrently by the particular hardware device.

17 . The system of claim 15 , wherein the specifications associated with the set of hardware devices include a length of a memory transaction utilized by a hardware device in the set of hardware devices, wherein determining the tensor tile configuration for the tensor expression comprises determining a size of an inner-most dimension of a tensor tile that is a multiple of the length of a memory transaction.

18 . The system of claim 15 , wherein the specifications associated with the set of hardware devices include a number of memory banks into which memory included in a hardware device is divided and a width of memory banks, wherein the instructions further cause the at least one processing unit to determine an amount of padding for the tensor expression based on the number of memory banks and the width of memory banks.

19 . The system of claim 15 , wherein the tensor expression specifying a set of shapes for the set of input tensors, a shape for the output tensor, and a set of tensor operations operating on the set of input tensors to generate the output tensor.

20 . The system of claim 19 , wherein determining the tensor tile configuration for the tensor expression comprises determining a shape of a tensor tile into which the shape of an input tensor in the set of input tensors can be evenly partitioned.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 29, 2022
From: XUE, JILONG; MA, LINGXIAO; XIA, YUQING; CUI, WEI; YANG, FAN; YANG, MAO; ZHOU, LIDONG
To: MICROSOFT TECHNOLOGY LICENSING, LLC
Reel/Frame 060359/0137 →
Continuity (1)
Related Publication 20240004718A1 · Jan 4, 2024
References Cited (44)
US 11237971B1 · Brown et al. · 2022 [cited by applicant]
US 20230315802A1 · Wang · 2023 [cited by examiner]
WO 2021084506A1 · 2021 [cited by applicant]
Vedurada et al; TTLG—An Efficient Tensor Transposition Library for GPUs; IEEE 2018 (Year: 2018). [cited by examiner]
“A Fast and Versatile Library for Linear and Tensor Algebra”, Retrieved from: http://web.archive.org/web/20170519140220/http:/tensor-compiler.org/, May 19, 2017, 2 Pages. [cited by applicant]
“AMD Radeon Instinct™ MI50 Accelerator”, Retrieved from: https://web.archive.org/web/20181122160018/https:/www.amd.com/en/products/professional-graphics/instinct-mi50, Nov. 22, 2018, 3 Pages. [cited by applicant]
“CuBLAS Library”, In User Guide of NVIDIA, DU-06702-001_v11.7, May 2022, 254 Pages. [cited by applicant]
“CUDA Compiler Driver NVCC”, In Reference Guide of NVIDIA, TRM-06721-001_v11.7, May 2022, 62 Pages. [cited by applicant]
“IPU Programmer's Guide”, Retrieved from: https://web.archive.org/web/20220327163228/https:/docs.graphcore.ai/projects/ipu-overview/en/latest/, Mar. 27, 2022, 1 Page. [cited by applicant]
“MLIR”, Retrieved from: https://web.archive.org/web/20220421204035/https:/mlir.llvm.org/, Apr. 21, 2022, 3 Pages. [cited by applicant]
“NVIDIA cuDNN”, Retrieved from: https://web.archive.org/web/20220415102939/https:/developer.nvidia.com/cudnn, Apr. 15, 2022, 3 Pages. [cited by applicant]
“NVIDIA TensorRT”, In Developer Guide of NVIDIA, PG-08540-001_v8.0.2, Aug. 2021, 160 Pages. [cited by applicant]
“ONNX”, Retrieved from: https://web.archive.org/web/20171015171740/https:/onnx.ai/, Oct. 15, 2017, 3 Pages. [cited by applicant]
“XLA: Optimizing Compiler for Machine Learning”, Retrieved from: https://www.tensorflow.org/xla, Dec. 2, 2012, 7 Pages. [cited by applicant]
Abadi, et al., “TensorFlow: A System for Large-Scale Machine Learning”, In Proceedings of the 12th USENIX Symposium on Operating Systems Design and Implementation, Nov. 2, 2016, pp. 265-283. [cited by applicant]
Aharoni, et al., “HeLayers: A Tile Tensors Framework for Large Neural Networks on Encrypted Data”, In Repository of arXiv:2011.01805v2, Dec. 7, 2021, 17 Pages. [cited by applicant]
Aharoni, et al., “Tile Tensors: A Versatile Data Structure with Descriptive Shapes for Homomorphic Encryption”, In Repository of arXiv:2011.01805v1, Nov. 3, 2020, 17 Pages. [cited by applicant]
Baghdadi, et al., “Tiramisu: A Polyhedral Compiler for Expressing Fast and Portable Code”, In Proceedings of the IEEE/ACM International Symposium on Code Generation and Optimization, Feb. 16, 2019, pp. 193-205. [cited by applicant]
Chen, et al., “Learning to Optimize Tensor Programs”, In Journal of Advances in Neural Information Processing Systems, vol. 31, Dec. 3, 2018, 12 Pages. [cited by applicant]
Chen, et al., “TVM: An Automated End-to-End Optimizing Compiler for Deep Learning”, In Proceedings of the 13th USENIX Symposium on Operating Systems Design and Implementation, Oct. 8, 2018, pp. 579-594. [cited by applicant]
Devlin, et al., “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding”, In Repository of arXiv:1810.04805v1, Oct. 11, 2018, 14 Pages. [cited by applicant]
Feng, Siyuan, “[RFC] TensorIR: A Schedulable IR for TVM”, Retrieved from: https://discuss.tvm.apache.org/t/rfc-tensorir-a-schedulable-ir-for-tvm/7872, Sep. 2020, 11 Pages. [cited by applicant]
Georganas, et al., “Tensor Processing Primitives: A Programming Abstraction for Efficiency and Portability in Deep Learning Workloads”, In Repository of arXiv:2104.05755v1, Apr. 12, 2021, 14 Pages. [cited by applicant]
He, et al., “Deep Residual Learning for Image Recognition”, In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition, Jun. 27, 2016, pp. 770-778. [cited by applicant]
Hochreiter, et al., “Long Short-Term Memory”, In Journal of Neural Computation, vol. 9, Issue 8, Nov. 15, 1997, 32 Pages. [cited by applicant]
Jia, et al., “Dissecting the Graphcore IPU Architecture via Microbenchmarking”, In Repository of arXiv:1912.03413v1, Dec. 7, 2019, 91 Pages. [cited by applicant]
Jia, et al., “Dissecting the NVIDIA Volta GPU Architecture via Microbenchmarking”, In Repository of arXiv:1804.06826v1, Apr. 18, 2018, 66 Pages. [cited by applicant]
Kerr, et al., “NVIDIA / cutlass”, Retrieved from: https://github.com/NVIDIA/cutlass, Jul. 2, 2022, 15 Pages. [cited by applicant]
Kim, Jinsung, “Optimizing Tensor Contractions on GPUs”, A Dissertation Presented in Partial Fulfillment of the Requirements for the Degree Doctor of Philosophy in the Graduate School of the Ohio State University, 2019, … [cited by applicant]
Lavin, et al., “Fast Algorithms for Convolutional Neural Networks”, In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Jun. 27, 2016, pp. 4013-4021. [cited by applicant]
Li, et al., “Analytical Characterization and Design Space Exploration for Optimization of CNNs”, In Proceedings of the 26th ACM International Conference on Architectural Support for Programming Languages and Operating S… [cited by applicant]
Li, et al., “The Deep Learning Compiler: A Comprehensive Survey”, In Repository of arXiv:2002.03794v4, Aug. 28, 2020, 34 Pages. [cited by applicant]
Ma, et al., “Rammer: Enabling Holistic Deep Learning Compiler Optimizations with rTasks”, In Proceedings of the 14th USENIX Symposium on Operating Systems Design and Implementation, Nov. 4, 2020, pp. 881-897. [cited by applicant]
Malavally, et al., “RadeonOpenCompute / ROCm”, Retrieved from: https://github.com/RadeonOpenCompute/ROCm, Jun. 29, 2022, 26 Pages. [cited by applicant]
Prasanna, Shashank, “A Complete Guide to AI Accelerators for Deep Learning Inference—GPUs, AWS Inferentia and Amazon Elastic Inference”, Retrieved from: https://towardsdatascience.com/a-complete-guide-to-ai-accelerators… [cited by applicant]
Ragan-Kelley, et al., “Halide: A Language and Compiler for Optimizing Parallelism, Locality, and Recomputation in Image Processing Pipelines”, In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language De… [cited by applicant]
Springer, et al., “HPTT: A High-Performance Tensor Transposition C++ Library”, In Repository of arXiv:1704.04374v2, May 10, 2017, 7 Pages. [cited by applicant]
Tillet, et al., “Triton: An Intermediate Language and Compiler for Tiled Neural Network Computations”, In Proceedings of the 3rd ACM SIGPLAN International Workshop on Machine Learning and Programming Languages, Jun. 22,… [cited by applicant]
Tollenaere, et al., “Efficient Convolution Optimisation by Composing Micro-Kernels”, Retrieved from: https://hal.archives-ouvertes.fr/hal-03149553v3/document, Oct. 14, 2021, 23 Pages. [cited by applicant]
Vasilache, et al., “Tensor Comprehensions: Framework-Agnostic High-Performance Machine Learning Abstractions”, In Repository of arXiv:1802.04730v1, Feb. 13, 2018, 39 Pages. [cited by applicant]
Zhao, et al., “AKG: Automatic Kernel Generation for Neural Processing Units using Polyhedral Transformations”, In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implement… [cited by applicant]
Zheng, et al., “Ansor: Generating High-Performance Tensor Programs for Deep Learning”, In Proceedings of 14th USENIX Symposium on Operating Systems Design and Implementation, Nov. 4, 2020, pp. 863-879. [cited by applicant]
Zheng, et al., “FlexTensor: An Automatic Schedule Exploration and Optimization Framework for Tensor Computation on Heterogeneous System”, In Proceedings of the Twenty-Fifth International Conference on Architectural Supp… [cited by applicant]
Zoph, et al., “Learning Transferable Architectures for Scalable Image Recognition”, In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Jun. 18, 2018, pp. 8697-8710. [cited by applicant]