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
) = X
T, or
op(X
) = X
H,
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.
Ts
Ta
Tb
Tc
float
half
half
float
half
half
half
half
float
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,
onemkl::transpose transa,
onemkl::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,
onemkl::transpose transa,
onemkl::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
.A
not transposedA
transposedColumn major
A
is anm
-by-k
matrix so the arraya
must have size at leastlda
*k
.A
is ank
-by-m
matrix so the arraya
must have size at leastlda
*m
Row major
A
is anm
-by-k
matrix so the arraya
must have size at leastlda
*m
.A
is ank
-by-m
matrix so the arraya
must have size at leastlda
*k
See Matrix Storage for more details.
- lda
The leading dimension of
A
. It must be positive.A
not transposedA
transposedColumn major
lda
must be at leastm
.lda
must be at leastk
.Row major
lda
must be at leastk
.lda
must be at leastm
.- b
The buffer holding the input matrix
B
.B
not transposedB
transposedColumn major
B
is ank
-by-n
matrix so the arrayb
must have size at leastldb
*n
.B
is ann
-by-k
matrix so the arrayb
must have size at leastldb
*k
Row major
B
is ank
-by-n
matrix so the arrayb
must have size at leastldb
*k
.B
is ann
-by-k
matrix so the arrayb
must have size at leastldb
*n
See Matrix Storage for more details.
- ldb
The leading dimension of
B
. It must be positive.B
not transposedB
transposedColumn major
ldb
must be at leastk
.ldb
must be at leastn
.Row major
ldb
must be at leastn
.ldb
must 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
*n
if column major layout is used to store matrices or at leastldc
*m
if 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 leastm
if column major layout is used to store matrices or at leastn
if 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
.
gemm (USM Version)#
Syntax
namespace oneapi::mkl::blas::column_major {
sycl::event gemm(sycl::queue &queue,
onemkl::transpose transa,
onemkl::transpose transb,
std::int64_t m,
std::int64_t n,
std::int64_t k,
Ts alpha,
const Ta *a,
std::int64_t lda,
const Tb *b,
std::int64_t ldb,
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,
onemkl::transpose transa,
onemkl::transpose transb,
std::int64_t m,
std::int64_t n,
std::int64_t k,
Ts alpha,
const Ta *a,
std::int64_t lda,
const Tb *b,
std::int64_t ldb,
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.
- a
Pointer to input matrix
A
.A
not transposedA
transposedColumn major
A
is anm
-by-k
matrix so the arraya
must have size at leastlda
*k
.A
is ank
-by-m
matrix so the arraya
must have size at leastlda
*m
Row major
A
is anm
-by-k
matrix so the arraya
must have size at leastlda
*m
.A
is ank
-by-m
matrix so the arraya
must have size at leastlda
*k
See Matrix Storage for more details.
- lda
The leading dimension of
A
. It must be positive.A
not transposedA
transposedColumn major
lda
must be at leastm
.lda
must be at leastk
.Row major
lda
must be at leastk
.lda
must be at leastm
.- b
Pointer to input matrix
B
.B
not transposedB
transposedColumn major
B
is ank
-by-n
matrix so the arrayb
must have size at leastldb
*n
.B
is ann
-by-k
matrix so the arrayb
must have size at leastldb
*k
Row major
B
is ank
-by-n
matrix so the arrayb
must have size at leastldb
*k
.B
is ann
-by-k
matrix so the arrayb
must have size at leastldb
*n
See Matrix Storage for more details.
- ldb
The leading dimension of
B
. It must be positive.B
not transposedB
transposedColumn major
ldb
must be at leastk
.ldb
must be at leastn
.Row major
ldb
must be at leastn
.ldb
must be at leastk
.- beta
Scaling factor for matrix
C
.- c
The pointer to input/output matrix
C
. It must have a size of at leastldc
*n
if column major layout is used to store matrices or at leastldc
*m
if 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 leastm
if column major layout is used to store matrices or at leastn
if 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.
Parent topic: BLAS Level 3 Routines