"""
"""
import torch
import pypto
@pypto.frontend.jit(
runtime_options={"run_mode": pypto.RunMode.SIM},
host_options={"compile_stage": pypto.CompStage.TENSOR_GRAPH},
pass_options={"vec_nbuffer_setting": {-1: 8}})
def loop_scope(a: pypto.Tensor[[pypto.STATIC, pypto.STATIC], pypto.DT_INT32],
b: pypto.Tensor[[pypto.STATIC, pypto.STATIC], pypto.DT_INT32],
result: pypto.Tensor[[pypto.STATIC, pypto.STATIC], pypto.DT_INT32]):
pypto.set_vec_tile_shapes(64, 64)
for _ in pypto.loop(1, name="s0", idx_name="k"):
pypto.set_vec_tile_shapes(32, 32)
result.move(a + b)
for _ in pypto.loop(1, name="s0", idx_name="k"):
assert [64, 64] == pypto.get_vec_tile_shapes()
result.move(result + b)
@pypto.frontend.jit(
runtime_options={"run_mode": pypto.RunMode.SIM},
host_options={"compile_stage": pypto.CompStage.TENSOR_GRAPH},
)
def loop_scope_1(a: pypto.Tensor[[pypto.STATIC, pypto.STATIC], pypto.DT_INT32],
b: pypto.Tensor[[pypto.STATIC, pypto.STATIC], pypto.DT_INT32],
result: pypto.Tensor[[pypto.STATIC, pypto.STATIC], pypto.DT_INT32]):
pypto.set_vec_tile_shapes(64, 64)
assert {} == pypto.get_pass_options().get("vec_nbuffer_setting")
for _ in pypto.loop(1, name="s0", idx_name="k"):
pypto.set_vec_tile_shapes(32, 32)
result.move(a + b)
def test_loop_scope():
tiling = 32
n, m = tiling * 1, tiling * 1
shape = (n, m)
a_data = torch.ones((n, m), dtype=torch.int32) * 2
b_data = torch.ones((n, m), dtype=torch.int32)
result = torch.zeros(shape, dtype=torch.int32)
loop_scope(a_data, b_data, result)
loop_scope_1(a_data, b_data, result)
if __name__ == "__main__":
test_loop_scope()