gemm_bias#
Computes a matrix-matrix product using general integer matrices with bias.
Description
The gemm_bias routines compute a scalar-matrix-matrix product and add the result to a scalar-matrix product, using general integer matrices with biases/offsets. 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_offset
is an m
-by-k
matrix with every element equal to the value ao,
B_offset
is a k
-by-n
matrix with every element equal to the value bo,
C_offset
is an m
-by-n
matrix defined by the
co buffer as described below,
A
, B
, and C
are matrices,
op(A
) is m
x k
, op(B
) is k
x n
, and
C
is m
x n
.
gemm_bias
supports the following precisions.
Ta
Tb
std::uint8_t
std::uint8_t
std::int8_t
std::uint8_t
std::uint8_t
std::int8_t
std::int8_t
std::int8_t
gemm_bias (Buffer Version)#
Syntax
namespace oneapi::math::blas::column_major {
void gemm_bias(sycl::queue &queue,
oneapi::math::transpose transa,
oneapi::math::transpose transb,
oneapi::math::offset offset_type,
std::int64_t m,
std::int64_t n,
std::int64_t k,
float alpha,
sycl::buffer<Ta,1> &a,
std::int64_t lda,
Ta ao,
sycl::buffer<Tb,1> &b,
std::int64_t ldb,
Tb bo,
float beta,
sycl::buffer<std::int32_t,1> &c,
std::int64_t ldc,
sycl::buffer<std::int32_t,1> &co)
}
namespace oneapi::math::blas::row_major {
void gemm_bias(sycl::queue &queue,
oneapi::math::transpose transa,
oneapi::math::transpose transb,
oneapi::math::offset offset_type,
std::int64_t m,
std::int64_t n,
std::int64_t k,
float alpha,
sycl::buffer<Ta,1> &a,
std::int64_t lda,
Ta ao,
sycl::buffer<Tb,1> &b,
std::int64_t ldb,
Tb bo,
float beta,
sycl::buffer<std::int32_t,1> &c,
std::int64_t ldc,
sycl::buffer<std::int32_t,1> &co)
}
Input Parameters
- queue
The queue where the routine should be executed.
- transa
Specifies op(
A
), the transposition operation applied toA
. See oneMath defined datatypes for more details.- transb
Specifies op(
B
), the transposition operation applied toB
. See oneMath defined datatypes for more details.- offset_type
Specifies the form of
C_offset
used in the matrix multiplication. See oneMath defined datatypes 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
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
.- ao
Specifies the scalar offset value for matrix
A
.- b
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
.- bo
Specifies the scalar offset value for matrix
B
.- beta
Scaling factor for matrix
C
.- c
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.- 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)
.
Output Parameters
- c
Output buffer, overwritten by
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
.
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::math::invalid_argument
oneapi::math::unsupported_device
gemm_bias (USM Version)#
Syntax
namespace oneapi::math::blas::column_major {
sycl::event gemm_bias(sycl::queue &queue,
oneapi::math::transpose transa,
oneapi::math::transpose transb,
oneapi::math::offset offset_type,
std::int64_t m,
std::int64_t n,
std::int64_t k,
value_or_pointer<float> alpha,
const Ta *a,
std::int64_t lda,
Ta ao,
const Tb *b,
std::int64_t ldb,
Tb bo,
value_or_pointer<float> beta,
std::int32_t *c,
std::int64_t ldc,
const std::int32_t *co,
const std::vector<sycl::event> &dependencies = {})
}
namespace oneapi::math::blas::row_major {
sycl::event gemm_bias(sycl::queue &queue,
oneapi::math::transpose transa,
oneapi::math::transpose transb,
oneapi::math::offset offset_type,
std::int64_t m,
std::int64_t n,
std::int64_t k,
value_or_pointer<float> alpha,
const Ta *a,
std::int64_t lda,
Ta ao,
const Tb *b,
std::int64_t ldb,
Tb bo,
value_or_pointer<float> beta,
std::int32_t *c,
std::int64_t ldc,
const std::int32_t *co,
const std::vector<sycl::event> &dependencies = {})
}
Input Parameters
- queue
The queue where the routine should be executed.
- transa
Specifies op(
A
), the transposition operation applied toA
. See oneMath defined datatypes for more details.- transb
Specifies op(
B
), the transposition operation applied toB
. See oneMath defined datatypes for more details.- offset_type
Specifies the form of
C_offset
used in the matrix multiplication. See oneMath defined datatypes 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. See Scalar Arguments in BLAS for more details.
- 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
.- ao
Specifies the scalar offset value for matrix
A
.- 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
.- bo
Specifies the scalar offset value for matrix
B
.- beta
Scaling factor for matrix
C
. See Scalar Arguments in BLAS for more details.- c
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.- co
Pointer to 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)
.- 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
) -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
.
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::math::invalid_argument
oneapi::math::unsupported_device
oneapi::math::device_bad_alloc
Parent topic: BLAS-like Extensions