Class Gemm
- Namespace
- NVMathNet.LinAlg
- Assembly
- NVMath.Net.dll
Stateless helpers for classic cuBLAS GEMM operations. Supports single-precision (System.Single), double-precision (System.Double), and half-precision (System.Half) element types.
Computes C = alpha * op(A) * op(B) + beta * C where all matrices are in column-major layout on the GPU device.
For mixed-precision or epilog support, see NVMathNet.LinAlg.Matmul (cuBLASLt).
public static class GemmInheritance
Inherited Members
Methods
Dgemm(DeviceBuffer<double>, DeviceBuffer<double>, DeviceBuffer<double>, int, int, int, double, double, bool, bool, CudaStream?)
Synchronously computes C = alpha * op(A) * op(B) + beta * C using double-precision.
public static void Dgemm(DeviceBuffer<double> a, DeviceBuffer<double> b, DeviceBuffer<double> c, int m, int n, int k, double alpha = 1, double beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null)Parameters
aDeviceBuffer<double>-
Device buffer for matrix A (m × k or k × m when transposed).
bDeviceBuffer<double>-
Device buffer for matrix B (k × n or n × k when transposed).
cDeviceBuffer<double>-
Device buffer for matrix C (m × n); updated in place.
mint-
Rows of op(A) and C.
nint-
Columns of op(B) and C.
kint-
Inner dimension (columns of op(A) / rows of op(B)).
alphadouble-
Scalar multiplier for A*B. Default: 1.
betadouble-
Scalar multiplier for existing values in C. Default: 0.
transposeAbool-
If
true, use AT. transposeBbool-
If
true, use BT. streamCudaStream?-
Optional CUDA stream;
nullcreates a private stream.
DgemmAsync(DeviceBuffer<double>, DeviceBuffer<double>, DeviceBuffer<double>, int, int, int, double, double, bool, bool, CudaStream?, CancellationToken)
Asynchronously computes C = alpha * op(A) * op(B) + beta * C using double-precision.
public static Task DgemmAsync(DeviceBuffer<double> a, DeviceBuffer<double> b, DeviceBuffer<double> c, int m, int n, int k, double alpha = 1, double beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null, CancellationToken ct = default)Parameters
aDeviceBuffer<double>-
Device buffer for matrix A (m × k or k × m when transposed).
bDeviceBuffer<double>-
Device buffer for matrix B (k × n or n × k when transposed).
cDeviceBuffer<double>-
Device buffer for matrix C (m × n); updated in place.
mint-
Rows of op(A) and C.
nint-
Columns of op(B) and C.
kint-
Inner dimension (columns of op(A) / rows of op(B)).
alphadouble-
Scalar multiplier for A*B. Default: 1.
betadouble-
Scalar multiplier for existing values in C. Default: 0.
transposeAbool-
If
true, use AT. transposeBbool-
If
true, use BT. streamCudaStream?-
Optional CUDA stream;
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
HgemmAsync(DeviceBuffer<Half>, DeviceBuffer<Half>, DeviceBuffer<Half>, int, int, int, Half, Half, bool, bool, CudaStream?, CancellationToken)
Asynchronously computes C = alpha * op(A) * op(B) + beta * C using half-precision.
public static Task HgemmAsync(DeviceBuffer<Half> a, DeviceBuffer<Half> b, DeviceBuffer<Half> c, int m, int n, int k, Half alpha, Half beta, bool transposeA = false, bool transposeB = false, CudaStream? stream = null, CancellationToken ct = default)Parameters
aDeviceBuffer<Half>-
Device buffer for matrix A (m × k or k × m when transposed).
bDeviceBuffer<Half>-
Device buffer for matrix B (k × n or n × k when transposed).
cDeviceBuffer<Half>-
Device buffer for matrix C (m × n); updated in place.
mint-
Rows of op(A) and C.
nint-
Columns of op(B) and C.
kint-
Inner dimension (columns of op(A) / rows of op(B)).
alphaHalf-
Scalar multiplier for A*B. Default: 1.
betaHalf-
Scalar multiplier for existing values in C. Default: 0.
transposeAbool-
If
true, use AT. transposeBbool-
If
true, use BT. streamCudaStream?-
Optional CUDA stream;
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Sgemm(DeviceBuffer<float>, DeviceBuffer<float>, DeviceBuffer<float>, int, int, int, float, float, bool, bool, CudaStream?)
Synchronously computes C = alpha * op(A) * op(B) + beta * C using single-precision.
public static void Sgemm(DeviceBuffer<float> a, DeviceBuffer<float> b, DeviceBuffer<float> c, int m, int n, int k, float alpha = 1, float beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null)Parameters
aDeviceBuffer<float>-
Device buffer for matrix A (m × k or k × m when transposed).
bDeviceBuffer<float>-
Device buffer for matrix B (k × n or n × k when transposed).
cDeviceBuffer<float>-
Device buffer for matrix C (m × n); updated in place.
mint-
Rows of op(A) and C.
nint-
Columns of op(B) and C.
kint-
Inner dimension (columns of op(A) / rows of op(B)).
alphafloat-
Scalar multiplier for A*B. Default: 1.
betafloat-
Scalar multiplier for existing values in C. Default: 0.
transposeAbool-
If
true, use AT. transposeBbool-
If
true, use BT. streamCudaStream?-
Optional CUDA stream;
nullcreates a private stream.
SgemmAsync(DeviceBuffer<float>, DeviceBuffer<float>, DeviceBuffer<float>, int, int, int, float, float, bool, bool, CudaStream?, CancellationToken)
Asynchronously computes C = alpha * op(A) * op(B) + beta * C using single-precision.
public static Task SgemmAsync(DeviceBuffer<float> a, DeviceBuffer<float> b, DeviceBuffer<float> c, int m, int n, int k, float alpha = 1, float beta = 0, bool transposeA = false, bool transposeB = false, CudaStream? stream = null, CancellationToken ct = default)Parameters
aDeviceBuffer<float>-
Device buffer for matrix A (m × k or k × m when transposed).
bDeviceBuffer<float>-
Device buffer for matrix B (k × n or n × k when transposed).
cDeviceBuffer<float>-
Device buffer for matrix C (m × n); updated in place.
mint-
Rows of op(A) and C.
nint-
Columns of op(B) and C.
kint-
Inner dimension (columns of op(A) / rows of op(B)).
alphafloat-
Scalar multiplier for A*B. Default: 1.
betafloat-
Scalar multiplier for existing values in C. Default: 0.
transposeAbool-
If
true, use AT. transposeBbool-
If
true, use BT. streamCudaStream?-
Optional CUDA stream;
nullcreates a private stream. ctCancellationToken-
Cancellation token.