arXiv:2509.20020cs.PLcs.LG2025-09

为einsum提供理论基础,统一不同框架的张量运算规则

The Syntax and Semantics of einsum

  • 定义einsum语言的正式语法与语义
  • 证明张量表达式的关键等价规则
  • 帮助开发者进行形式化推理与优化

2011年,einsum被引入NumPy,作为机器学习、量子电路模拟等领域中张量运算的实用便捷符号。此后,PyTorch、TensorFlow和Julia等框架也相继实现。尽管应用广泛,einsum仍缺乏统一的理论基础,各框架间定义不一致,限制了形式化推理与系统优化。本文梳理张量表达式的术语体系,给出einsum语言的正式定义,并基于此形式化证明关键等价规则,揭示其在实际应用中的重要性。

原文摘要 · Abstract (English)

In 2011, einsum was introduced to NumPy as a practical and convenient notation for tensor expressions in machine learning, quantum circuit simulation, and other fields. It has since been implemented in additional Python frameworks such as PyTorch and TensorFlow, as well as in other programming languages such as Julia. Despite its practical success, the einsum notation still lacks a solid theoretical basis, and is not unified across the different frameworks, limiting opportunities for formal reasoning and systematic optimization. In this work, we discuss the terminology of tensor expressions and provide a formal definition of the einsum language. Based on this definition, we formalize and prove important equivalence rules for tensor expressions and highlight their relevance in practical applications.

张量计算形式化Python

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。