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) = XT, or
op(X) = XH,
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_offsetused 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.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.- ao
 Specifies the scalar offset value for matrix
A.- b
 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.- 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*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.- co
 Buffer holding the offset values for matrix
C.If
offset_type=offset::fix, thecoarray must have size at least 1.If
offset_type=offset::col, thecoarray must have size at leastmax(1,m).If
offset_type=offset::row, thecoarray 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_offsetused 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.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.- ao
 Specifies the scalar offset value for matrix
A.- 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.- 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*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.- co
 Pointer to offset values for matrix
C.If
offset_type=offset::fix, thecoarray must have size at least 1.If
offset_type=offset::col, thecoarray must have size at leastmax(1,m).If
offset_type=offset::row, thecoarray 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