gemm_bias¶
Computes a matrix-matrix product with general matrices.
Syntax
Buffer API
-
void
gemm_bias
(queue &exec_queue, transpose transa, transpose transb, offset offset_type, std::int64_t m, std::int64_t n, std::int64_t k, Ts alpha, buffer<Ta, 1> &a, std::int64_t lda, Ta ao, buffer<Tb, 1> &b, std::int64_t ldb, Tb bo, Ts beta, buffer<Tc, 1> &c, std::int64_t ldc, buffer<Tc, 1> &co)¶
USM API
-
event
gemm_bias
(queue &exec_queue, transpose transa, transpose transb, offset offset_type, std::int64_t m, std::int64_t n, std::int64_t k, Ts alpha, Ta *a, std::int64_t lda, Ta ao, Tb *b, std::int64_t ldb, Tb bo, Ts beta, Tc *c, std::int64_t ldc, Tc *co, const vector_class<event> &dependencies = {})¶
gemm_bias
supports the following precisions and devices.
Ts |
Ta |
Tb |
Tc |
Devices Supported |
---|---|---|---|---|
|
|
|
|
Host, CPU, and GPU |
|
|
|
|
Host, CPU, and GPU |
|
|
|
|
Host, CPU, and GPU |
Description
The gemm_bias routines compute a scalar-matrix-matrix product and add the result to a scalar-matrix product, with general matrices. The operation is defined as:
C ← alpha*(op(A) - A_offset)*(op(B) - B_offset) + beta*C + C_offset
for the offset API where:
op(X) is one of op(X) = X, or op(X) = XT, or op(X) = XH
alpha
andbeta
are scalarsA_offset
is anm
-by-k
matrix with every element equal to the value aoB_offset
is ak
-by-n
matrix with every element equal to the value boC_offset
is anm
-by-n
matrix defined by the co buffer as described in Data TypesA
,B
, andC
are matrices
Here, op(A
) is m
x k
, op(B
) is k
x n
, and
C
is m
x n
.
Input Parameters
- exec_queue
The queue where the routine should be executed.
- transa
Specifies op(
A
), the transposition operation applied toA
. See Data Types for more details.- transb
Specifies op(
B
), the transposition operation applied toB
. See Data Types for more details.- offset_type
Specifies the form of
C_offset
used in the matrix multiplication. See Data Types for more details.- m
Number of rows of op(
A
) andC
. Must be at least zero.- n
Number of columns of op(
B
) andC
. Must be at least zero.- k
Number of columns of op(
A
) and rows of op(B
). Must be at least zero.- alpha
Scaling factor for the matrix-matrix product.
- a
Buffer holding the input matrix
A
.If
A
is not transposed,A
is anm
-by-k
matrix so the arraya
must have size at leastlda
*k
(respectively,lda
*m
) if column (respectively, row) major layout is used to store matrices. IfA
is transposed,A
is ank
-by-m
matrix so the arraya
must have size at leastlda
*m
(respectivelylda
*k
) if column (respectively, row) major is used to store matrices. See Matrix Storage for more details.- lda
Leading dimension of
A
. If matrices are stored using column major layout, lda must be at least m ifA
is not transposed, and at leastk
ifA
is transposed. If matrices are stored using row major layout,lda
must be at leastk
ifA
is not transposed, and at leastm
ifA
is transposed. It must be positive.- ao
Specifies the scalar offset value for matrix
A
.- b
Buffer holding the input matrix
B
.If
B
is not transposed,B
is ak
-by-n
matrix so the arrayb
must have size at leastldb
*n
(respectively,ldb
*k
) if column (respectively, row) major layout is used to store matrices. IfB
is transposed,B
is ann
-by-k
matrix so the arrayb
must have size at leastldb
*k
(respectively,ldb
*n
) if column (respectively, row) major is used to store matrices. See Matrix Storage for more details.- ldb
Leading dimension of
B
. If matrices are stored using column major layout,ldb
must be at leastk
ifB
is not transposed, andm
ifB
is transposed. If matrices are stored using row major layout,ldb
must be at leastn
ifB
is not transposed, and at leastk
ifB
is transposed. It must be positive.- bo
Specifies the scalar offset value for matrix
B
.- beta
Scaling factor for matrix
C
.- c
Buffer holding the input matrix
C
. Must have size at leastldc
*n
. See Matrix Storage for more details.- ldc
Leading dimension of
C
. Must be positive and at leastm
.- co
Buffer holding the offset values for matrix
C
.If
offset_type = offset::fix
, theco
array must have size at least 1.If
offset_type = offset::col
, theco
array must have size at leastmax(1,m)
.If
offset_type = offset::row
, theco
array must have size at leastmax(1,n)
.See Data Types for more details.
- dependencies
List of events to wait for before starting computation, if any. If omitted, defaults to no dependencies.
Output Parameters
Buffer API
- c
Output buffer, overwritten by alpha*op(
A
)*op(B
) + beta*C
for the standard API and alpha*(op(A
) -A_offset
)*(op(B
) -B_offset
) + beta*C
+C_offset
.
USM API
- c
Output array, overwritten by alpha*op(
A
)*op(B
) + beta*C
for the standard API and alpha*(op(A
) -A_offset
)*(op(B
) -B_offset
) + beta*C
+C_offset
.
Notes
If beta
= 0, matrix C
does not need to be initialized before
calling gemm_bias.