tik_break

Description

Terminates the for_range loop statement, that is, stopping executing the current loop.

Prototype

tik_break()

Parameters

None

Applicability

Atlas 200/300/500 Inference Product

Atlas Training Series Product

Restrictions

  1. tik_break() can be used only in the scope of the for_range statement.
  2. When block_num of the for_range statement is greater than 1, tik_break() must not be used in the current loop, but can be used in child loops.
  3. In the same scope, the code following the tik_break statement will be skipped.
  4. For for_range(0, 1), for_range will be expanded. After it is expanded, the statements following tik_break will not be executed.
  5. If tik_break is used in the current scope of for_range, thread_num will be set to 1.

Returns

None

Example

tik_instance = tik.Tik()
kernel_name = "test_tik_break"
data_type = 'float16'
data_shape = (128,)
src_gm = tik_instance.Tensor(data_type, data_shape, name="src_gm", scope=tik.scope_gm)
dst_gm = tik_instance.Tensor(data_type, data_shape, name="dst_gm", scope=tik.scope_gm)

src_ub = tik_instance.Tensor(data_type, data_shape, name="src_ub", scope=tik.scope_ubuf)
dst_ub = tik_instance.Tensor(data_type, data_shape, name="dst_ub", scope=tik.scope_ubuf)

tik_instance.data_move(src_ub, src_gm, 0, 1, 8, 0, 0)
with tik_instance.for_range(0, 8) as i:
    with tik_instance.if_scope(i == 5):
        tik_instance.tik_break()
    tik_instance.data_move(dst_ub[i*16], src_ub[i*16], 0, 1, 1, 0, 0)
tik_instance.data_move(dst_gm, dst_ub, 0, 1, 8, 0, 0)
tik_instance.BuildCCE(kernel_name, inputs=[src_gm], outputs=[dst_gm], config={'save_temp_cce_file': True})