Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Functions
CPU tensor kernels

Always-available CPU reference tensor kernels. More...

Collaboration diagram for CPU tensor kernels:

Classes

class  uni20::kernel::cpu::GemmLoop< T, MR, NR, KR >
 Generic M×N×K contraction engine with full K-dimension recursion. More...
 

Functions

template<typename T , std::size_t MR, std::size_t NR, std::size_t KR>
void uni20::kernel::contract_strided (static_vector< extent_strides< 2 >, MR > const &Mgrp, static_vector< extent_strides< 2 >, NR > const &Ngrp, static_vector< extent_strides< 2 >, KR > const &Kgrp, T alpha, T const *A, T const *B, T beta, T *C)
 Execute the CPU tensor contraction using precomputed stride groupings.
 
 uni20::kernel::cpu::GemmLoop< T, MR, NR, KR >::GemmLoop (static_vector< extent_strides< 2 >, MR > const &Mgrp, static_vector< extent_strides< 2 >, NR > const &Ngrp, static_vector< extent_strides< 2 >, KR > const &Kgrp, T alpha, T beta) noexcept
 Build the loop engine for a fused contraction.
 
void uni20::kernel::cpu::GemmLoop< T, MR, NR, KR >::run (T const *A0, T const *B0, T *C0) noexcept
 Perform C = β·C + α·(A ⋅ B) over all fused M, N, and K dimensions.
 

Detailed Description

Always-available CPU reference tensor kernels.

Function Documentation

◆ contract_strided()

template<typename T , std::size_t MR, std::size_t NR, std::size_t KR>
void uni20::kernel::contract_strided ( static_vector< extent_strides< 2 >, MR > const &  Mgrp,
static_vector< extent_strides< 2 >, NR > const &  Ngrp,
static_vector< extent_strides< 2 >, KR > const &  Kgrp,
T  alpha,
T const *  A,
T const *  B,
T  beta,
T *  C 
)

Execute the CPU tensor contraction using precomputed stride groupings.

Template Parameters
TScalar type stored in the tensors.
MRNumber of fused M dimensions.
NRNumber of fused N dimensions.
KRNumber of fused K dimensions.
Parameters
MgrpMetadata describing extents and strides for the fused M dimensions.
NgrpMetadata describing extents and strides for the fused N dimensions.
KgrpMetadata describing extents and strides for the fused K dimensions.
alphaScaling factor applied to the contraction output.
APointer to the base of the left-hand operand.
BPointer to the base of the right-hand operand.
betaScaling factor applied to the pre-existing contents of the destination tensor.
CPointer to the base of the destination tensor.

◆ GemmLoop()

template<typename T , std::size_t MR, std::size_t NR, std::size_t KR>
uni20::kernel::cpu::GemmLoop< T, MR, NR, KR >::GemmLoop ( static_vector< extent_strides< 2 >, MR > const &  Mgrp,
static_vector< extent_strides< 2 >, NR > const &  Ngrp,
static_vector< extent_strides< 2 >, KR > const &  Kgrp,
T  alpha,
T  beta 
)
inlinenoexcept

Build the loop engine for a fused contraction.

Parameters
MgrpMetadata describing extents and strides for the fused M dimensions.
NgrpMetadata describing extents and strides for the fused N dimensions.
KgrpMetadata describing extents and strides for the fused K dimensions.
alphaScaling factor applied to the contraction output.
betaScaling factor applied to the pre-existing contents of the destination tensor.

◆ run()

template<typename T , std::size_t MR, std::size_t NR, std::size_t KR>
void uni20::kernel::cpu::GemmLoop< T, MR, NR, KR >::run ( T const *  A0,
T const *  B0,
T *  C0 
)
inlinenoexcept

Perform C = β·C + α·(A ⋅ B) over all fused M, N, and K dimensions.

Parameters
A0Pointer to the base of the left-hand operand.
B0Pointer to the base of the right-hand operand.
C0Pointer to the base of the destination tensor.