gemm_?8?8s32
Compute the product of a general matrix and a matrix.
That is,
.
The value of op(X) may be
. alpha and beta are multiplication coefficients; op(A) is an m*k matrix; op(B) is a k*n matrix, and C is an m*n matrix.
A_offset is a scalar of fixed type int8_t. A_offset is added to all elements in op(A).
B_offset is a scalar of fixed type int8_t. B_offset is added to all elements in op(B).
C_offset has three definitions (the element type is int32_t):
- A scalar. C_offset is added to each element in matrix C.
- A row vector. C_offset is added to each row in matrix C.
- A column vector. C_offset is added to each column in matrix C.
Interface Definition
C interface:
void cblas_gemm_s8s8s32(
const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE transa, const CBLAS_TRANSPOSE transb, const CBLAS_OFFSET offsetc,
const BLASINT m, const BLASINT n, const BLASINT k, const float alpha,
const BLASINT8 *a, const BLASINT lda, const BLASINT8 oa,
const BLASINT8 *b, const BLASINT ldb, const BLASINT8 ob,
const float beta, int32_t *c, const BLASINT ldc, const int32_t *oc);
void cblas_gemm_u8u8s32(
const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE transa, const CBLAS_TRANSPOSE transb, const CBLAS_OFFSET offsetc,
const BLASINT m, const BLASINT n, const BLASINT k, const float alpha,
const BLASUINT8 *a, const BLASINT lda, const BLASINT8 oa,
const BLASUINT8 *b, const BLASINT ldb, const BLASINT8 ob,
const float beta, int32_t *c, const BLASINT ldc, const int32_t *oc);
void cblas_gemm_s8u8s32(
const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE transa, const CBLAS_TRANSPOSE transb, const CBLAS_OFFSET offsetc,
const BLASINT m, const BLASINT n, const BLASINT k, const float alpha,
const BLASINT8 *a, const BLASINT lda, const BLASINT8 oa,
const BLASUINT8 *b, const BLASINT ldb, const BLASINT8 ob,
const float beta, int32_t *c, const BLASINT ldc, const int32_t *oc);
void cblas_gemm_u8s8s32(
const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE transa, const CBLAS_TRANSPOSE transb, const CBLAS_OFFSET offsetc,
const BLASINT m, const BLASINT n, const BLASINT k, const float alpha,
const BLASUINT8 *a, const BLASINT lda, const BLASINT8 oa,
const BLASINT8 *b, const BLASINT ldb, const BLASINT8 ob,
const float beta, int32_t *c, const BLASINT ldc, const int32_t *oc);
Fortran interface:
int8 gemm has no Fortran interface.
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
layout |
Enumeration type CBLAS_LAYOUT |
Whether the matrix is in row- or column-major order.
|
Input |
transa |
Enumeration type CBLAS_TRANSPOSE |
Whether matrix A is non-transposed or transposed.
|
Input |
transb |
Enumeration type CBLAS_TRANSPOSE |
Whether matrix B is non-transposed or transposed.
|
Input |
offsetc |
Enumeration type CBLAS_OFFSET |
Whether the oc parameter (C_offset defined in GEMM) is a row vector, column vector, or scalar.
|
Input |
M |
Integer |
Number of rows in matrices op(A) and C. |
Input |
N |
Integer |
Number of columns in matrices op(B) and C. |
Input |
K |
Integer |
Number of columns in matrix op(A) and number of rows in matrix op(B). |
Input |
alpha |
Single-precision floating-point type |
Multiplication coefficient. |
Input |
A |
|
Matrix A. |
Input |
lda |
Integer |
|
Input |
oa |
int8_t |
Value of A_offset defined in GEMM. |
Input |
B |
|
Matrix B. |
Input |
ldb |
Integer |
|
Input |
ob |
int8_t |
Value of B_offset defined in GEMM. |
Input |
beta |
Single-precision floating-point type |
Multiplication coefficient. |
Input |
C |
int32_t |
Matrix C. |
Input/Output |
ldc |
Integer |
For a column-store matrix, ldc must be at least max(1, m); otherwise, ldc must be at least max(1, n). |
Input |
oc |
int32_t |
Value of C_offset defined in GEMM.
|
Input |
Dependencies
#include "kblas.h"
Examples
int m = 4, k = 3, n = 4, lda = 4, ldb = 3, ldc = 4;
float alpha = 1.0, beta = 2.0;
int8_t oa=3, ob=5;
CBLAS_OFFSET offsetc = CblasRowOffset;
int32_t oc[] = {1, 2, 3, 4};
/*
* A:
* 35, 39, 27,
* 38, 55, 40,
* 46, 35, 41,
* 54, 55, 24,
* B:
* 35, 54, 35, 40,
* 38, 39, 55, 41,
* 46, 55, 27, 24,
* C:
* 7, 7, 7, 7,
* 7, 7, 7, 7,
* 7, 7, 7, 7,
* 7, 7, 7, 7,
*/
int8_t a[12] = {35, 38, 46, 54,
39, 55, 35, 55,
27, 40, 41, 24};
int8_t b[12] = {35, 38, 46,
54, 39, 55,
35, 55, 27,
40, 41, 24};
int32_t c[16] = {7, 7, 7, 7,
7, 7, 7, 7,
7, 7, 7, 7,
7, 7, 7, 7};
cblas_gemm_s8s8s32(CblasColMajor, CblasNoTrans, CblasNoTrans, offsetc,
m, n, k, alpha,
a, lda, oa,
b, ldb, ob,
beta, c, ldc, oc);
/*
* Output C:
* 4871 5906 5017 4530
* 6342 7567 6513 5778
* 5853 7219 5665 5247
* 6166 7551 6641 6034
*
*/



