gemm#
Computes a matrix-matrix product with general matrices.
Description
The gemm routines compute a scalar-matrix-matrix product and add the
result to a scalar-matrix product, with general matrices. The
operation is defined as:
where:
op(X) is one of op(X) = X, or op(X) = XT, or
op(X) = XH,
alpha and beta are scalars,
A, B and C are matrices,
op(A) is an m-by-k matrix,
op(B) is a k-by-n matrix,
C is an m-by-n matrix.
gemm supports the following precisions.
 Ta(A matrix) Tb(B matrix) Tc(C matrix) Ts(alpha/beta)
std::int8_t
std::int8_t
std::int32_t
float
std::int8_t
std::int8_t
float
float
half
half
float
float
half
half
half
half
bfloat16
bfloat16
float
float
bfloat16
bfloat16
bfloat16
float
float
float
float
float
double
double
double
double
std::complex<float>
std::complex<float>
std::complex<float>
std::complex<float>
std::complex<double>
std::complex<double>
std::complex<double>
std::complex<double>
gemm (Buffer Version)#
Syntax
namespace oneapi::mkl::blas::column_major {
    void gemm(sycl::queue &queue,
              oneapi::mkl::transpose transa,
              oneapi::mkl::transpose transb,
              std::int64_t m,
              std::int64_t n,
              std::int64_t k,
              Ts alpha,
              sycl::buffer<Ta,1> &a,
              std::int64_t lda,
              sycl::buffer<Tb,1> &b,
              std::int64_t ldb,
              Ts beta,
              sycl::buffer<Tc,1> &c,
              std::int64_t ldc)
}
namespace oneapi::mkl::blas::row_major {
    void gemm(sycl::queue &queue,
              oneapi::mkl::transpose transa,
              oneapi::mkl::transpose transb,
              std::int64_t m,
              std::int64_t n,
              std::int64_t k,
              Ts alpha,
              sycl::buffer<Ta,1> &a,
              std::int64_t lda,
              sycl::buffer<Tb,1> &b,
              std::int64_t ldb,
              Ts beta,
              sycl::buffer<Tc,1> &c,
              std::int64_t ldc)
}
Input Parameters
- queue
 The queue where the routine should be executed.
- transa
 Specifies the form of op(
A), the transposition operation applied toA.- transb
 Specifies the form of op(
B), the transposition operation applied toB.- m
 Specifies the number of rows of the matrix op(
A) and of the matrixC. The value of m must be at least zero.- n
 Specifies the number of columns of the matrix op(
B) and the number of columns of the matrixC. The value of n must be at least zero.- k
 Specifies the number of columns of the matrix op(
A) and the number of rows of the matrix op(B). The value of k must be at least zero.- alpha
 Scaling factor for the matrix-matrix product.
- a
 The buffer holding the input matrix
A.Anot transposedAtransposedColumn major
Ais anm-by-kmatrix so the arrayamust have size at leastlda*k.Ais ank-by-mmatrix so the arrayamust have size at leastlda*mRow major
Ais anm-by-kmatrix so the arrayamust have size at leastlda*m.Ais ank-by-mmatrix so the arrayamust have size at leastlda*kSee Matrix Storage for more details.
- lda
 The leading dimension of
A. It must be positive.Anot transposedAtransposedColumn major
ldamust be at leastm.ldamust be at leastk.Row major
ldamust be at leastk.ldamust be at leastm.- b
 The buffer holding the input matrix
B.Bnot transposedBtransposedColumn major
Bis ank-by-nmatrix so the arraybmust have size at leastldb*n.Bis ann-by-kmatrix so the arraybmust have size at leastldb*kRow major
Bis ank-by-nmatrix so the arraybmust have size at leastldb*k.Bis ann-by-kmatrix so the arraybmust have size at leastldb*nSee Matrix Storage for more details.
- ldb
 The leading dimension of
B. It must be positive.Bnot transposedBtransposedColumn major
ldbmust be at leastk.ldbmust be at leastn.Row major
ldbmust be at leastn.ldbmust be at leastk.- beta
 Scaling factor for matrix
C.- c
 The buffer holding the input/output matrix
C. It must have a size of at leastldc*nif column major layout is used to store matrices or at leastldc*mif row major layout is used to store matrices . See Matrix Storage for more details.- ldc
 The leading dimension of
C. It must be positive and at leastmif column major layout is used to store matrices or at leastnif row major layout is used to store matrices.
Output Parameters
- c
 The buffer, which is overwritten by
alpha*op(A)*op(B) +beta*C.
Notes
If beta = 0, matrix C does not need to be initialized before
calling gemm.
Throws
This routine shall throw the following exceptions if the associated condition is detected. An implementation may throw additional implementation-specific exception(s) in case of error conditions not covered here.
gemm (USM Version)#
Syntax
namespace oneapi::mkl::blas::column_major {
    sycl::event gemm(sycl::queue &queue,
                     oneapi::mkl::transpose transa,
                     oneapi::mkl::transpose transb,
                     std::int64_t m,
                     std::int64_t n,
                     std::int64_t k,
                     value_or_pointer<Ts> alpha,
                     const Ta *a,
                     std::int64_t lda,
                     const Tb *b,
                     std::int64_t ldb,
                     value_or_poitner<Ts> beta,
                     Tc *c,
                     std::int64_t ldc,
                     const std::vector<sycl::event> &dependencies = {})
}
namespace oneapi::mkl::blas::row_major {
    sycl::event gemm(sycl::queue &queue,
                     oneapi::mkl::transpose transa,
                     oneapi::mkl::transpose transb,
                     std::int64_t m,
                     std::int64_t n,
                     std::int64_t k,
                     value_or_pointer<Ts> alpha,
                     const Ta *a,
                     std::int64_t lda,
                     const Tb *b,
                     std::int64_t ldb,
                     value_or_pointer<Ts> beta,
                     Tc *c,
                     std::int64_t ldc,
                     const std::vector<sycl::event> &dependencies = {})
}
Input Parameters
- queue
 The queue where the routine should be executed.
- transa
 Specifies the form of op(
A), the transposition operation applied toA.- transb
 Specifies the form of op(
B), the transposition operation applied toB.- m
 Specifies the number of rows of the matrix op(
A) and of the matrixC. The value of m must be at least zero.- n
 Specifies the number of columns of the matrix op(
B) and the number of columns of the matrixC. The value of n must be at least zero.- k
 Specifies the number of columns of the matrix op(
A) and the number of rows of the matrix op(B). The value of k must be at least zero.- alpha
 Scaling factor for the matrix-matrix product. See Scalar Arguments in BLAS for more details.
- a
 Pointer to input matrix
A.Anot transposedAtransposedColumn major
Ais anm-by-kmatrix so the arrayamust have size at leastlda*k.Ais ank-by-mmatrix so the arrayamust have size at leastlda*mRow major
Ais anm-by-kmatrix so the arrayamust have size at leastlda*m.Ais ank-by-mmatrix so the arrayamust have size at leastlda*kSee Matrix Storage for more details.
- lda
 The leading dimension of
A. It must be positive.Anot transposedAtransposedColumn major
ldamust be at leastm.ldamust be at leastk.Row major
ldamust be at leastk.ldamust be at leastm.- b
 Pointer to input matrix
B.Bnot transposedBtransposedColumn major
Bis ank-by-nmatrix so the arraybmust have size at leastldb*n.Bis ann-by-kmatrix so the arraybmust have size at leastldb*kRow major
Bis ank-by-nmatrix so the arraybmust have size at leastldb*k.Bis ann-by-kmatrix so the arraybmust have size at leastldb*nSee Matrix Storage for more details.
- ldb
 The leading dimension of
B. It must be positive.Bnot transposedBtransposedColumn major
ldbmust be at leastk.ldbmust be at leastn.Row major
ldbmust be at leastn.ldbmust be at leastk.- beta
 Scaling factor for matrix
C. See Scalar Arguments in BLAS for more details.- c
 The pointer to input/output matrix
C. It must have a size of at leastldc*nif column major layout is used to store matrices or at leastldc*mif row major layout is used to store matrices . See Matrix Storage for more details.- ldc
 The leading dimension of
C. It must be positive and at leastmif column major layout is used to store matrices or at leastnif row major layout is used to store matrices.- dependencies
 List of events to wait for before starting computation, if any. If omitted, defaults to no dependencies.
Output Parameters
- c
 Pointer to the output matrix, overwritten by
alpha*op(A)*op(B) +beta*C.
Notes
If beta = 0, matrix C does not need to be initialized
before calling gemm.
Return Values
Output event to wait on to ensure computation is complete.
Throws
This routine shall throw the following exceptions if the associated condition is detected. An implementation may throw additional implementation-specific exception(s) in case of error conditions not covered here.
oneapi::mkl::unsupported_device
Parent topic: BLAS Level 3 Routines