matmul_block
-
void ckernel::matmul_block_init(uint32_t in0_cb_id, uint32_t in1_cb_id, const uint32_t transpose = 0, uint32_t ct_dim = 1, uint32_t rt_dim = 1, uint32_t kt_dim = 1, uint32_t call_line = __builtin_LINE())
-
Short init for matmul_block. Configures the unpacker and math engine to matmul mode.
Must be called before matmul_block. The one-time HW configuration must already have been performed via compute_kernel_hw_startup<SrcOrder::Reverse>(in0, in1, out) at the start of MAIN. Matmul maps in0 -> SrcB and in1 -> SrcA (the reverse of other ops), which is why compute_kernel_hw_startup must use SrcOrder::Reverse.
NOTE (known gap, #46769): if a preceding op left SrcA/SrcB with asymmetric tile sizes (i.e. different data formats per source) and the following matmul uses the same formats, matmul_block_init cannot fix the per-source tile sizes on its own. It does not re-program the tile descriptor, and a reconfig_data_format is inappropriate when the data formats did not change. No current kernel hits this; tracked in #46769.
Return value: None
Argument
Description
Type
Valid Range
Required
in0_cb_id
The identifier of the first input circular buffer (CB)
uint32_t
0 to 31
True
in1_cb_id
The identifier of the second input circular buffer (CB)
uint32_t
0 to 31
True
transpose
The transpose flag for performing transpose operation on B
uint32_t
Any positive value will indicate transpose is set
False
ct_dim
The column dimension for the output block.
uint32_t
Must be equal to block B column dimension; 1 to 8 in half-sync mode, 1 to 16 in full-sync mode
False
rt_dim
The row dimension for the output block.
uint32_t
Must be equal to block A row dimension; 1 to 8 in half-sync mode, 1 to 16 in full-sync mode
False
kt_dim
The inner dimension.
uint32_t
Must be equal to block A column dimension
False
-
void ckernel::matmul_block(uint32_t in0_cb_id, uint32_t in1_cb_id, uint32_t in0_tile_index, uint32_t in1_tile_index, uint32_t idst, const uint32_t transpose, uint32_t ct_dim, uint32_t rt_dim, uint32_t kt_dim, uint32_t call_line = __builtin_LINE())
-
Performs block-sized matrix multiplication C=A*B between the blocks in two different input CBs and accumulates the result to DST (DST += C). The DST register buffer must be in acquired state via acquire_dst call. This call is blocking and is only available on the compute engine.
A block is a rectangle of tiles: A is rt_dim x kt_dim tiles, B is kt_dim x ct_dim tiles, and the output C is rt_dim x ct_dim tiles. So a block is just ct_dim * rt_dim output tiles produced in one call (with kt_dim tiles along the shared inner dimension). The output must fit in DST, so the block size is limited by DST size and sync mode (see matmul_block_init for the valid ct_dim/rt_dim ranges).
Return value: None
Argument
Description
Type
Valid Range
Required
in0_cb_id
The identifier of the first input circular buffer (CB)
uint32_t
0 to 31
True
in1_cb_id
The identifier of the second input circular buffer (CB)
uint32_t
0 to 31
True
in0_tile_index
The index of the tile in block A from the first input CB
uint32_t
Must be less than the size of the CB
True
in1_tile_index
The index of the tile in block B from the second input CB
uint32_t
Must be less than the size of the CB
True
idst
The index of the tile in DST REG to which the result C will be written.
uint32_t
Must be less than the acquired size of DST REG
True
transpose
The transpose flag for performing transpose operation on tiles in B.
bool
Must be true or false
True
ct_dim
The column dimension for the output block.
uint32_t
Must be equal to block B column dimension
True
rt_dim
The row dimension for the output block.
uint32_t
Must be equal to block A row dimension
True
kt_dim
The inner dimension.
uint32_t
Must be equal to block A column dimension
True
See also compute_kernel_hw_startup, which must be called once with SrcOrder::Reverse before matmul_block_init.