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

in0_cb_id The identifier of the first input circular buffer (CB)

in1_cb_id The identifier of the second input circular buffer (CB)

transpose The transpose flag for performing transpose operation on B

ct_dim The column dimension for the output block.

rt_dim The row dimension for the output block.

kt_dim The inner dimension.

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

in0_cb_id The identifier of the first input circular buffer (CB)

in1_cb_id The identifier of the second input circular buffer (CB)

in0_tile_index The index of the tile in block A from the first input CB

in1_tile_index The index of the tile in block B from the second input CB

idst The index of the tile in DST REG to which the result C will be written.

transpose The transpose flag for performing transpose operation on tiles in B.

ct_dim The column dimension for the output block.

rt_dim The row dimension for the output block.

kt_dim The inner dimension.

See also compute_kernel_hw_startup, which must be called once with SrcOrder::Reverse before matmul_block_init.