Formalizing einsum with Named Tensor Notation
Yafei Yang, Chung-chieh Shan
Abstract
Einstein notation (einsum) is a widely adopted tensor operation that has proven useful in areas such as machine learning and quantum computing. But it had no formal semantics until recently, and its properties had no mechanized verification. We formalize the denotational semantics of a language of tensors (multi-dimensional arrays) that supports einsum and repeated tensors (expand). With this semantics, we verify equational rewriting rules about einsum and expand that improve the performance of tensor computation. Whereas typical languages use unnamed tensors, whose shape is a sequence of natural numbers, we found it advantageous for mechanization to use named tensors, whose shape is a finite map from names to natural numbers. To our knowledge, this is the first time that the semantics and rewriting rules of einsum are mechanized in a proof assistant. Our solution is agnostic to proof assistants; we have implemented it in Lean and partially in Agda.
Create a lesson
Related papers
SAFE: Formal Specification and Implementation of a Scalable Analysis Framework for ECMAScript
Shared title terminology · Hongki Lee, Sooncheol Won, Joonho Jin et al.
User-Schedulable Approximations for Quantized Tensor Programs
Shared title terminology · Alex Reinking
Retargetable Compilation for Tensor Kernels via a Unified Layout Abstraction
Shared title terminology · Likai Ma, Renze Chen, Tianqi Li et al.
Contravariant Universe Subtyping, Formalized, Mechanized
Shared title terminology · Shengyi Jiang, Jason Z. S. Hu
Cleave: Scaling Tensor Program Optimization via Decoupled Algebraic Search and Operator Scheduling
Shared title terminology · David Pissarra, Jinkun Lin, Haitian Jiang et al.
A Complete, Formal Semantics for Rust Source Code
Shared title terminology · Daniel Drodt