arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1608.00099cs.MScs.PL
收藏

TRIOT:C++11中更快的张量操作

TRIOT: Faster tensor manipulation in C++11

Florian Heyl, Oliver Serang

摘要:

上下文:多维数组被许多不同的算法使用。因此,在多维数组上索引和广播复杂操作是普遍存在的任务,并且可能限制性能。查询:同时索引两个或多个具有不同形状的多维数组(例如,将数据从一个张量复制到另一个更大的零填充张量(预期卷积)很难有效地完成:当张量的维度在编译时未知时,无法应用C,Fortran和Go中的硬编码嵌套for循环。同样,除非在编译时数组的维数是已知的,否则不能使用boost::multi_array,并且实现的风格限制用户在向量化操作中使用索引元组(这是计算多维分布的期望值所必需的)。另一方面,不需要在编译时已知维数或形状的迭代方法(例如,递增并将进位操作应用于索引元组或重新映射平面数组中的整数索引)可能比硬编码的嵌套for循环慢得多。...重要性:操作多维数组是软件中的常见任务,特别是在高性能数值方法中。本文提出了一种新的方法来利用模板递归来转换和应用操作的多维数组,然后演示了卓越的性能和灵活性的操作,可以实现使用这种新的方法。

英文摘要:

[abridged] Context: Multidimensional arrays are used by many different algorithms. As such, indexing and broadcasting complex operations over multidimensional arrays are ubiquitous tasks and can be performance limiting. Inquiry: Simultaneously indexing two or more multidimensional arrays with different shapes (e.g., copying data from one tensor to another larger, zero padded tensor in anticipation of a convolution) is difficult to do efficiently: Hard-coded nested for loops in C, Fortran, and Go cannot be applied when the dimension of a tensor is unknown at compile time. Likewise, boost::multi_array cannot be used unless the dimensions of the array are known at compile time, and the style of implementation restricts the user from using the index tuple inside a vectorized operation (as would be required to compute an expected value of a multidimensional distribution). On the other hand, iteration methods that do not require the dimensionality or shape to be known at compile time (e.g., incrementing and applying carry operations to index tuples or remapping integer indices in the flat array), can be substantially slower than hard-coded nested for loops. ... Importance: Manipulation of multidimensional arrays is a common task in software, especially in high performance numerical methods. This paper proposes a novel way to leverage template recursion to iterate over and apply operations to multidimensional arrays, and then demonstrates the superior performance and flexibility of operations that can be achieved using this new approach.

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

↑