tik_break语句用来终止for_range循环语句,即tik_break语句将停止执行当前的循环。
tik_break()
无
Atlas 200/300/500 推理产品
Atlas 训练系列产品
Atlas推理系列产品AI Core
Atlas推理系列产品Vector Core
Atlas A2训练系列产品
Atlas 200I/500 A2推理产品
无
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})