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语言的形式化定义。基于此定义,我们形式化地论证了张量表达式的关键等价规则,并阐明了这些规则在实际应用中的重要意义。