arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.15613cs.MS
收藏

用C++表达式模板实现领域特定语言的算法微分

Algorithmic differentiation for domain specific languages in C++ with expression templates

RPTU University Kaiserslautern-Landau(凯泽斯劳滕-兰道理工应用技术大学)

Max Sagebaum, Nicolas R. Gauger

AI总结:

本文提出了一种针对C++领域特定语言的算法微分工具,通过保留原始数据内存结构和注解操作来提升性能和优化能力。

摘要:

将运算符重载的算法微分(AD)应用于计算机程序以计算导数相当常见。但,将底层计算浮点类型替换为AD工具的专用类型会带来两个问题。首先,程序的内存结构发生变化,浮点数据与AD的标识符交织在一起,这阻止了编译器进行诸如SIMD优化之类的优化。其次,AD工具无法看到程序使用的任何领域特定操作,例如线性代数操作,这阻止了AD工具在这些地方使用专用算法。我们提出了一种专门针对这种情况的新的AD工具。通过将每个实体(例如矩阵)与标识符关联,而不是每个浮点值(例如矩阵元素),保留了原始数据的内存结构。对这些实体的操作可以进行注解,并使用生成器创建AD重载。我们证明这种方法的性能与其他专有化相当。此外,对于仅使用线性代数实体和操作编写的程序,运行时因子低于反向AD理论上的4.5。

英文摘要:

The application of operator overloading algorithmic differentiation (AD) to computer programs in order to compute the derivative is quite common. But, the replacement of the underlying computational floating point type with the specialized type of an AD tool has two problems. First, the memory structure of the program is changed and floating-point data is interleaved with identifiers from AD. This prevents the compiler from performing optimizations such as SIMD optimizations. Second, the AD tool does not see any domain-specific operations, e.,g. linear algebra operations, that the program uses. This prevents the AD tool from using specialized algorithms in such places. We propose a new AD tool that is tailored to such situations. The memory structure of the primal data is retained by associating an identifier with each entity, e.,g. matrix, and not with each floating point value, e.,g. element of the matrix. Operations on such entities can then be annotated and a generator is used to create the AD overloads. We demonstrate that this approach provides performance comparable to that of other specializations. In addition, the run-time factor is below the theoretical 4.5 of reverse AD for programs that are written purely with linear algebra entities and operations.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑