https://github.com/matthiasreumann/t1m
Transposition-free Complex Tensor Contractions
https://github.com/matthiasreumann/t1m
complex-tensors tensor tensor-contraction tensors
Last synced: about 1 year ago
JSON representation
Transposition-free Complex Tensor Contractions
- Host: GitHub
- URL: https://github.com/matthiasreumann/t1m
- Owner: MatthiasReumann
- License: mit
- Created: 2023-05-18T14:08:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T14:26:28.000Z (over 1 year ago)
- Last Synced: 2025-04-15T02:52:37.133Z (about 1 year ago)
- Topics: complex-tensors, tensor, tensor-contraction, tensors
- Language: C++
- Homepage:
- Size: 804 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# t1m
Fusion of the [**T**BLIS](https://github.com/devinamatthews/tblis) approach and the [**1M** Method](https://www.cs.utexas.edu/users/flame/pubs/blis6_toms_rev2.pdf) for complex Matrix-Matrix Multiplication to achieve complex Tensor Contractions.
## Requirements
- BLIS Library ([URL](https://github.com/flame/blis))
- MArray Library ([URL](https://github.com/devinamatthews/marray))
## API
```cpp
namespace t1m
{
void contract(Tensor> A, std::string labelsA,
Tensor> B, std::string labelsB,
Tensor> C, std::string labelsC);
void contract(Tensor> A, std::string labelsA,
Tensor> B, std::string labelsB,
Tensor> C, std::string labelsC);
void contract(float alpha, Tensor A, std::string labelsA,
Tensor B, std::string labelsB,
float beta, Tensor C, std::string labelsC);
void contract(double alpha, Tensor A, std::string labelsA,
Tensor B, std::string labelsB,
double beta, Tensor C, std::string labelsC);
};
```
### Multithreading
The `t1m` library supports OpenMP. The number of threads can be specified with the environment variable `OMP_NUM_THREADS`.
### Example
```cpp
#include
#include "t1m.hpp"
int main()
{
std::complex *A = nullptr, *B = nullptr, *C = nullptr;
t1m::utils::alloc_aligned(&A, 2 * 2 * 2);
t1m::utils::alloc_aligned(&B, 2 * 2);
t1m::utils::alloc_aligned(&C, 2 * 2 * 2);
// initialize values in column major
auto tensorA = t1m::Tensor>({2, 2, 2}, A);
auto tensorB = t1m::Tensor>({2, 2}, B);
auto tensorC = t1m::Tensor>({2, 2, 2}, C);
t1m::contract(tensorA, "abc", tensorB, "bd", tensorC, "acd");
// work with C or tensorC
free(A);
free(B);
free(C);
}
```
## Citation
In case you want refer to `t1m` as part of a research paper, please cite appropriately ([pdf](https://mediatum.ub.tum.de/download/1718165/1718165.pdf)):
```text.bibtex
@thesis {t1m2023,
author = {Matthias Reumann},
title = {Transpose-Free Contraction of Complex Tensors},
year = {2023},
school = {Technical University of Munich},
month = {Aug},
language = {en},
abstract = {Tensor Contraction (TC) is the operation that connects tensors in a Tensor Network (TN). Many scientific applications rely on efficient algorithms for the contraction of large tensors. In this thesis, we aim to develop a transposition-free TC algorithm for complex tensors. Our algorithm fuses high-performance General Matrix-Matrix Multiplication (GEMM), the 1M method for achieving complex with real-valued GEMM, and the Block-Scatter layout for tensors. Consequently, we give an elaborate overview of each. A benchmark for a series of contractions shows that our implementation can compete with the performance of state-of-the-art TC libraries.},
}