Skip to content
Cem Bassoy edited this page Jan 11, 2025 · 17 revisions

General

TLIB(TTM) is header-only library with C++ functions that compute the mode-q tensor-matrix product. It provides free C++ functions for parallel computing the mode-q tensor-times-matrix product of the general form

C = A q B :⇔ C ( i 1 , , i q 1 , j , i q + 1 , , i p ) = i q = 1 n q A ( i 1 , , i q , , i p ) B ( j , i q ) .

where q is the contraction mode, A and C are tensors of order p with shapes n a = ( n 1 , n q 1 , n q , n q + 1 , , n p ) and n c = ( n 1 , , n q 1 , m , n q + 1 , , n p ) , respectively. The order 2 tensor B is a matrix with shape n b = ( m , n q ) .

Flexibility

The number of dimensions (order) p and the dimensions n r as well as the linear tensor layout of the tensors A , B and C can be chosen at runtime, while A and C must have the same tensor layout. The tensor layout is defined with thelp of a permutation tuple π of length p . We have free C++ function which will help you to generate any k order tensor layout, including the first-order (column-major) or the last-order (row-major) storage formats.

Implementation

All C++ functions are based on the Loops-Over-GEMM (LoG) approach and utilize high-performance gemv, gemm or gemm_batch routines of BLAS such as OpenBLAS or Intel MKL without transposing tensors. Depending on the combination of q , p and π , the matrix B might be transposed.

Interfaces

TLIB provides three C++ interfaces to compute the tensor-matrix product, see cpp-interfaces.

Using the the two low-level interfaces, you can specify different versions using tags. TLIB provides 8 different C++ function templates that compute the tensor-matrix product, see cpp-functions.

Usage & Installation

You don't need to install TLIB. However, it needs to be linked with either OpenBLAS or Intel MKL or BLIS/ AOCL when it is used. Support for "standalone" will follow, see installation for more info on usage and test installation.

Issues & Contribution

Users should feel free to report any bugs or problems in issues. For discussions, feel free to comment and discuss any related topics in discussions.

Clone this wiki locally