41 template <
typename AccumulatorsPerThread_,
typename ThreadsPerWarp_>
65 static_assert(AccumulatorsPerThread::kH % 2 == 0,
"Invalid size");
66 static_assert(AccumulatorsPerThread::kW % 2 == 0,
"Invalid size");
76 #if defined(__CUDACC__) && __CUDA_ARCH__ >= 530 78 __half2
const* a_half2 =
reinterpret_cast<__half2 const*
>(&a[0]);
79 __half2
const* b_half2 =
reinterpret_cast<__half2 const*
>(&b[0]);
80 __half2
const* c_half2 =
reinterpret_cast<__half2 const*
>(&c[0]);
83 __half2* d_half2 =
reinterpret_cast<__half2*
>(&d[0]);
85 for (
int j = 0; j < AccumulatorsPerThread::kH / 2; ++j) {
86 for (
int i = 0; i < AccumulatorsPerThread::kW / 2; ++i) {
88 int const k0 = (2 * j + 0) * (AccumulatorsPerThread::kW / 2) + i;
89 int const k1 = (2 * j + 1) * (AccumulatorsPerThread::kW / 2) + i;
92 d_half2[k0] = __hfma2(a_half2[i], __low2half2(b_half2[j]), c_half2[k0]);
94 d_half2[k1] = __hfma2(a_half2[i], __high2half2(b_half2[j]), c_half2[k1]);
half ScalarA
The type for A.
Definition: hgemm_multiply_add.h:52
Fragment< half, AccumulatorsPerThread::kH *AccumulatorsPerThread::kW > Accumulators
The accumulators.
Definition: hgemm_multiply_add.h:62
ShapeMul< AccumulatorsPerThread, ThreadsPerWarp >::Shape AccumulatorsPerWarp
The number of accumulators per warp.
Definition: hgemm_multiply_add.h:50
half ScalarC
The type for C and D.
Definition: hgemm_multiply_add.h:60
CUTLASS_DEVICE ThreadMultiplyAdd()
Make sure there's an even number of elements in both dimensions.
Definition: hgemm_multiply_add.h:69
Shape< A_::kD *B_::kD, A_::kH *B_::kH, A_::kW *B_::kW, A_::kC *B_::kC > Shape
Definition: shape.h:119
A template defining Fragment Concept.
Definition: fragment.h:99
Template implementing matrix multiply-add operations on fragments.
Shape< 1, 1, 2, 1 > InstructionShape
The shape of the instruction.
Definition: hgemm_multiply_add.h:44
half ScalarB
The type for B.
Definition: hgemm_multiply_add.h:56
ThreadsPerWarp_ ThreadsPerWarp
The number of threads per warp.
Definition: hgemm_multiply_add.h:48
AccumulatorsPerThread_ AccumulatorsPerThread
The number of accumulators per thread.
Definition: hgemm_multiply_add.h:46
CUTLASS_DEVICE void multiply_add(FragmentA const &a, FragmentB const &b, Accumulators const &c, Accumulators &d)
Multiply : d = a*b + c.
Definition: hgemm_multiply_add.h:72
A Shape implementing Layout Concept describing the dimensions of a cube.
Definition: shape.h:64
Template performing matrix multiply-add operation within a thread.
Definition: thread_multiply_add.h:43
Defines Fragment, a statically-sized array for storing parts of matrices within a thread's registers...
Fragment< ScalarA, AccumulatorsPerThread::kW > FragmentA
The fragment for A.
Definition: hgemm_multiply_add.h:54
Fragment< ScalarB, AccumulatorsPerThread::kH > FragmentB
The fragment for B.
Definition: hgemm_multiply_add.h:58