asc2.zeros_acc
- asc2.zeros_acc(shape: Iterable[int], dtype: DataType, *, bias: LocalTensor | None = None) LocalTensor
Create a zero-initialized accumulator tensor in L0C memory for matrix multiplication.
This tensor is specifically designed for use with
matmul_acc()operations and is always located inTensorLocation.L0C.The supported data type is:
float32.- Parameters:
shape – The shape of the accumulator tensor
dtype – The data type of the accumulator
bias – Optional initialization tensor (1D tensor in
BT). If provided, the accumulator will be initialized with this value instead of zeros. This is typically used for bias initialization in matrix multiplication. Supported dtypes:float16,bfloat16, orfloat32. Tensors withfloat16orbfloat16are automatically promoted tofloat32.
- Returns:
A new accumulator tensor in L0C memory (zero-initialized or initialized with the provided value)
- Return type:
- Raises:
TypeError – If shape contains non-integer values
RuntimeError – If shape contains non-positive values or bias has wrong shape/dtype
Examples
Create a zero-initialized accumulator:
acc = asc2.zeros_acc([64, 256], dtype=asc2.float32) for k in range(k_tiles): a_k = asc2.copy_in(a_gm, [0, k * 32], [64, 32], asc2.TensorLocation.L0A) b_k = asc2.copy_in(b_gm, [k * 32, 0], [32, 256], asc2.TensorLocation.L0B) asc2.matmul_acc(acc, a_k, b_k) asc2.copy_out(acc, c_gm, [0, 0])
Create a bias-initialized accumulator:
bias = asc2.copy_in(bias_gm, [0], [256], asc2.TensorLocation.BT) acc = asc2.zeros_acc([64, 256], dtype=asc2.float32, bias=bias) for k in range(k_tiles): a_k = asc2.copy_in(a_gm, [0, k * 32], [64, 32], asc2.TensorLocation.L0A) b_k = asc2.copy_in(b_gm, [k * 32, 0], [32, 256], asc2.TensorLocation.L0B) asc2.matmul_acc(acc, a_k, b_k) asc2.copy_out(acc, c_gm, [0, 0])