asc.experimental.asctile.sub_block_idx

asc.experimental.asctile.sub_block_idx() → PlainValue

Returns the current sub-block index of vector or cube unit on the AI core.

This function is useful to distinguish between vector sub-cores if the platform has multiple of them, especially when the kernel employs both vector and cube units. For example, there are 2 vector sub-cores and 1 cube sub-core on Ascend950PR_9599 chip.

Returns:

The current sub-block index

Return type:

PlainValue

Examples

Use with block_idx to compute starting iteration in a loop:

idx = asctile.block_idx()
num = asctile.sub_block_num()
start = idx / num
for i in asctile.range(start, total, step=asctile.block_num()):
    ...