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.
翻译:2011年,einsum作为一种实用且便捷的张量表达式表示法被引入NumPy,广泛应用于机器学习、量子电路模拟等领域。此后,该表示法已在PyTorch、TensorFlow等其他Python框架以及Julia等编程语言中得到实现。尽管einsum在实践中取得了成功,但其表示法仍缺乏坚实的理论基础,且在不同框架中尚未统一,这限制了形式化推理与系统化优化的可能性。本文探讨了张量表达式的术语体系,并给出了einsum语言的形式化定义。基于此定义,我们形式化地证明并阐述了张量表达式的重要等价规则,并强调了这些规则在实际应用中的重要意义。