Merged
feat(IR): frontend pass output new format IR #5459
Jie YinAdd on Aug 15
feat(IR): frontend pass output new format IR #5459
Merged
Merged fromyinjie27_/pyptonormalize-ir-compareintocann/pyptomaster
Total: 62 files changed+1219-1057
| @@ -59,6 +59,7 @@ | |||
| 59 | #define IR_KW_PTR "ptr" | 59 | #define IR_KW_PTR "ptr" |
| 60 | #define IR_KW_TOKEN "token" | 60 | #define IR_KW_TOKEN "token" |
| 61 | #define IR_KW_NONE "none" | 61 | #define IR_KW_NONE "none" |
| 62 | +#define IR_KW_NULL "null" | ||
| 62 | #define IR_KW_TENSOR_VIEW "tensor_view" | 63 | #define IR_KW_TENSOR_VIEW "tensor_view" |
| 63 | #define IR_KW_TILE_VIEW "tile_view" | 64 | #define IR_KW_TILE_VIEW "tile_view" |
| 64 | #define IR_KW_MEMREF "memref" | 65 | #define IR_KW_MEMREF "memref" |
| @@ -160,6 +161,7 @@ enum class LexerTokenKind { | |||
| 160 | KwEntry, | 161 | KwEntry, |
| 161 | KwType, | 162 | KwType, |
| 162 | KwDim, | 163 | KwDim, |
| 164 | + KwNull, | ||
| 163 | // Scalar binary op keywords | 165 | // Scalar binary op keywords |
| 164 | KwBOpAdd, | 166 | KwBOpAdd, |
| 165 | KwBOpSub, | 167 | KwBOpSub, |
| @@ -277,6 +279,7 @@ static inline const npu::tile_fwk::BiMap<LexerTokenKind>& GetLexerTokenDict() | |||
| 277 | {LexerTokenKind::KwEntry, IR_KW_ENTRY}, | 279 | {LexerTokenKind::KwEntry, IR_KW_ENTRY}, |
| 278 | {LexerTokenKind::KwType, IR_KW_TYPE}, | 280 | {LexerTokenKind::KwType, IR_KW_TYPE}, |
| 279 | {LexerTokenKind::KwDim, IR_KW_DIM}, | 281 | {LexerTokenKind::KwDim, IR_KW_DIM}, |
| 282 | + {LexerTokenKind::KwNull, IR_KW_NULL}, | ||
| 280 | // Scalar binary ops | 283 | // Scalar binary ops |
| 281 | {LexerTokenKind::KwBOpAdd, IR_KW_SCALAR_BOP_ADD}, | 284 | {LexerTokenKind::KwBOpAdd, IR_KW_SCALAR_BOP_ADD}, |
| 282 | {LexerTokenKind::KwBOpSub, IR_KW_SCALAR_BOP_SUB}, | 285 | {LexerTokenKind::KwBOpSub, IR_KW_SCALAR_BOP_SUB}, |
| @@ -128,8 +128,10 @@ void IRDumperText::VisitType_(const TensorTypePtr& op) | |||
| 128 | stream_ << IR_PUN_COMMA << " "; | 128 | stream_ << IR_PUN_COMMA << " "; |
| 129 | PrintShape(tv.stride); | 129 | PrintShape(tv.stride); |
| 130 | stream_ << IR_PUN_COMMA << " " << GetTensorLayoutDict().Find(tv.layout); | 130 | stream_ << IR_PUN_COMMA << " " << GetTensorLayoutDict().Find(tv.layout); |
| 131 | - stream_ << IR_PUN_COMMA << " "; | 131 | + if (tv.ptr.has_value()) { |
| 132 | - VisitExpr(tv.ptr.value()); | 132 | + stream_ << IR_PUN_COMMA << " "; |
| 133 | + VisitExpr(tv.ptr.value()); | ||
| 134 | + } | ||
| 133 | } | 135 | } |
| 134 | stream_ << IR_PUN_GT; | 136 | stream_ << IR_PUN_GT; |
| 135 | stream_ << IR_PUN_GT; | 137 | stream_ << IR_PUN_GT; |
| @@ -147,7 +149,11 @@ void IRDumperText::VisitType_(const TileTypePtr& op) | |||
| 147 | stream_ << IR_PUN_COMMA << " "; | 149 | stream_ << IR_PUN_COMMA << " "; |
| 148 | PrintShape(tv.stride); | 150 | PrintShape(tv.stride); |
| 149 | stream_ << IR_PUN_COMMA << " "; | 151 | stream_ << IR_PUN_COMMA << " "; |
| 150 | - VisitExpr(tv.startOffset); | 152 | + if (tv.startOffset) { |
| 153 | + VisitExpr(tv.startOffset); | ||
| 154 | + } else { | ||
| 155 | + stream_ << IR_KW_NULL; | ||
| 156 | + } | ||
| 151 | } | 157 | } |
| 152 | stream_ << IR_PUN_GT; | 158 | stream_ << IR_PUN_GT; |
| 153 | stream_ << IR_PUN_COMMA << " " << IR_KW_HW_INFO << IR_PUN_LT; | 159 | stream_ << IR_PUN_COMMA << " " << IR_KW_HW_INFO << IR_PUN_LT; |
| @@ -391,7 +397,11 @@ void IRDumperText::VisitStmt_(const IfStmtPtr& op) | |||
| 391 | stream_ << " " << IR_KW_THEN; | 397 | stream_ << " " << IR_KW_THEN; |
| 392 | PrintBody(op->thenBody_); | 398 | PrintBody(op->thenBody_); |
| 393 | stream_ << "\n" << GetIndent() << IR_KW_ELSE; | 399 | stream_ << "\n" << GetIndent() << IR_KW_ELSE; |
| 394 | - PrintBody(op->elseBody_.value()); | 400 | + if (op->elseBody_.has_value()) { |
| 401 | + PrintBody(op->elseBody_.value()); | ||
| 402 | + } else { | ||
| 403 | + stream_ << " " << IR_PUN_LBRACE << IR_PUN_RBRACE; | ||
| 404 | + } | ||
| 395 | } | 405 | } |
| 396 | 406 | ||
| 397 | void IRDumperText::VisitStmt_(const YieldStmtPtr& op) | 407 | void IRDumperText::VisitStmt_(const YieldStmtPtr& op) |
| @@ -558,9 +558,12 @@ public: | |||
| 558 | MUST_MATCH(ParseToken(LexerTokenKind::PunComma)); | 558 | MUST_MATCH(ParseToken(LexerTokenKind::PunComma)); |
| 559 | MUST_VALID(layoutStr, ParseIdent()); | 559 | MUST_VALID(layoutStr, ParseIdent()); |
| 560 | TensorLayout layout = GetTensorLayoutDict().Find(layoutStr->data, TensorLayout::ND); | 560 | TensorLayout layout = GetTensorLayoutDict().Find(layoutStr->data, TensorLayout::ND); |
| 561 | - MUST_MATCH(ParseToken(LexerTokenKind::PunComma)); | 561 | + if (CheckToken(LexerTokenKind::PunComma, true)) { |
| 562 | - MUST_VALID(ptrExpr, ParseExpr()); | 562 | + MUST_VALID(ptrExpr, ParseExpr()); |
| 563 | - tensorView = TensorView(validShape->data, stride->data, layout, ptrExpr); | 563 | + tensorView = TensorView(validShape->data, stride->data, layout, ptrExpr); |
| 564 | + } else { | ||
| 565 | + tensorView = TensorView(validShape->data, stride->data, layout); | ||
| 566 | + } | ||
| 564 | } | 567 | } |
| 565 | 568 | ||
| 566 | MUST_MATCH(ParseToken(LexerTokenKind::PunGt)); | 569 | MUST_MATCH(ParseToken(LexerTokenKind::PunGt)); |
| @@ -592,7 +595,11 @@ public: | |||
| 592 | MUST_MATCH(ParseToken(LexerTokenKind::PunComma)); | 595 | MUST_MATCH(ParseToken(LexerTokenKind::PunComma)); |
| 593 | auto stride = ParseShape(); | 596 | auto stride = ParseShape(); |
| 594 | MUST_MATCH(ParseToken(LexerTokenKind::PunComma)); | 597 | MUST_MATCH(ParseToken(LexerTokenKind::PunComma)); |
| 595 | - MUST_VALID(startOffset, ParseExpr()); | 598 | + ExprPtr startOffset = nullptr; |
| 599 | + if (!CheckToken(LexerTokenKind::KwNull)) { | ||
| 600 | + MUST_VALID(offset, ParseExpr()); | ||
| 601 | + startOffset = offset; | ||
| 602 | + } | ||
| 596 | tileView = TileView(validShape->data, stride->data, startOffset); | 603 | tileView = TileView(validShape->data, stride->data, startOffset); |
| 597 | } | 604 | } |
| 598 | 605 | ||
| @@ -37,6 +37,7 @@ | |||
| 37 | #include "ir/scalar_expr.h" | 37 | #include "ir/scalar_expr.h" |
| 38 | #include "ir/scalar_expr_ops.h" | 38 | #include "ir/scalar_expr_ops.h" |
| 39 | #include "ir/stmt.h" | 39 | #include "ir/stmt.h" |
| 40 | +#include "ir/transforms/io_text.h" | ||
| 40 | #include "ir/transforms/op_conversion_registry.h" | 41 | #include "ir/transforms/op_conversion_registry.h" |
| 41 | #include "ir/transforms/printer.h" | 42 | #include "ir/transforms/printer.h" |
| 42 | #include "ir/transforms/structural_comparison.h" | 43 | #include "ir/transforms/structural_comparison.h" |
| @@ -1395,6 +1396,8 @@ void BindProgram(py::module_& ir) | |||
| 1395 | py::arg("name"), py::arg("params"), py::arg("return_types"), py::arg("body"), py::arg("span"), | 1396 | py::arg("name"), py::arg("params"), py::arg("return_types"), py::arg("body"), py::arg("span"), |
| 1396 | py::arg("type") = FunctionType::OPAQUE, py::arg("entry") = false, "Create a function definition"); | 1397 | py::arg("type") = FunctionType::OPAQUE, py::arg("entry") = false, "Create a function definition"); |
| 1397 | BindFields<Function>(function_class); | 1398 | BindFields<Function>(function_class); |
| 1399 | + function_class.def( | ||
| 1400 | + "__str__", [](const std::shared_ptr<Function>& self) { return TextDump(self); }, "IR text representation"); | ||
| 1398 | 1401 | ||
| 1399 | // IRDebugInfo - compilation-session side table for tuple/struct field names. | 1402 | // IRDebugInfo - compilation-session side table for tuple/struct field names. |
| 1400 | auto debug_info_class = py::class_<IRDebugInfo, std::shared_ptr<IRDebugInfo>>( | 1403 | auto debug_info_class = py::class_<IRDebugInfo, std::shared_ptr<IRDebugInfo>>( |
| @@ -1460,6 +1463,8 @@ void BindProgram(py::module_& ir) | |||
| 1460 | "Map of function names to their corresponding functions, sorted by name"); | 1463 | "Map of function names to their corresponding functions, sorted by name"); |
| 1461 | program_class.def_readonly("name", &Program::name_, "Program name"); | 1464 | program_class.def_readonly("name", &Program::name_, "Program name"); |
| 1462 | program_class.def_readonly("span", &Program::span_, "Source location"); | 1465 | program_class.def_readonly("span", &Program::span_, "Source location"); |
| 1466 | + program_class.def( | ||
| 1467 | + "__str__", [](const std::shared_ptr<const Program>& self) { return TextDump(self); }, "IR text representation"); | ||
| 1463 | 1468 | ||
| 1464 | // Python-style printer function - unified API for IRNode | 1469 | // Python-style printer function - unified API for IRNode |
| 1465 | ir.def( | 1470 | ir.def( |
| @@ -426,17 +426,17 @@ def test_basic_stmt(): | |||
| 426 | func = ir.Function("test_func", [x], [st], assign_x, span) | 426 | func = ir.Function("test_func", [x], [st], assign_x, span) |
| 427 | assert str(func) == "\n".join( | 427 | assert str(func) == "\n".join( |
| 428 | [ | 428 | [ |
| 429 | - "@ir.function", | 429 | + "function test_func incast(int32_t %x) outcast(int32_t) #type(Opaque) #entry(false) {", |
| 430 | - "def test_func(x: ir.Scalar[ir.INT32]) -> ir.Scalar[ir.INT32]:", | 430 | + " int32_t %x = 42;", |
| 431 | - " x: ir.Scalar[ir.INT32] = 42", | 431 | + "}", |
| 432 | ] | 432 | ] |
| 433 | ) | 433 | ) |
| 434 | helper_func = ir.Function("helper", [x], [st], ir.YieldStmt([x], span), span, ir.FunctionType.Helper) | 434 | helper_func = ir.Function("helper", [x], [st], ir.YieldStmt([x], span), span, ir.FunctionType.Helper) |
| 435 | assert str(helper_func) == "\n".join( | 435 | assert str(helper_func) == "\n".join( |
| 436 | [ | 436 | [ |
| 437 | - "@ir.function(type=ir.FunctionType.Helper)", | 437 | + "function helper incast(int32_t %x) outcast(int32_t) #type(Helper) #entry(false) {", |
| 438 | - "def helper(x: ir.Scalar[ir.INT32]) -> ir.Scalar[ir.INT32]:", | 438 | + " yield %x;", |
| 439 | - " return x", | 439 | + "}", |
| 440 | ] | 440 | ] |
| 441 | ) | 441 | ) |
| 442 | 442 | ||
| @@ -445,13 +445,14 @@ def test_basic_stmt(): | |||
| 445 | prog = ir.Program([func, func2], "test_prog", span) | 445 | prog = ir.Program([func, func2], "test_prog", span) |
| 446 | assert str(prog) == "\n".join( | 446 | assert str(prog) == "\n".join( |
| 447 | [ | 447 | [ |
| 448 | - "# ir.program: test_prog", | 448 | + "program #entry() {", |
| 449 | - "@ir.function", | 449 | + " function test_func incast(int32_t %x) outcast(int32_t) #type(Opaque) #entry(false) {", |
| 450 | - "def test_func(x: ir.Scalar[ir.INT32]) -> ir.Scalar[ir.INT32]:", | 450 | + " int32_t %x = 42;", |
| 451 | - " x: ir.Scalar[ir.INT32] = 42", | 451 | + " }", |
| 452 | - "@ir.function", | 452 | + " function test_func2 incast(int32_t %x) outcast(int32_t) #type(Opaque) #entry(false) {", |
| 453 | - "def test_func2(x: ir.Scalar[ir.INT32]) -> ir.Scalar[ir.INT32]:", | 453 | + " int32_t %x = 42;", |
| 454 | - " x: ir.Scalar[ir.INT32] = 42", | 454 | + " }", |
| 455 | + "}", | ||
| 455 | ] | 456 | ] |
| 456 | ) | 457 | ) |
| 457 | assert prog["test_func"] is not None | 458 | assert prog["test_func"] is not None |
| @@ -68,7 +68,11 @@ def test_ir_verify(): | |||
| 68 | y = pypto.from_torch(b) | 68 | y = pypto.from_torch(b) |
| 69 | z = pypto.from_torch(c) | 69 | z = pypto.from_torch(c) |
| 70 | 70 | ||
| 71 | + original_options = pypto.get_verify_options() | ||
| 71 | pypto.set_verify_options(**verify_options) | 72 | pypto.set_verify_options(**verify_options) |
| 72 | - BuildOnlineCalculatorManager().build_and_load_calculator() | 73 | + try: |
| 74 | + BuildOnlineCalculatorManager().build_and_load_calculator() | ||
| 73 | 75 | ||
| 74 | - _run_dce(foo, golden, x, y, z) | 76 | + _run_dce(foo, golden, x, y, z) |
| 77 | + finally: | ||
| 78 | + pypto.set_verify_options(**original_options) | ||
| @@ -7,31 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(a@0: ir.Tensor, b@1: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_fillpad.pypto").read_text() |
| 17 | - for loop_idx_12, (b_1,) in ir.range(0, (((n-0)/2)*2), 2, init_values=(b@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 2}): | ||
| 18 | - if ((loop_idx_12+1)==(n-1)): | ||
| 19 | - $3@4 = VEC_DUP() | ||
| 20 | - b_5@1 = ADDS($3@4) | ||
| 21 | - b_7 = ir.yield_(b_5@1) | ||
| 22 | - else: | ||
| 23 | - b_7 = ir.yield_(b_1@1) | ||
| 24 | - b_9 = continue b_7@1 | ||
| 25 | - for loop_idx_12_0, (b_11,) in ir.range((((n-0)/2)*2), n, 1, init_values=(b_9@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 26 | - if (loop_idx_12_0==(n-1)): | ||
| 27 | - $8@6 = VEC_DUP() | ||
| 28 | - b_12@1 = ADDS($8@6) | ||
| 29 | - b_14 = ir.yield_(b_12@1) | ||
| 30 | - else: | ||
| 31 | - b_14 = ir.yield_(b_11@1) | ||
| 32 | - b_16 = continue b_14@1 | ||
| 33 | - return a@0, b_16@1 | ||
| 34 | -""" # noqa: E501 | ||
| 35 | 19 | ||
| 36 | 20 | ||
| 37 | def test_fillpad(): | 21 | def test_fillpad(): |
| @@ -0,0 +1,25 @@ | |||
| 1 | +function foo incast(logical_tensor %a, logical_tensor %b) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %b_9 = for %loop_idx_12 inrange 0, scalar_expr, 2 iter {logical_tensor %b_1 = %b;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(2) { | ||
| 3 | + logical_tensor %b_7 = if scalar_expr then { | ||
| 4 | + logical_tensor %$3 = VEC_DUP() token(); | ||
| 5 | + logical_tensor %b_5 = ADDS(%$3) token(); | ||
| 6 | + yield %b_5; | ||
| 7 | + } | ||
| 8 | + else { | ||
| 9 | + yield %b_1; | ||
| 10 | + } | ||
| 11 | + continue %b_7; | ||
| 12 | + } | ||
| 13 | + logical_tensor %b_16 = for %loop_idx_12_0 inrange scalar_expr, %n, 1 iter {logical_tensor %b_11 = %b_9;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 14 | + logical_tensor %b_14 = if scalar_expr then { | ||
| 15 | + logical_tensor %$8 = VEC_DUP() token(); | ||
| 16 | + logical_tensor %b_12 = ADDS(%$8) token(); | ||
| 17 | + yield %b_12; | ||
| 18 | + } | ||
| 19 | + else { | ||
| 20 | + yield %b_11; | ||
| 21 | + } | ||
| 22 | + continue %b_14; | ||
| 23 | + } | ||
| 24 | + return %a, %b_16; | ||
| 25 | +} | ||
| @@ -7,46 +7,16 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | from pypto import ir, pil | 13 | from pypto import ir, pil |
| 12 | 14 | ||
| 13 | from ..test_common import check_snapshot | 15 | from ..test_common import check_snapshot |
| 14 | 16 | ||
| 15 | -IR = """ | 17 | +_GOLDEN_DIR = Path(__file__).parent |
| 16 | -@ir.function | 18 | + |
| 17 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 19 | +IR = (_GOLDEN_DIR / "test_merge_chain_clonemap.pypto").read_text() |
| 18 | - for loop_idx_20, (i, s0, t0, t1) in ir.range(0, 2, 1, init_values=(None, None, None, None), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 19 | - if (0<n): | ||
| 20 | - if (0<m): | ||
| 21 | - $0@3 = ADD(x@0, y@1) | ||
| 22 | - $3@5 = ADD($0@3, y@1) | ||
| 23 | - $6@7 = ADD($3@5, x@0) | ||
| 24 | - z@2 = ASSEMBLE($6@7, attrs=["toOffset": [0, 0]]) | ||
| 25 | - $0_0, t1_0, $6_0, z = ir.yield_($0@3, $3@5, $6@7, z@2) | ||
| 26 | - else: | ||
| 27 | - $0_1@3 = ADD(x@0, y@1) | ||
| 28 | - $4@6 = SUB($0_1@3, y@1) | ||
| 29 | - $6_2@7 = ADD($4@6, x@0) | ||
| 30 | - z@2 = ASSEMBLE($6_2@7, attrs=["toOffset": [0, 0]]) | ||
| 31 | - $0_0, t1_0, $6_0, z = ir.yield_($0_1@3, $4@6, $6_2@7, z@2) | ||
| 32 | - t0_0, t1_2, $6_1, z = ir.yield_($0_0@3, t1_0@5, $6_0@7, z@2) | ||
| 33 | - else: | ||
| 34 | - if (0<m): | ||
| 35 | - $1@4 = SUB(x@0, y@1) | ||
| 36 | - $3_0@5 = ADD($1@4, y@1) | ||
| 37 | - $6_4@7 = ADD($3_0@5, x@0) | ||
| 38 | - z@2 = ASSEMBLE($6_4@7, attrs=["toOffset": [0, 0]]) | ||
| 39 | - $1_0, t1_3, $6_5, z = ir.yield_($1@4, $3_0@5, $6_4@7, z@2) | ||
| 40 | - else: | ||
| 41 | - $1_1@4 = SUB(x@0, y@1) | ||
| 42 | - $4_0@6 = SUB($1_1@4, y@1) | ||
| 43 | - $6_3@7 = ADD($4_0@6, x@0) | ||
| 44 | - z@2 = ASSEMBLE($6_3@7, attrs=["toOffset": [0, 0]]) | ||
| 45 | - $1_0, t1_3, $6_5, z = ir.yield_($1_1@4, $4_0@6, $6_3@7, z@2) | ||
| 46 | - t0_0, t1_2, $6_1, z = ir.yield_($1_0@4, t1_3@5, $6_5@7, z@2) | ||
| 47 | - i_0, s0_0, t0_1, t1_1 = continue loop_idx_20, $6_1@7, t0_0@3, t1_2@5 | ||
| 48 | - return x@0, y@1, z@2 | ||
| 49 | -""" # noqa: E501 | ||
| 50 | 20 | ||
| 51 | 21 | ||
| 52 | def test_merge_chain_clonemap(): | 22 | def test_merge_chain_clonemap(): |
| @@ -0,0 +1,40 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + int64_t %i_0, logical_tensor %s0_0, logical_tensor %t0_1, logical_tensor %t1_1 = for %loop_idx_20 inrange 0, 2, 1 iter {none %i = %None;none %s0 = %None;none %t0 = %None;none %t1 = %None;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + logical_tensor %t0_0, logical_tensor %t1_2, logical_tensor %$6_1, logical_tensor %z = if scalar_expr then { | ||
| 4 | + logical_tensor %$0_0, logical_tensor %t1_0, logical_tensor %$6_0, logical_tensor %z = if scalar_expr then { | ||
| 5 | + logical_tensor %$0 = ADD(%x, %y) token(); | ||
| 6 | + logical_tensor %$3 = ADD(%$0, %y) token(); | ||
| 7 | + logical_tensor %$6 = ADD(%$3, %x) token(); | ||
| 8 | + logical_tensor %z = ASSEMBLE(%$6) token(); | ||
| 9 | + yield %$0, %$3, %$6, %z; | ||
| 10 | + } | ||
| 11 | + else { | ||
| 12 | + logical_tensor %$0_1 = ADD(%x, %y) token(); | ||
| 13 | + logical_tensor %$4 = SUB(%$0_1, %y) token(); | ||
| 14 | + logical_tensor %$6_2 = ADD(%$4, %x) token(); | ||
| 15 | + logical_tensor %z = ASSEMBLE(%$6_2) token(); | ||
| 16 | + yield %$0_1, %$4, %$6_2, %z; | ||
| 17 | + } | ||
| 18 | + yield %$0_0, %t1_0, %$6_0, %z; | ||
| 19 | + } | ||
| 20 | + else { | ||
| 21 | + logical_tensor %$1_0, logical_tensor %t1_3, logical_tensor %$6_5, logical_tensor %z = if scalar_expr then { | ||
| 22 | + logical_tensor %$1 = SUB(%x, %y) token(); | ||
| 23 | + logical_tensor %$3_0 = ADD(%$1, %y) token(); | ||
| 24 | + logical_tensor %$6_4 = ADD(%$3_0, %x) token(); | ||
| 25 | + logical_tensor %z = ASSEMBLE(%$6_4) token(); | ||
| 26 | + yield %$1, %$3_0, %$6_4, %z; | ||
| 27 | + } | ||
| 28 | + else { | ||
| 29 | + logical_tensor %$1_1 = SUB(%x, %y) token(); | ||
| 30 | + logical_tensor %$4_0 = SUB(%$1_1, %y) token(); | ||
| 31 | + logical_tensor %$6_3 = ADD(%$4_0, %x) token(); | ||
| 32 | + logical_tensor %z = ASSEMBLE(%$6_3) token(); | ||
| 33 | + yield %$1_1, %$4_0, %$6_3, %z; | ||
| 34 | + } | ||
| 35 | + yield %$1_0, %t1_3, %$6_5, %z; | ||
| 36 | + } | ||
| 37 | + continue %loop_idx_20, %$6_1, %t0_0, %t1_2; | ||
| 38 | + } | ||
| 39 | + return %x, %y, %z; | ||
| 40 | +} | ||
| @@ -6,40 +6,15 @@ | |||
| 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | +from pathlib import Path | ||
| 10 | + | ||
| 9 | import pypto | 11 | import pypto |
| 10 | 12 | ||
| 11 | from ..test_common import check_snapshot, run_merge_pass | 13 | from ..test_common import check_snapshot, run_merge_pass |
| 12 | 14 | ||
| 13 | -IR = """ | 15 | +_GOLDEN_DIR = Path(__file__).parent |
| 14 | -@ir.function | 16 | + |
| 15 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 17 | +IR = (_GOLDEN_DIR / "test_merge_pass1.pypto").read_text() |
| 16 | - for loop_idx_10 in ir.range(0, 2, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 17 | - if (loop_idx_10==0): | ||
| 18 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 19 | - View_y@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 20 | - $0@5 = ADD(View_x@3, View_y@4) | ||
| 21 | - $4@8 = SUB($0@5, View_x@3) | ||
| 22 | - z@2 = ASSEMBLE($4@8, attrs=["toOffset": [0, 0]]) | ||
| 23 | - ir.yield_() | ||
| 24 | - else: | ||
| 25 | - if (loop_idx_10==1): | ||
| 26 | - View_x_8@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 27 | - View_y_8@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 28 | - $1@6 = SUB(View_x_8@3, View_y_8@4) | ||
| 29 | - $3@7 = ADD($1@6, View_x_8@3) | ||
| 30 | - z@2 = ASSEMBLE($3@7, attrs=["toOffset": [0, 0]]) | ||
| 31 | - ir.yield_() | ||
| 32 | - else: | ||
| 33 | - View_x_6@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 34 | - View_y_6@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 35 | - $1_1@6 = SUB(View_x_6@3, View_y_6@4) | ||
| 36 | - $4_0@8 = SUB($1_1@6, View_x_6@3) | ||
| 37 | - z@2 = ASSEMBLE($4_0@8, attrs=["toOffset": [0, 0]]) | ||
| 38 | - ir.yield_() | ||
| 39 | - ir.yield_() | ||
| 40 | - continue | ||
| 41 | - return x@0, y@1, z@2 | ||
| 42 | -""" | ||
| 43 | 18 | ||
| 44 | 19 | ||
| 45 | def test_merge_pass1(): | 20 | def test_merge_pass1(): |
| @@ -0,0 +1,33 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + for %loop_idx_10 inrange 0, 2, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + if scalar_expr then { | ||
| 4 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 5 | + logical_tensor %View_y = VIEW(%y) token(); | ||
| 6 | + logical_tensor %$0 = ADD(%View_x, %View_y) token(); | ||
| 7 | + logical_tensor %$4 = SUB(%$0, %View_x) token(); | ||
| 8 | + logical_tensor %z = ASSEMBLE(%$4) token(); | ||
| 9 | + yield; | ||
| 10 | + } | ||
| 11 | + else { | ||
| 12 | + if scalar_expr then { | ||
| 13 | + logical_tensor %View_x_8 = VIEW(%x) token(); | ||
| 14 | + logical_tensor %View_y_8 = VIEW(%y) token(); | ||
| 15 | + logical_tensor %$1 = SUB(%View_x_8, %View_y_8) token(); | ||
| 16 | + logical_tensor %$3 = ADD(%$1, %View_x_8) token(); | ||
| 17 | + logical_tensor %z = ASSEMBLE(%$3) token(); | ||
| 18 | + yield; | ||
| 19 | + } | ||
| 20 | + else { | ||
| 21 | + logical_tensor %View_x_6 = VIEW(%x) token(); | ||
| 22 | + logical_tensor %View_y_6 = VIEW(%y) token(); | ||
| 23 | + logical_tensor %$1_1 = SUB(%View_x_6, %View_y_6) token(); | ||
| 24 | + logical_tensor %$4_0 = SUB(%$1_1, %View_x_6) token(); | ||
| 25 | + logical_tensor %z = ASSEMBLE(%$4_0) token(); | ||
| 26 | + yield; | ||
| 27 | + } | ||
| 28 | + yield; | ||
| 29 | + } | ||
| 30 | + continue; | ||
| 31 | + } | ||
| 32 | + return %x, %y, %z; | ||
| 33 | +} | ||
| @@ -7,27 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_pass2.pypto").read_text() |
| 17 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 18 | - View_y@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 19 | - for loop_idx_32 in ir.range(0, 2, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 20 | - if (loop_idx_32==0): | ||
| 21 | - $1@6 = SUB(View_x@3, View_y@4) | ||
| 22 | - z@2 = ASSEMBLE($1@6, attrs=["toOffset": [0, 0]]) | ||
| 23 | - ir.yield_() | ||
| 24 | - else: | ||
| 25 | - $3@7 = ADD(View_x@3, View_y@4) | ||
| 26 | - z@2 = ASSEMBLE($3@7, attrs=["toOffset": [0, 0]]) | ||
| 27 | - ir.yield_() | ||
| 28 | - continue | ||
| 29 | - return x@0, y@1, z@2 | ||
| 30 | -""" | ||
| 31 | 19 | ||
| 32 | 20 | ||
| 33 | def test_merge_pass2(): | 21 | def test_merge_pass2(): |
| @@ -0,0 +1,18 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 3 | + logical_tensor %View_y = VIEW(%y) token(); | ||
| 4 | + for %loop_idx_32 inrange 0, 2, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + if scalar_expr then { | ||
| 6 | + logical_tensor %$1 = SUB(%View_x, %View_y) token(); | ||
| 7 | + logical_tensor %z = ASSEMBLE(%$1) token(); | ||
| 8 | + yield; | ||
| 9 | + } | ||
| 10 | + else { | ||
| 11 | + logical_tensor %$3 = ADD(%View_x, %View_y) token(); | ||
| 12 | + logical_tensor %z = ASSEMBLE(%$3) token(); | ||
| 13 | + yield; | ||
| 14 | + } | ||
| 15 | + continue; | ||
| 16 | + } | ||
| 17 | + return %x, %y, %z; | ||
| 18 | +} | ||
| @@ -7,21 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_pass3.pypto").read_text() |
| 17 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 18 | - View_y@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 19 | - for loop_idx_32 in ir.range(0, 2, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 20 | - $1@6 = SUB(View_x@3, View_y@4) | ||
| 21 | - z@2 = ASSEMBLE($1@6, attrs=["toOffset": [0, 0]]) | ||
| 22 | - continue | ||
| 23 | - return x@0, y@1, z@2 | ||
| 24 | -""" | ||
| 25 | 19 | ||
| 26 | 20 | ||
| 27 | def test_merge_pass3(): | 21 | def test_merge_pass3(): |
| @@ -0,0 +1,10 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 3 | + logical_tensor %View_y = VIEW(%y) token(); | ||
| 4 | + for %loop_idx_32 inrange 0, 2, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + logical_tensor %$1 = SUB(%View_x, %View_y) token(); | ||
| 6 | + logical_tensor %z = ASSEMBLE(%$1) token(); | ||
| 7 | + continue; | ||
| 8 | + } | ||
| 9 | + return %x, %y, %z; | ||
| 10 | +} | ||
| @@ -7,36 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_pass4.pypto").read_text() |
| 17 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 18 | - View_y@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 19 | - for loop_idx_32 in ir.range(0, 2, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 20 | - if (loop_idx_32==0): | ||
| 21 | - $0@5 = ADD(View_x@3, View_y@4) | ||
| 22 | - a_0 = ir.yield_($0@5) | ||
| 23 | - else: | ||
| 24 | - $1@6 = SUB(View_x@3, View_y@4) | ||
| 25 | - a_0 = ir.yield_($1@6) | ||
| 26 | - for loop_idx_50 in ir.range(0, 2, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 27 | - z@2 = ASSEMBLE(a_0@5, attrs=["toOffset": [(loop_idx_50*16), 0]]) | ||
| 28 | - continue | ||
| 29 | - if (loop_idx_32==1): | ||
| 30 | - $3@7 = ADD(a_0@5, View_y@4) | ||
| 31 | - z@2 = ASSEMBLE($3@7, attrs=["toOffset": [0, 0]]) | ||
| 32 | - ir.yield_() | ||
| 33 | - else: | ||
| 34 | - $4@8 = SUB(a_0@5, View_y@4) | ||
| 35 | - z@2 = ASSEMBLE($4@8, attrs=["toOffset": [0, 0]]) | ||
| 36 | - ir.yield_() | ||
| 37 | - continue | ||
| 38 | - return x@0, y@1, z@2 | ||
| 39 | -""" | ||
| 40 | 19 | ||
| 41 | 20 | ||
| 42 | def test_merge_pass4(): | 21 | def test_merge_pass4(): |
| @@ -0,0 +1,30 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 3 | + logical_tensor %View_y = VIEW(%y) token(); | ||
| 4 | + for %loop_idx_32 inrange 0, 2, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + logical_tensor %a_0 = if scalar_expr then { | ||
| 6 | + logical_tensor %$0 = ADD(%View_x, %View_y) token(); | ||
| 7 | + yield %$0; | ||
| 8 | + } | ||
| 9 | + else { | ||
| 10 | + logical_tensor %$1 = SUB(%View_x, %View_y) token(); | ||
| 11 | + yield %$1; | ||
| 12 | + } | ||
| 13 | + for %loop_idx_50 inrange 0, 2, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 14 | + logical_tensor %z = ASSEMBLE(%a_0) token(); | ||
| 15 | + continue; | ||
| 16 | + } | ||
| 17 | + if scalar_expr then { | ||
| 18 | + logical_tensor %$3 = ADD(%a_0, %View_y) token(); | ||
| 19 | + logical_tensor %z = ASSEMBLE(%$3) token(); | ||
| 20 | + yield; | ||
| 21 | + } | ||
| 22 | + else { | ||
| 23 | + logical_tensor %$4 = SUB(%a_0, %View_y) token(); | ||
| 24 | + logical_tensor %z = ASSEMBLE(%$4) token(); | ||
| 25 | + yield; | ||
| 26 | + } | ||
| 27 | + continue; | ||
| 28 | + } | ||
| 29 | + return %x, %y, %z; | ||
| 30 | +} | ||
| @@ -7,29 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_pass5.pypto").read_text() |
| 17 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 18 | - View_y@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 19 | - for loop_idx_32 in ir.range(0, 2, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 20 | - if (loop_idx_32==0): | ||
| 21 | - $0@5 = ADD(View_x@3, View_y@4) | ||
| 22 | - $3@7 = ADD($0@5, View_x@3) | ||
| 23 | - z@2 = ASSEMBLE($3@7, attrs=["toOffset": [0, 0]]) | ||
| 24 | - ir.yield_() | ||
| 25 | - else: | ||
| 26 | - $1@6 = SUB(View_x@3, View_y@4) | ||
| 27 | - $3_1@7 = ADD($1@6, View_x@3) | ||
| 28 | - z@2 = ASSEMBLE($3_1@7, attrs=["toOffset": [0, 0]]) | ||
| 29 | - ir.yield_() | ||
| 30 | - continue | ||
| 31 | - return x@0, y@1, z@2 | ||
| 32 | -""" | ||
| 33 | 19 | ||
| 34 | 20 | ||
| 35 | def test_merge_pass5(): | 21 | def test_merge_pass5(): |
| @@ -0,0 +1,20 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 3 | + logical_tensor %View_y = VIEW(%y) token(); | ||
| 4 | + for %loop_idx_32 inrange 0, 2, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + if scalar_expr then { | ||
| 6 | + logical_tensor %$0 = ADD(%View_x, %View_y) token(); | ||
| 7 | + logical_tensor %$3 = ADD(%$0, %View_x) token(); | ||
| 8 | + logical_tensor %z = ASSEMBLE(%$3) token(); | ||
| 9 | + yield; | ||
| 10 | + } | ||
| 11 | + else { | ||
| 12 | + logical_tensor %$1 = SUB(%View_x, %View_y) token(); | ||
| 13 | + logical_tensor %$3_1 = ADD(%$1, %View_x) token(); | ||
| 14 | + logical_tensor %z = ASSEMBLE(%$3_1) token(); | ||
| 15 | + yield; | ||
| 16 | + } | ||
| 17 | + continue; | ||
| 18 | + } | ||
| 19 | + return %x, %y, %z; | ||
| 20 | +} | ||
| @@ -7,27 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_pass6.pypto").read_text() |
| 17 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 18 | - View_y@4 = VIEW(y@1, attrs=["fromOffset": [0, 0], "toValidShape": [16, 16]]) | ||
| 19 | - for loop_idx_32 in ir.range(0, 2, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 20 | - if (loop_idx_32==0): | ||
| 21 | - $0@5 = ADD(View_x@3, View_y@4) | ||
| 22 | - z@2 = ASSEMBLE($0@5, attrs=["toOffset": [0, 0]]) | ||
| 23 | - ir.yield_() | ||
| 24 | - else: | ||
| 25 | - $3@7 = SUB(View_x@3, View_y@4) | ||
| 26 | - z@2 = ASSEMBLE($3@7, attrs=["toOffset": [0, 0]]) | ||
| 27 | - ir.yield_() | ||
| 28 | - continue | ||
| 29 | - return x@0, y@1, z@2 | ||
| 30 | -""" | ||
| 31 | 19 | ||
| 32 | 20 | ||
| 33 | def test_merge_pass6(): | 21 | def test_merge_pass6(): |
| @@ -0,0 +1,18 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 3 | + logical_tensor %View_y = VIEW(%y) token(); | ||
| 4 | + for %loop_idx_32 inrange 0, 2, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + if scalar_expr then { | ||
| 6 | + logical_tensor %$0 = ADD(%View_x, %View_y) token(); | ||
| 7 | + logical_tensor %z = ASSEMBLE(%$0) token(); | ||
| 8 | + yield; | ||
| 9 | + } | ||
| 10 | + else { | ||
| 11 | + logical_tensor %$3 = SUB(%View_x, %View_y) token(); | ||
| 12 | + logical_tensor %z = ASSEMBLE(%$3) token(); | ||
| 13 | + yield; | ||
| 14 | + } | ||
| 15 | + continue; | ||
| 16 | + } | ||
| 17 | + return %x, %y, %z; | ||
| 18 | +} | ||
| @@ -7,104 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_pass7.pypto").read_text() |
| 17 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [RUNTIME_Min(RUNTIME_Max(RUNTIME_GetInputShapeDim(ARG_x,0), 0), 16), 16]]) | ||
| 18 | - for loop_idx_37 in ir.range(0, (((RUNTIME_GetInputShapeDim(ARG_x,0)-0)/4)*4), 4, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 4}): | ||
| 19 | - if (loop_idx_37==0): | ||
| 20 | - if ((loop_idx_37+3)==(RUNTIME_GetInputShapeDim(ARG_x,0)-1)): | ||
| 21 | - $0@5 = ADDS(View_x@3) | ||
| 22 | - $5@9 = SUBS(View_x@3) | ||
| 23 | - z@2 = ASSEMBLE($5@9, attrs=["toOffset": [0, 0]]) | ||
| 24 | - $8@11 = SUBS(View_x@3) | ||
| 25 | - $12@14 = SUBS(View_x@3) | ||
| 26 | - z@2 = ASSEMBLE($12@14, attrs=["toOffset": [0, 0]]) | ||
| 27 | - $15@16 = SUBS(View_x@3) | ||
| 28 | - $19@19 = SUBS(View_x@3) | ||
| 29 | - z@2 = ASSEMBLE($19@19, attrs=["toOffset": [0, 0]]) | ||
| 30 | - $22@21 = SUBS(View_x@3) | ||
| 31 | - $25@23 = ADDS(View_x@3) | ||
| 32 | - z@2 = ASSEMBLE($25@23, attrs=["toOffset": [0, 0]]) | ||
| 33 | - ir.yield_() | ||
| 34 | - else: | ||
| 35 | - $0_1@5 = ADDS(View_x@3) | ||
| 36 | - $5_2@9 = SUBS(View_x@3) | ||
| 37 | - z@2 = ASSEMBLE($5_2@9, attrs=["toOffset": [0, 0]]) | ||
| 38 | - $8_2@11 = SUBS(View_x@3) | ||
| 39 | - $12_2@14 = SUBS(View_x@3) | ||
| 40 | - z@2 = ASSEMBLE($12_2@14, attrs=["toOffset": [0, 0]]) | ||
| 41 | - $15_2@16 = SUBS(View_x@3) | ||
| 42 | - $19_2@19 = SUBS(View_x@3) | ||
| 43 | - z@2 = ASSEMBLE($19_2@19, attrs=["toOffset": [0, 0]]) | ||
| 44 | - $22_2@21 = SUBS(View_x@3) | ||
| 45 | - $26@24 = SUBS(View_x@3) | ||
| 46 | - z@2 = ASSEMBLE($26@24, attrs=["toOffset": [0, 0]]) | ||
| 47 | - ir.yield_() | ||
| 48 | - ir.yield_() | ||
| 49 | - else: | ||
| 50 | - if ((loop_idx_37+3)==(RUNTIME_GetInputShapeDim(ARG_x,0)-1)): | ||
| 51 | - $1@6 = SUBS(View_x@3) | ||
| 52 | - $5_5@9 = SUBS(View_x@3) | ||
| 53 | - z@2 = ASSEMBLE($5_5@9, attrs=["toOffset": [0, 0]]) | ||
| 54 | - $8_5@11 = SUBS(View_x@3) | ||
| 55 | - $12_5@14 = SUBS(View_x@3) | ||
| 56 | - z@2 = ASSEMBLE($12_5@14, attrs=["toOffset": [0, 0]]) | ||
| 57 | - $15_5@16 = SUBS(View_x@3) | ||
| 58 | - $19_5@19 = SUBS(View_x@3) | ||
| 59 | - z@2 = ASSEMBLE($19_5@19, attrs=["toOffset": [0, 0]]) | ||
| 60 | - $22_5@21 = SUBS(View_x@3) | ||
| 61 | - $25_0@23 = ADDS(View_x@3) | ||
| 62 | - z@2 = ASSEMBLE($25_0@23, attrs=["toOffset": [0, 0]]) | ||
| 63 | - ir.yield_() | ||
| 64 | - else: | ||
| 65 | - $1_1@6 = SUBS(View_x@3) | ||
| 66 | - $5_4@9 = SUBS(View_x@3) | ||
| 67 | - z@2 = ASSEMBLE($5_4@9, attrs=["toOffset": [0, 0]]) | ||
| 68 | - $8_4@11 = SUBS(View_x@3) | ||
| 69 | - $12_4@14 = SUBS(View_x@3) | ||
| 70 | - z@2 = ASSEMBLE($12_4@14, attrs=["toOffset": [0, 0]]) | ||
| 71 | - $15_4@16 = SUBS(View_x@3) | ||
| 72 | - $19_4@19 = SUBS(View_x@3) | ||
| 73 | - z@2 = ASSEMBLE($19_4@19, attrs=["toOffset": [0, 0]]) | ||
| 74 | - $22_4@21 = SUBS(View_x@3) | ||
| 75 | - $26_0@24 = SUBS(View_x@3) | ||
| 76 | - z@2 = ASSEMBLE($26_0@24, attrs=["toOffset": [0, 0]]) | ||
| 77 | - ir.yield_() | ||
| 78 | - ir.yield_() | ||
| 79 | - continue | ||
| 80 | - for loop_idx_37_0 in ir.range((((RUNTIME_GetInputShapeDim(ARG_x,0)-0)/4)*4), RUNTIME_GetInputShapeDim(ARG_x,0), 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 81 | - if (loop_idx_37_0==0): | ||
| 82 | - if (loop_idx_37_0==(RUNTIME_GetInputShapeDim(ARG_x,0)-1)): | ||
| 83 | - $30@25 = ADDS(View_x@3) | ||
| 84 | - $34@28 = ADDS(View_x@3) | ||
| 85 | - z@2 = ASSEMBLE($34@28, attrs=["toOffset": [0, 0]]) | ||
| 86 | - ir.yield_() | ||
| 87 | - else: | ||
| 88 | - $30_1@25 = ADDS(View_x@3) | ||
| 89 | - $35@29 = SUBS(View_x@3) | ||
| 90 | - z@2 = ASSEMBLE($35@29, attrs=["toOffset": [0, 0]]) | ||
| 91 | - ir.yield_() | ||
| 92 | - ir.yield_() | ||
| 93 | - else: | ||
| 94 | - if (loop_idx_37_0==(RUNTIME_GetInputShapeDim(ARG_x,0)-1)): | ||
| 95 | - $31@26 = SUBS(View_x@3) | ||
| 96 | - $34_0@28 = ADDS(View_x@3) | ||
| 97 | - z@2 = ASSEMBLE($34_0@28, attrs=["toOffset": [0, 0]]) | ||
| 98 | - ir.yield_() | ||
| 99 | - else: | ||
| 100 | - $31_1@26 = SUBS(View_x@3) | ||
| 101 | - $35_0@29 = SUBS(View_x@3) | ||
| 102 | - z@2 = ASSEMBLE($35_0@29, attrs=["toOffset": [0, 0]]) | ||
| 103 | - ir.yield_() | ||
| 104 | - ir.yield_() | ||
| 105 | - continue | ||
| 106 | - return x@0, y@1, z@2 | ||
| 107 | -""" # noqa: E501 | ||
| 108 | 19 | ||
| 109 | 20 | ||
| 110 | def test_merge_pass7(): | 21 | def test_merge_pass7(): |
| @@ -0,0 +1,106 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 3 | + for %loop_idx_37 inrange 0, scalar_expr, 4 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(4) { | ||
| 4 | + if scalar_expr then { | ||
| 5 | + if scalar_expr then { | ||
| 6 | + logical_tensor %$0 = ADDS(%View_x) token(); | ||
| 7 | + logical_tensor %$5 = SUBS(%View_x) token(); | ||
| 8 | + logical_tensor %z = ASSEMBLE(%$5) token(); | ||
| 9 | + logical_tensor %$8 = SUBS(%View_x) token(); | ||
| 10 | + logical_tensor %$12 = SUBS(%View_x) token(); | ||
| 11 | + logical_tensor %z = ASSEMBLE(%$12) token(); | ||
| 12 | + logical_tensor %$15 = SUBS(%View_x) token(); | ||
| 13 | + logical_tensor %$19 = SUBS(%View_x) token(); | ||
| 14 | + logical_tensor %z = ASSEMBLE(%$19) token(); | ||
| 15 | + logical_tensor %$22 = SUBS(%View_x) token(); | ||
| 16 | + logical_tensor %$25 = ADDS(%View_x) token(); | ||
| 17 | + logical_tensor %z = ASSEMBLE(%$25) token(); | ||
| 18 | + yield; | ||
| 19 | + } | ||
| 20 | + else { | ||
| 21 | + logical_tensor %$0_1 = ADDS(%View_x) token(); | ||
| 22 | + logical_tensor %$5_2 = SUBS(%View_x) token(); | ||
| 23 | + logical_tensor %z = ASSEMBLE(%$5_2) token(); | ||
| 24 | + logical_tensor %$8_2 = SUBS(%View_x) token(); | ||
| 25 | + logical_tensor %$12_2 = SUBS(%View_x) token(); | ||
| 26 | + logical_tensor %z = ASSEMBLE(%$12_2) token(); | ||
| 27 | + logical_tensor %$15_2 = SUBS(%View_x) token(); | ||
| 28 | + logical_tensor %$19_2 = SUBS(%View_x) token(); | ||
| 29 | + logical_tensor %z = ASSEMBLE(%$19_2) token(); | ||
| 30 | + logical_tensor %$22_2 = SUBS(%View_x) token(); | ||
| 31 | + logical_tensor %$26 = SUBS(%View_x) token(); | ||
| 32 | + logical_tensor %z = ASSEMBLE(%$26) token(); | ||
| 33 | + yield; | ||
| 34 | + } | ||
| 35 | + yield; | ||
| 36 | + } | ||
| 37 | + else { | ||
| 38 | + if scalar_expr then { | ||
| 39 | + logical_tensor %$1 = SUBS(%View_x) token(); | ||
| 40 | + logical_tensor %$5_5 = SUBS(%View_x) token(); | ||
| 41 | + logical_tensor %z = ASSEMBLE(%$5_5) token(); | ||
| 42 | + logical_tensor %$8_5 = SUBS(%View_x) token(); | ||
| 43 | + logical_tensor %$12_5 = SUBS(%View_x) token(); | ||
| 44 | + logical_tensor %z = ASSEMBLE(%$12_5) token(); | ||
| 45 | + logical_tensor %$15_5 = SUBS(%View_x) token(); | ||
| 46 | + logical_tensor %$19_5 = SUBS(%View_x) token(); | ||
| 47 | + logical_tensor %z = ASSEMBLE(%$19_5) token(); | ||
| 48 | + logical_tensor %$22_5 = SUBS(%View_x) token(); | ||
| 49 | + logical_tensor %$25_0 = ADDS(%View_x) token(); | ||
| 50 | + logical_tensor %z = ASSEMBLE(%$25_0) token(); | ||
| 51 | + yield; | ||
| 52 | + } | ||
| 53 | + else { | ||
| 54 | + logical_tensor %$1_1 = SUBS(%View_x) token(); | ||
| 55 | + logical_tensor %$5_4 = SUBS(%View_x) token(); | ||
| 56 | + logical_tensor %z = ASSEMBLE(%$5_4) token(); | ||
| 57 | + logical_tensor %$8_4 = SUBS(%View_x) token(); | ||
| 58 | + logical_tensor %$12_4 = SUBS(%View_x) token(); | ||
| 59 | + logical_tensor %z = ASSEMBLE(%$12_4) token(); | ||
| 60 | + logical_tensor %$15_4 = SUBS(%View_x) token(); | ||
| 61 | + logical_tensor %$19_4 = SUBS(%View_x) token(); | ||
| 62 | + logical_tensor %z = ASSEMBLE(%$19_4) token(); | ||
| 63 | + logical_tensor %$22_4 = SUBS(%View_x) token(); | ||
| 64 | + logical_tensor %$26_0 = SUBS(%View_x) token(); | ||
| 65 | + logical_tensor %z = ASSEMBLE(%$26_0) token(); | ||
| 66 | + yield; | ||
| 67 | + } | ||
| 68 | + yield; | ||
| 69 | + } | ||
| 70 | + continue; | ||
| 71 | + } | ||
| 72 | + for %loop_idx_37_0 inrange scalar_expr, scalar_expr, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 73 | + if scalar_expr then { | ||
| 74 | + if scalar_expr then { | ||
| 75 | + logical_tensor %$30 = ADDS(%View_x) token(); | ||
| 76 | + logical_tensor %$34 = ADDS(%View_x) token(); | ||
| 77 | + logical_tensor %z = ASSEMBLE(%$34) token(); | ||
| 78 | + yield; | ||
| 79 | + } | ||
| 80 | + else { | ||
| 81 | + logical_tensor %$30_1 = ADDS(%View_x) token(); | ||
| 82 | + logical_tensor %$35 = SUBS(%View_x) token(); | ||
| 83 | + logical_tensor %z = ASSEMBLE(%$35) token(); | ||
| 84 | + yield; | ||
| 85 | + } | ||
| 86 | + yield; | ||
| 87 | + } | ||
| 88 | + else { | ||
| 89 | + if scalar_expr then { | ||
| 90 | + logical_tensor %$31 = SUBS(%View_x) token(); | ||
| 91 | + logical_tensor %$34_0 = ADDS(%View_x) token(); | ||
| 92 | + logical_tensor %z = ASSEMBLE(%$34_0) token(); | ||
| 93 | + yield; | ||
| 94 | + } | ||
| 95 | + else { | ||
| 96 | + logical_tensor %$31_1 = SUBS(%View_x) token(); | ||
| 97 | + logical_tensor %$35_0 = SUBS(%View_x) token(); | ||
| 98 | + logical_tensor %z = ASSEMBLE(%$35_0) token(); | ||
| 99 | + yield; | ||
| 100 | + } | ||
| 101 | + yield; | ||
| 102 | + } | ||
| 103 | + continue; | ||
| 104 | + } | ||
| 105 | + return %x, %y, %z; | ||
| 106 | +} | ||
| @@ -7,104 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_pass8.pypto").read_text() |
| 17 | - View_x@3 = VIEW(x@0, attrs=["fromOffset": [0, 0], "toValidShape": [RUNTIME_Min(RUNTIME_Max(RUNTIME_GetInputShapeDim(ARG_x,0), 0), 16), 16]]) | ||
| 18 | - for loop_idx_37 in ir.range(0, (((RUNTIME_GetInputShapeDim(ARG_x,0)-0)/4)*4), 4, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 4}): | ||
| 19 | - if (loop_idx_37==0): | ||
| 20 | - if (RUNTIME_GetInputShapeDim(ARG_x,0)<=(loop_idx_37+4)): | ||
| 21 | - $0@5 = ADDS(View_x@3) | ||
| 22 | - $5@9 = SUBS(View_x@3) | ||
| 23 | - z@2 = ASSEMBLE($5@9, attrs=["toOffset": [0, 0]]) | ||
| 24 | - $8@11 = SUBS(View_x@3) | ||
| 25 | - $12@14 = SUBS(View_x@3) | ||
| 26 | - z@2 = ASSEMBLE($12@14, attrs=["toOffset": [0, 0]]) | ||
| 27 | - $15@16 = SUBS(View_x@3) | ||
| 28 | - $19@19 = SUBS(View_x@3) | ||
| 29 | - z@2 = ASSEMBLE($19@19, attrs=["toOffset": [0, 0]]) | ||
| 30 | - $22@21 = SUBS(View_x@3) | ||
| 31 | - $25@23 = ADDS(View_x@3) | ||
| 32 | - z@2 = ASSEMBLE($25@23, attrs=["toOffset": [0, 0]]) | ||
| 33 | - ir.yield_() | ||
| 34 | - else: | ||
| 35 | - $0_1@5 = ADDS(View_x@3) | ||
| 36 | - $5_2@9 = SUBS(View_x@3) | ||
| 37 | - z@2 = ASSEMBLE($5_2@9, attrs=["toOffset": [0, 0]]) | ||
| 38 | - $8_2@11 = SUBS(View_x@3) | ||
| 39 | - $12_2@14 = SUBS(View_x@3) | ||
| 40 | - z@2 = ASSEMBLE($12_2@14, attrs=["toOffset": [0, 0]]) | ||
| 41 | - $15_2@16 = SUBS(View_x@3) | ||
| 42 | - $19_2@19 = SUBS(View_x@3) | ||
| 43 | - z@2 = ASSEMBLE($19_2@19, attrs=["toOffset": [0, 0]]) | ||
| 44 | - $22_2@21 = SUBS(View_x@3) | ||
| 45 | - $26@24 = SUBS(View_x@3) | ||
| 46 | - z@2 = ASSEMBLE($26@24, attrs=["toOffset": [0, 0]]) | ||
| 47 | - ir.yield_() | ||
| 48 | - ir.yield_() | ||
| 49 | - else: | ||
| 50 | - if (RUNTIME_GetInputShapeDim(ARG_x,0)<=(loop_idx_37+4)): | ||
| 51 | - $1@6 = SUBS(View_x@3) | ||
| 52 | - $5_5@9 = SUBS(View_x@3) | ||
| 53 | - z@2 = ASSEMBLE($5_5@9, attrs=["toOffset": [0, 0]]) | ||
| 54 | - $8_5@11 = SUBS(View_x@3) | ||
| 55 | - $12_5@14 = SUBS(View_x@3) | ||
| 56 | - z@2 = ASSEMBLE($12_5@14, attrs=["toOffset": [0, 0]]) | ||
| 57 | - $15_5@16 = SUBS(View_x@3) | ||
| 58 | - $19_5@19 = SUBS(View_x@3) | ||
| 59 | - z@2 = ASSEMBLE($19_5@19, attrs=["toOffset": [0, 0]]) | ||
| 60 | - $22_5@21 = SUBS(View_x@3) | ||
| 61 | - $25_0@23 = ADDS(View_x@3) | ||
| 62 | - z@2 = ASSEMBLE($25_0@23, attrs=["toOffset": [0, 0]]) | ||
| 63 | - ir.yield_() | ||
| 64 | - else: | ||
| 65 | - $1_1@6 = SUBS(View_x@3) | ||
| 66 | - $5_4@9 = SUBS(View_x@3) | ||
| 67 | - z@2 = ASSEMBLE($5_4@9, attrs=["toOffset": [0, 0]]) | ||
| 68 | - $8_4@11 = SUBS(View_x@3) | ||
| 69 | - $12_4@14 = SUBS(View_x@3) | ||
| 70 | - z@2 = ASSEMBLE($12_4@14, attrs=["toOffset": [0, 0]]) | ||
| 71 | - $15_4@16 = SUBS(View_x@3) | ||
| 72 | - $19_4@19 = SUBS(View_x@3) | ||
| 73 | - z@2 = ASSEMBLE($19_4@19, attrs=["toOffset": [0, 0]]) | ||
| 74 | - $22_4@21 = SUBS(View_x@3) | ||
| 75 | - $26_0@24 = SUBS(View_x@3) | ||
| 76 | - z@2 = ASSEMBLE($26_0@24, attrs=["toOffset": [0, 0]]) | ||
| 77 | - ir.yield_() | ||
| 78 | - ir.yield_() | ||
| 79 | - continue | ||
| 80 | - for loop_idx_37_0 in ir.range((((RUNTIME_GetInputShapeDim(ARG_x,0)-0)/4)*4), RUNTIME_GetInputShapeDim(ARG_x,0), 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 81 | - if (loop_idx_37_0==0): | ||
| 82 | - if (RUNTIME_GetInputShapeDim(ARG_x,0)<=(loop_idx_37_0+1)): | ||
| 83 | - $30@25 = ADDS(View_x@3) | ||
| 84 | - $34@28 = ADDS(View_x@3) | ||
| 85 | - z@2 = ASSEMBLE($34@28, attrs=["toOffset": [0, 0]]) | ||
| 86 | - ir.yield_() | ||
| 87 | - else: | ||
| 88 | - $30_1@25 = ADDS(View_x@3) | ||
| 89 | - $35@29 = SUBS(View_x@3) | ||
| 90 | - z@2 = ASSEMBLE($35@29, attrs=["toOffset": [0, 0]]) | ||
| 91 | - ir.yield_() | ||
| 92 | - ir.yield_() | ||
| 93 | - else: | ||
| 94 | - if (RUNTIME_GetInputShapeDim(ARG_x,0)<=(loop_idx_37_0+1)): | ||
| 95 | - $31@26 = SUBS(View_x@3) | ||
| 96 | - $34_0@28 = ADDS(View_x@3) | ||
| 97 | - z@2 = ASSEMBLE($34_0@28, attrs=["toOffset": [0, 0]]) | ||
| 98 | - ir.yield_() | ||
| 99 | - else: | ||
| 100 | - $31_1@26 = SUBS(View_x@3) | ||
| 101 | - $35_0@29 = SUBS(View_x@3) | ||
| 102 | - z@2 = ASSEMBLE($35_0@29, attrs=["toOffset": [0, 0]]) | ||
| 103 | - ir.yield_() | ||
| 104 | - ir.yield_() | ||
| 105 | - continue | ||
| 106 | - return x@0, y@1, z@2 | ||
| 107 | -""" # noqa: E501 | ||
| 108 | 19 | ||
| 109 | 20 | ||
| 110 | def test_merge_pass8(): | 21 | def test_merge_pass8(): |
| @@ -0,0 +1,106 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %View_x = VIEW(%x) token(); | ||
| 3 | + for %loop_idx_37 inrange 0, scalar_expr, 4 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(4) { | ||
| 4 | + if scalar_expr then { | ||
| 5 | + if scalar_expr then { | ||
| 6 | + logical_tensor %$0 = ADDS(%View_x) token(); | ||
| 7 | + logical_tensor %$5 = SUBS(%View_x) token(); | ||
| 8 | + logical_tensor %z = ASSEMBLE(%$5) token(); | ||
| 9 | + logical_tensor %$8 = SUBS(%View_x) token(); | ||
| 10 | + logical_tensor %$12 = SUBS(%View_x) token(); | ||
| 11 | + logical_tensor %z = ASSEMBLE(%$12) token(); | ||
| 12 | + logical_tensor %$15 = SUBS(%View_x) token(); | ||
| 13 | + logical_tensor %$19 = SUBS(%View_x) token(); | ||
| 14 | + logical_tensor %z = ASSEMBLE(%$19) token(); | ||
| 15 | + logical_tensor %$22 = SUBS(%View_x) token(); | ||
| 16 | + logical_tensor %$25 = ADDS(%View_x) token(); | ||
| 17 | + logical_tensor %z = ASSEMBLE(%$25) token(); | ||
| 18 | + yield; | ||
| 19 | + } | ||
| 20 | + else { | ||
| 21 | + logical_tensor %$0_1 = ADDS(%View_x) token(); | ||
| 22 | + logical_tensor %$5_2 = SUBS(%View_x) token(); | ||
| 23 | + logical_tensor %z = ASSEMBLE(%$5_2) token(); | ||
| 24 | + logical_tensor %$8_2 = SUBS(%View_x) token(); | ||
| 25 | + logical_tensor %$12_2 = SUBS(%View_x) token(); | ||
| 26 | + logical_tensor %z = ASSEMBLE(%$12_2) token(); | ||
| 27 | + logical_tensor %$15_2 = SUBS(%View_x) token(); | ||
| 28 | + logical_tensor %$19_2 = SUBS(%View_x) token(); | ||
| 29 | + logical_tensor %z = ASSEMBLE(%$19_2) token(); | ||
| 30 | + logical_tensor %$22_2 = SUBS(%View_x) token(); | ||
| 31 | + logical_tensor %$26 = SUBS(%View_x) token(); | ||
| 32 | + logical_tensor %z = ASSEMBLE(%$26) token(); | ||
| 33 | + yield; | ||
| 34 | + } | ||
| 35 | + yield; | ||
| 36 | + } | ||
| 37 | + else { | ||
| 38 | + if scalar_expr then { | ||
| 39 | + logical_tensor %$1 = SUBS(%View_x) token(); | ||
| 40 | + logical_tensor %$5_5 = SUBS(%View_x) token(); | ||
| 41 | + logical_tensor %z = ASSEMBLE(%$5_5) token(); | ||
| 42 | + logical_tensor %$8_5 = SUBS(%View_x) token(); | ||
| 43 | + logical_tensor %$12_5 = SUBS(%View_x) token(); | ||
| 44 | + logical_tensor %z = ASSEMBLE(%$12_5) token(); | ||
| 45 | + logical_tensor %$15_5 = SUBS(%View_x) token(); | ||
| 46 | + logical_tensor %$19_5 = SUBS(%View_x) token(); | ||
| 47 | + logical_tensor %z = ASSEMBLE(%$19_5) token(); | ||
| 48 | + logical_tensor %$22_5 = SUBS(%View_x) token(); | ||
| 49 | + logical_tensor %$25_0 = ADDS(%View_x) token(); | ||
| 50 | + logical_tensor %z = ASSEMBLE(%$25_0) token(); | ||
| 51 | + yield; | ||
| 52 | + } | ||
| 53 | + else { | ||
| 54 | + logical_tensor %$1_1 = SUBS(%View_x) token(); | ||
| 55 | + logical_tensor %$5_4 = SUBS(%View_x) token(); | ||
| 56 | + logical_tensor %z = ASSEMBLE(%$5_4) token(); | ||
| 57 | + logical_tensor %$8_4 = SUBS(%View_x) token(); | ||
| 58 | + logical_tensor %$12_4 = SUBS(%View_x) token(); | ||
| 59 | + logical_tensor %z = ASSEMBLE(%$12_4) token(); | ||
| 60 | + logical_tensor %$15_4 = SUBS(%View_x) token(); | ||
| 61 | + logical_tensor %$19_4 = SUBS(%View_x) token(); | ||
| 62 | + logical_tensor %z = ASSEMBLE(%$19_4) token(); | ||
| 63 | + logical_tensor %$22_4 = SUBS(%View_x) token(); | ||
| 64 | + logical_tensor %$26_0 = SUBS(%View_x) token(); | ||
| 65 | + logical_tensor %z = ASSEMBLE(%$26_0) token(); | ||
| 66 | + yield; | ||
| 67 | + } | ||
| 68 | + yield; | ||
| 69 | + } | ||
| 70 | + continue; | ||
| 71 | + } | ||
| 72 | + for %loop_idx_37_0 inrange scalar_expr, scalar_expr, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 73 | + if scalar_expr then { | ||
| 74 | + if scalar_expr then { | ||
| 75 | + logical_tensor %$30 = ADDS(%View_x) token(); | ||
| 76 | + logical_tensor %$34 = ADDS(%View_x) token(); | ||
| 77 | + logical_tensor %z = ASSEMBLE(%$34) token(); | ||
| 78 | + yield; | ||
| 79 | + } | ||
| 80 | + else { | ||
| 81 | + logical_tensor %$30_1 = ADDS(%View_x) token(); | ||
| 82 | + logical_tensor %$35 = SUBS(%View_x) token(); | ||
| 83 | + logical_tensor %z = ASSEMBLE(%$35) token(); | ||
| 84 | + yield; | ||
| 85 | + } | ||
| 86 | + yield; | ||
| 87 | + } | ||
| 88 | + else { | ||
| 89 | + if scalar_expr then { | ||
| 90 | + logical_tensor %$31 = SUBS(%View_x) token(); | ||
| 91 | + logical_tensor %$34_0 = ADDS(%View_x) token(); | ||
| 92 | + logical_tensor %z = ASSEMBLE(%$34_0) token(); | ||
| 93 | + yield; | ||
| 94 | + } | ||
| 95 | + else { | ||
| 96 | + logical_tensor %$31_1 = SUBS(%View_x) token(); | ||
| 97 | + logical_tensor %$35_0 = SUBS(%View_x) token(); | ||
| 98 | + logical_tensor %z = ASSEMBLE(%$35_0) token(); | ||
| 99 | + yield; | ||
| 100 | + } | ||
| 101 | + yield; | ||
| 102 | + } | ||
| 103 | + continue; | ||
| 104 | + } | ||
| 105 | + return %x, %y, %z; | ||
| 106 | +} | ||
| @@ -7,23 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor, z@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_merge_returnstmt_barrier.pypto").read_text() |
| 17 | - if (0<n): | ||
| 18 | - $0@3 = ADD(x@0, y@1) | ||
| 19 | - z@2 = ASSEMBLE($0@3, attrs=["toOffset": [0, 0]]) | ||
| 20 | - z = ir.yield_(z@2) | ||
| 21 | - else: | ||
| 22 | - $1@4 = SUB(x@0, y@1) | ||
| 23 | - z@2 = ASSEMBLE($1@4, attrs=["toOffset": [0, 0]]) | ||
| 24 | - z = ir.yield_(z@2) | ||
| 25 | - return x@0, y@1, z@2 | ||
| 26 | -""" # noqa: E501 | ||
| 27 | 19 | ||
| 28 | 20 | ||
| 29 | def test_merge_return_stmt_barrier(): | 21 | def test_merge_return_stmt_barrier(): |
| @@ -0,0 +1,13 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y, logical_tensor %z) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %z = if scalar_expr then { | ||
| 3 | + logical_tensor %$0 = ADD(%x, %y) token(); | ||
| 4 | + logical_tensor %z = ASSEMBLE(%$0) token(); | ||
| 5 | + yield %z; | ||
| 6 | + } | ||
| 7 | + else { | ||
| 8 | + logical_tensor %$1 = SUB(%x, %y) token(); | ||
| 9 | + logical_tensor %z = ASSEMBLE(%$1) token(); | ||
| 10 | + yield %z; | ||
| 11 | + } | ||
| 12 | + return %x, %y, %z; | ||
| 13 | +} | ||
| @@ -7,68 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(a@0: ir.Tensor, b@1: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_oi_update.pypto").read_text() |
| 17 | - for loop_idx_10, (b_1,) in ir.range(0, 10, 1, init_values=(b@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 18 | - for loop_idx_16, (b_3,) in ir.range(0, 10, 1, init_values=(b_1@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 19 | - oi_update_1@2 = TENSOR_ALLOC() | ||
| 20 | - for loop_idx_34, (b_5, oi_update_3) in ir.range(0, (((n-0)/2)*2), 2, init_values=(b_3@1, oi_update_1@2), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 2}): | ||
| 21 | - if (loop_idx_34==0): | ||
| 22 | - if (n<=(loop_idx_34+2)): | ||
| 23 | - oi_update_4@2 = ADDS(a@0) | ||
| 24 | - oi_update_9@2 = SUBS(oi_update_4@2) | ||
| 25 | - $6@9 = DIVS(oi_update_9@2) | ||
| 26 | - b_9@1 = FLOOR($6@9) | ||
| 27 | - oi_update_31, b_11 = ir.yield_(oi_update_9@2, b_9@1) | ||
| 28 | - else: | ||
| 29 | - oi_update_33@2 = ADDS(a@0) | ||
| 30 | - oi_update_35@2 = SUBS(oi_update_33@2) | ||
| 31 | - oi_update_31, b_11 = ir.yield_(oi_update_35@2, b_5@1) | ||
| 32 | - oi_update_27, b_26 = ir.yield_(oi_update_31@2, b_11@1) | ||
| 33 | - else: | ||
| 34 | - if (n<=(loop_idx_34+2)): | ||
| 35 | - oi_update_5@2 = SUBS(oi_update_3@2) | ||
| 36 | - oi_update_45@2 = SUBS(oi_update_5@2) | ||
| 37 | - $6_0@9 = DIVS(oi_update_45@2) | ||
| 38 | - b_30@1 = FLOOR($6_0@9) | ||
| 39 | - oi_update_39, b_28 = ir.yield_(oi_update_45@2, b_30@1) | ||
| 40 | - else: | ||
| 41 | - oi_update_41@2 = SUBS(oi_update_3@2) | ||
| 42 | - oi_update_43@2 = SUBS(oi_update_41@2) | ||
| 43 | - oi_update_39, b_28 = ir.yield_(oi_update_43@2, b_5@1) | ||
| 44 | - oi_update_27, b_26 = ir.yield_(oi_update_39@2, b_28@1) | ||
| 45 | - b_13, oi_update_13 = continue b_26@1, oi_update_27@2 | ||
| 46 | - for loop_idx_34_0, (b_15, oi_update_15) in ir.range((((n-0)/2)*2), n, 1, init_values=(b_13@1, oi_update_13@2), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 47 | - if (loop_idx_34_0==0): | ||
| 48 | - if (n<=(loop_idx_34_0+1)): | ||
| 49 | - oi_update_16@2 = ADDS(a@0) | ||
| 50 | - $10@13 = DIVS(oi_update_16@2) | ||
| 51 | - b_16@1 = FLOOR($10@13) | ||
| 52 | - oi_update_47, b_18 = ir.yield_(oi_update_16@2, b_16@1) | ||
| 53 | - else: | ||
| 54 | - oi_update_49@2 = ADDS(a@0) | ||
| 55 | - oi_update_47, b_18 = ir.yield_(oi_update_49@2, b_15@1) | ||
| 56 | - oi_update_19, b_32 = ir.yield_(oi_update_47@2, b_18@1) | ||
| 57 | - else: | ||
| 58 | - if (n<=(loop_idx_34_0+1)): | ||
| 59 | - oi_update_17@2 = SUBS(oi_update_15@2) | ||
| 60 | - $10_0@13 = DIVS(oi_update_17@2) | ||
| 61 | - b_34@1 = FLOOR($10_0@13) | ||
| 62 | - oi_update_51, b_36 = ir.yield_(oi_update_17@2, b_34@1) | ||
| 63 | - else: | ||
| 64 | - oi_update_53@2 = SUBS(oi_update_15@2) | ||
| 65 | - oi_update_51, b_36 = ir.yield_(oi_update_53@2, b_15@1) | ||
| 66 | - oi_update_19, b_32 = ir.yield_(oi_update_51@2, b_36@1) | ||
| 67 | - b_20, oi_update_21 = continue b_32@1, oi_update_19@2 | ||
| 68 | - b_22 = continue b_20@1 | ||
| 69 | - b_24 = continue b_22@1 | ||
| 70 | - return a@0, b_24@1 | ||
| 71 | -""" # noqa: E501 | ||
| 72 | 19 | ||
| 73 | 20 | ||
| 74 | def test_oi_update(): | 21 | def test_oi_update(): |
| @@ -0,0 +1,72 @@ | |||
| 1 | +function foo incast(logical_tensor %a, logical_tensor %b) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %b_24 = for %loop_idx_10 inrange 0, 10, 1 iter {logical_tensor %b_1 = %b;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + logical_tensor %b_22 = for %loop_idx_16 inrange 0, 10, 1 iter {logical_tensor %b_3 = %b_1;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 4 | + logical_tensor %oi_update_1 = TENSOR_ALLOC() token(); | ||
| 5 | + logical_tensor %b_13, logical_tensor %oi_update_13 = for %loop_idx_34 inrange 0, scalar_expr, 2 iter {logical_tensor %b_5 = %b_3;logical_tensor %oi_update_3 = %oi_update_1;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(2) { | ||
| 6 | + logical_tensor %oi_update_27, logical_tensor %b_26 = if scalar_expr then { | ||
| 7 | + logical_tensor %oi_update_31, logical_tensor %b_11 = if scalar_expr then { | ||
| 8 | + logical_tensor %oi_update_4 = ADDS(%a) token(); | ||
| 9 | + logical_tensor %oi_update_9 = SUBS(%oi_update_4) token(); | ||
| 10 | + logical_tensor %$6 = DIVS(%oi_update_9) token(); | ||
| 11 | + logical_tensor %b_9 = FLOOR(%$6) token(); | ||
| 12 | + yield %oi_update_9, %b_9; | ||
| 13 | + } | ||
| 14 | + else { | ||
| 15 | + logical_tensor %oi_update_33 = ADDS(%a) token(); | ||
| 16 | + logical_tensor %oi_update_35 = SUBS(%oi_update_33) token(); | ||
| 17 | + yield %oi_update_35, %b_5; | ||
| 18 | + } | ||
| 19 | + yield %oi_update_31, %b_11; | ||
| 20 | + } | ||
| 21 | + else { | ||
| 22 | + logical_tensor %oi_update_39, logical_tensor %b_28 = if scalar_expr then { | ||
| 23 | + logical_tensor %oi_update_5 = SUBS(%oi_update_3) token(); | ||
| 24 | + logical_tensor %oi_update_45 = SUBS(%oi_update_5) token(); | ||
| 25 | + logical_tensor %$6_0 = DIVS(%oi_update_45) token(); | ||
| 26 | + logical_tensor %b_30 = FLOOR(%$6_0) token(); | ||
| 27 | + yield %oi_update_45, %b_30; | ||
| 28 | + } | ||
| 29 | + else { | ||
| 30 | + logical_tensor %oi_update_41 = SUBS(%oi_update_3) token(); | ||
| 31 | + logical_tensor %oi_update_43 = SUBS(%oi_update_41) token(); | ||
| 32 | + yield %oi_update_43, %b_5; | ||
| 33 | + } | ||
| 34 | + yield %oi_update_39, %b_28; | ||
| 35 | + } | ||
| 36 | + continue %b_26, %oi_update_27; | ||
| 37 | + } | ||
| 38 | + logical_tensor %b_20, logical_tensor %oi_update_21 = for %loop_idx_34_0 inrange scalar_expr, %n, 1 iter {logical_tensor %b_15 = %b_13;logical_tensor %oi_update_15 = %oi_update_13;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 39 | + logical_tensor %oi_update_19, logical_tensor %b_32 = if scalar_expr then { | ||
| 40 | + logical_tensor %oi_update_47, logical_tensor %b_18 = if scalar_expr then { | ||
| 41 | + logical_tensor %oi_update_16 = ADDS(%a) token(); | ||
| 42 | + logical_tensor %$10 = DIVS(%oi_update_16) token(); | ||
| 43 | + logical_tensor %b_16 = FLOOR(%$10) token(); | ||
| 44 | + yield %oi_update_16, %b_16; | ||
| 45 | + } | ||
| 46 | + else { | ||
| 47 | + logical_tensor %oi_update_49 = ADDS(%a) token(); | ||
| 48 | + yield %oi_update_49, %b_15; | ||
| 49 | + } | ||
| 50 | + yield %oi_update_47, %b_18; | ||
| 51 | + } | ||
| 52 | + else { | ||
| 53 | + logical_tensor %oi_update_51, logical_tensor %b_36 = if scalar_expr then { | ||
| 54 | + logical_tensor %oi_update_17 = SUBS(%oi_update_15) token(); | ||
| 55 | + logical_tensor %$10_0 = DIVS(%oi_update_17) token(); | ||
| 56 | + logical_tensor %b_34 = FLOOR(%$10_0) token(); | ||
| 57 | + yield %oi_update_17, %b_34; | ||
| 58 | + } | ||
| 59 | + else { | ||
| 60 | + logical_tensor %oi_update_53 = SUBS(%oi_update_15) token(); | ||
| 61 | + yield %oi_update_53, %b_15; | ||
| 62 | + } | ||
| 63 | + yield %oi_update_51, %b_36; | ||
| 64 | + } | ||
| 65 | + continue %b_32, %oi_update_19; | ||
| 66 | + } | ||
| 67 | + continue %b_20; | ||
| 68 | + } | ||
| 69 | + continue %b_22; | ||
| 70 | + } | ||
| 71 | + return %a, %b_24; | ||
| 72 | +} | ||
| @@ -7,35 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def kernel(a@0: ir.Tensor, b@1: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_oi_update1.pypto").read_text() |
| 17 | - oi_update@2 = TENSOR_ALLOC() | ||
| 18 | - oi_update1@3 = TENSOR_ALLOC() | ||
| 19 | - for loop_idx_31, (oi_update_2, oi_update_3) in ir.range(0, 10, 1, init_values=(oi_update@2, oi_update1@3), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 20 | - if (loop_idx_31==0): | ||
| 21 | - oi_update_4@2 = ADDS(a@0) | ||
| 22 | - oi_update_22@3 = ADDS(a@0) | ||
| 23 | - oi_update_43, oi_update_44 = ir.yield_(oi_update_4@2, oi_update_22@3) | ||
| 24 | - else: | ||
| 25 | - if (10<=(loop_idx_31+1)): | ||
| 26 | - oi_update_10@2 = ADD(a@0, oi_update_2@2) | ||
| 27 | - b@1 = ASSEMBLE(oi_update_10@2, attrs=["toOffset": [0, 0]]) | ||
| 28 | - oi_update_27@3 = ADD(a@0, oi_update_3@3) | ||
| 29 | - b@1 = ASSEMBLE(oi_update_27@3, attrs=["toOffset": [0, 0]]) | ||
| 30 | - oi_update_49, oi_update_50 = ir.yield_(oi_update_2@2, oi_update_3@3) | ||
| 31 | - else: | ||
| 32 | - oi_update_54@2 = ADD(a@0, oi_update_2@2) | ||
| 33 | - oi_update_46@3 = ADD(a@0, oi_update_3@3) | ||
| 34 | - oi_update_49, oi_update_50 = ir.yield_(oi_update_54@2, oi_update_46@3) | ||
| 35 | - oi_update_43, oi_update_44 = ir.yield_(oi_update_49@2, oi_update_50@3) | ||
| 36 | - oi_update_40, oi_update_41 = continue oi_update_43@2, oi_update_44@3 | ||
| 37 | - return a@0, b@1 | ||
| 38 | -""" # noqa: E501 | ||
| 39 | 19 | ||
| 40 | 20 | ||
| 41 | def test_oi_update1(): | 21 | def test_oi_update1(): |
| @@ -0,0 +1,28 @@ | |||
| 1 | +function kernel incast(logical_tensor %a, logical_tensor %b) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %oi_update = TENSOR_ALLOC() token(); | ||
| 3 | + logical_tensor %oi_update1 = TENSOR_ALLOC() token(); | ||
| 4 | + logical_tensor %oi_update_40, logical_tensor %oi_update_41 = for %loop_idx_31 inrange 0, 10, 1 iter {logical_tensor %oi_update_2 = %oi_update;logical_tensor %oi_update_3 = %oi_update1;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + logical_tensor %oi_update_43, logical_tensor %oi_update_44 = if scalar_expr then { | ||
| 6 | + logical_tensor %oi_update_4 = ADDS(%a) token(); | ||
| 7 | + logical_tensor %oi_update_22 = ADDS(%a) token(); | ||
| 8 | + yield %oi_update_4, %oi_update_22; | ||
| 9 | + } | ||
| 10 | + else { | ||
| 11 | + logical_tensor %oi_update_49, logical_tensor %oi_update_50 = if scalar_expr then { | ||
| 12 | + logical_tensor %oi_update_10 = ADD(%a, %oi_update_2) token(); | ||
| 13 | + logical_tensor %b = ASSEMBLE(%oi_update_10) token(); | ||
| 14 | + logical_tensor %oi_update_27 = ADD(%a, %oi_update_3) token(); | ||
| 15 | + logical_tensor %b = ASSEMBLE(%oi_update_27) token(); | ||
| 16 | + yield %oi_update_2, %oi_update_3; | ||
| 17 | + } | ||
| 18 | + else { | ||
| 19 | + logical_tensor %oi_update_54 = ADD(%a, %oi_update_2) token(); | ||
| 20 | + logical_tensor %oi_update_46 = ADD(%a, %oi_update_3) token(); | ||
| 21 | + yield %oi_update_54, %oi_update_46; | ||
| 22 | + } | ||
| 23 | + yield %oi_update_49, %oi_update_50; | ||
| 24 | + } | ||
| 25 | + continue %oi_update_43, %oi_update_44; | ||
| 26 | + } | ||
| 27 | + return %a, %b; | ||
| 28 | +} | ||
| @@ -6,27 +6,17 @@ | |||
| 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | +from pathlib import Path | ||
| 10 | + | ||
| 9 | import pytest | 11 | import pytest |
| 10 | 12 | ||
| 11 | import pypto | 13 | import pypto |
| 12 | 14 | ||
| 13 | from ..test_common import check_snapshot, run_merge_pass | 15 | from ..test_common import check_snapshot, run_merge_pass |
| 14 | 16 | ||
| 15 | -IR = """ | 17 | +_GOLDEN_DIR = Path(__file__).parent |
| 16 | -@ir.function | 18 | + |
| 17 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor): | 19 | +IR = (_GOLDEN_DIR / "test_type_conflict.pypto").read_text() |
| 18 | - for loop_idx_10, (x_1, y_1) in ir.range(0, 2, 1, init_values=(x@0, y@1), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 19 | - if (loop_idx_10==0): | ||
| 20 | - $0@2 = VEC_DUP() | ||
| 21 | - x_2@0 = ADDS($0@2) | ||
| 22 | - x_4, y_4 = ir.yield_(x_2@0, y_1@1) | ||
| 23 | - else: | ||
| 24 | - $2@4 = VEC_DUP() | ||
| 25 | - y_2@1 = ADDS($2@4) | ||
| 26 | - x_4, y_4 = ir.yield_(x_1@0, y_2@1) | ||
| 27 | - x_6, y_6 = continue x_4@0, y_4@1 | ||
| 28 | - return x_6@0, y_6@1 | ||
| 29 | -""" # noqa: E501 | ||
| 30 | 20 | ||
| 31 | 21 | ||
| 32 | def test_type_conflict(): | 22 | def test_type_conflict(): |
| @@ -0,0 +1,16 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %x_6, logical_tensor %y_6 = for %loop_idx_10 inrange 0, 2, 1 iter {logical_tensor %x_1 = %x;logical_tensor %y_1 = %y;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + logical_tensor %x_4, logical_tensor %y_4 = if scalar_expr then { | ||
| 4 | + logical_tensor %$0 = VEC_DUP() token(); | ||
| 5 | + logical_tensor %x_2 = ADDS(%$0) token(); | ||
| 6 | + yield %x_2, %y_1; | ||
| 7 | + } | ||
| 8 | + else { | ||
| 9 | + logical_tensor %$2 = VEC_DUP() token(); | ||
| 10 | + logical_tensor %y_2 = ADDS(%$2) token(); | ||
| 11 | + yield %x_1, %y_2; | ||
| 12 | + } | ||
| 13 | + continue %x_4, %y_4; | ||
| 14 | + } | ||
| 15 | + return %x_6, %y_6; | ||
| 16 | +} | ||
| @@ -7,321 +7,15 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | 9 | ||
| 10 | +from pathlib import Path | ||
| 11 | + | ||
| 10 | import pypto | 12 | import pypto |
| 11 | 13 | ||
| 12 | from ..test_common import check_snapshot, run_merge_pass | 14 | from ..test_common import check_snapshot, run_merge_pass |
| 13 | 15 | ||
| 14 | -IR = """ | 16 | +_GOLDEN_DIR = Path(__file__).parent |
| 15 | -@ir.function | 17 | + |
| 16 | -def foo(a@0: ir.Tensor, b@1: ir.Tensor, c@2: ir.Tensor): | 18 | +IR = (_GOLDEN_DIR / "test_unroll_list.pypto").read_text() |
| 17 | - for loop_idx_18, (b_1,) in ir.range(0, 10, 1, init_values=(b@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 18 | - for loop_idx_24, (b_3,) in ir.range(0, 10, 1, init_values=(b_1@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 19 | - for loop_idx_30, (b_5,) in ir.range(0, RUNTIME_GetInputShapeDim(ARG_a,1), 1, init_values=(b_3@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 20 | - for loop_idx_54, (b_7,) in ir.range(0, (((((((RUNTIME_GetInputShapeDim(ARG_a,0)-((RUNTIME_GetInputShapeDim(ARG_a,1)-1)-loop_idx_30))+32)-1)/32)-0)/32)*32), 32, init_values=(b_5@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 32}): | ||
| 21 | - if (loop_idx_54==0): | ||
| 22 | - if ((loop_idx_54+31)==(((RUNTIME_GetInputShapeDim(ARG_a,0)+loop_idx_30)-RUNTIME_GetInputShapeDim(ARG_a,1))/32)): | ||
| 23 | - $0@3 = ADDS(c@2) | ||
| 24 | - $1@4 = ADDS($0@3) | ||
| 25 | - $7@8 = ADDS(c@2) | ||
| 26 | - $9@10 = ADDS($7@8) | ||
| 27 | - $14@13 = ADDS(c@2) | ||
| 28 | - $16@15 = ADDS($14@13) | ||
| 29 | - $21@18 = ADDS(c@2) | ||
| 30 | - $23@20 = ADDS($21@18) | ||
| 31 | - $28@23 = ADDS(c@2) | ||
| 32 | - $30@25 = ADDS($28@23) | ||
| 33 | - $35@28 = ADDS(c@2) | ||
| 34 | - $37@30 = ADDS($35@28) | ||
| 35 | - $42@33 = ADDS(c@2) | ||
| 36 | - $44@35 = ADDS($42@33) | ||
| 37 | - $49@38 = ADDS(c@2) | ||
| 38 | - $51@40 = ADDS($49@38) | ||
| 39 | - $56@43 = ADDS(c@2) | ||
| 40 | - $58@45 = ADDS($56@43) | ||
| 41 | - $63@48 = ADDS(c@2) | ||
| 42 | - $65@50 = ADDS($63@48) | ||
| 43 | - $70@53 = ADDS(c@2) | ||
| 44 | - $72@55 = ADDS($70@53) | ||
| 45 | - $77@58 = ADDS(c@2) | ||
| 46 | - $79@60 = ADDS($77@58) | ||
| 47 | - $84@63 = ADDS(c@2) | ||
| 48 | - $86@65 = ADDS($84@63) | ||
| 49 | - $91@68 = ADDS(c@2) | ||
| 50 | - $93@70 = ADDS($91@68) | ||
| 51 | - $98@73 = ADDS(c@2) | ||
| 52 | - $100@75 = ADDS($98@73) | ||
| 53 | - $105@78 = ADDS(c@2) | ||
| 54 | - $107@80 = ADDS($105@78) | ||
| 55 | - $112@83 = ADDS(c@2) | ||
| 56 | - $114@85 = ADDS($112@83) | ||
| 57 | - $119@88 = ADDS(c@2) | ||
| 58 | - $121@90 = ADDS($119@88) | ||
| 59 | - $126@93 = ADDS(c@2) | ||
| 60 | - $128@95 = ADDS($126@93) | ||
| 61 | - $133@98 = ADDS(c@2) | ||
| 62 | - $135@100 = ADDS($133@98) | ||
| 63 | - $140@103 = ADDS(c@2) | ||
| 64 | - $142@105 = ADDS($140@103) | ||
| 65 | - $147@108 = ADDS(c@2) | ||
| 66 | - $149@110 = ADDS($147@108) | ||
| 67 | - $154@113 = ADDS(c@2) | ||
| 68 | - $156@115 = ADDS($154@113) | ||
| 69 | - $161@118 = ADDS(c@2) | ||
| 70 | - $163@120 = ADDS($161@118) | ||
| 71 | - $168@123 = ADDS(c@2) | ||
| 72 | - $170@125 = ADDS($168@123) | ||
| 73 | - $175@128 = ADDS(c@2) | ||
| 74 | - $177@130 = ADDS($175@128) | ||
| 75 | - $182@133 = ADDS(c@2) | ||
| 76 | - $184@135 = ADDS($182@133) | ||
| 77 | - $189@138 = ADDS(c@2) | ||
| 78 | - $191@140 = ADDS($189@138) | ||
| 79 | - $196@143 = ADDS(c@2) | ||
| 80 | - $198@145 = ADDS($196@143) | ||
| 81 | - $203@148 = ADDS(c@2) | ||
| 82 | - $205@150 = ADDS($203@148) | ||
| 83 | - $210@153 = ADDS(c@2) | ||
| 84 | - $212@155 = ADDS($210@153) | ||
| 85 | - $217@158 = ADDS(c@2) | ||
| 86 | - $219@160 = ADDS($217@158) | ||
| 87 | - $221@1 = ADDS($219@160) | ||
| 88 | - b_39 = ir.yield_($221@1) | ||
| 89 | - else: | ||
| 90 | - $0_2@3 = ADDS(c@2) | ||
| 91 | - $1_1@4 = ADDS($0_2@3) | ||
| 92 | - $7_2@8 = ADDS(c@2) | ||
| 93 | - $9_2@10 = ADDS($7_2@8) | ||
| 94 | - $14_2@13 = ADDS(c@2) | ||
| 95 | - $16_2@15 = ADDS($14_2@13) | ||
| 96 | - $21_2@18 = ADDS(c@2) | ||
| 97 | - $23_2@20 = ADDS($21_2@18) | ||
| 98 | - $28_2@23 = ADDS(c@2) | ||
| 99 | - $30_2@25 = ADDS($28_2@23) | ||
| 100 | - $35_2@28 = ADDS(c@2) | ||
| 101 | - $37_2@30 = ADDS($35_2@28) | ||
| 102 | - $42_2@33 = ADDS(c@2) | ||
| 103 | - $44_2@35 = ADDS($42_2@33) | ||
| 104 | - $49_2@38 = ADDS(c@2) | ||
| 105 | - $51_2@40 = ADDS($49_2@38) | ||
| 106 | - $56_2@43 = ADDS(c@2) | ||
| 107 | - $58_2@45 = ADDS($56_2@43) | ||
| 108 | - $63_2@48 = ADDS(c@2) | ||
| 109 | - $65_2@50 = ADDS($63_2@48) | ||
| 110 | - $70_2@53 = ADDS(c@2) | ||
| 111 | - $72_2@55 = ADDS($70_2@53) | ||
| 112 | - $77_2@58 = ADDS(c@2) | ||
| 113 | - $79_2@60 = ADDS($77_2@58) | ||
| 114 | - $84_2@63 = ADDS(c@2) | ||
| 115 | - $86_2@65 = ADDS($84_2@63) | ||
| 116 | - $91_2@68 = ADDS(c@2) | ||
| 117 | - $93_2@70 = ADDS($91_2@68) | ||
| 118 | - $98_2@73 = ADDS(c@2) | ||
| 119 | - $100_2@75 = ADDS($98_2@73) | ||
| 120 | - $105_2@78 = ADDS(c@2) | ||
| 121 | - $107_2@80 = ADDS($105_2@78) | ||
| 122 | - $112_2@83 = ADDS(c@2) | ||
| 123 | - $114_2@85 = ADDS($112_2@83) | ||
| 124 | - $119_2@88 = ADDS(c@2) | ||
| 125 | - $121_2@90 = ADDS($119_2@88) | ||
| 126 | - $126_2@93 = ADDS(c@2) | ||
| 127 | - $128_2@95 = ADDS($126_2@93) | ||
| 128 | - $133_2@98 = ADDS(c@2) | ||
| 129 | - $135_2@100 = ADDS($133_2@98) | ||
| 130 | - $140_2@103 = ADDS(c@2) | ||
| 131 | - $142_2@105 = ADDS($140_2@103) | ||
| 132 | - $147_2@108 = ADDS(c@2) | ||
| 133 | - $149_2@110 = ADDS($147_2@108) | ||
| 134 | - $154_2@113 = ADDS(c@2) | ||
| 135 | - $156_2@115 = ADDS($154_2@113) | ||
| 136 | - $161_2@118 = ADDS(c@2) | ||
| 137 | - $163_2@120 = ADDS($161_2@118) | ||
| 138 | - $168_2@123 = ADDS(c@2) | ||
| 139 | - $170_2@125 = ADDS($168_2@123) | ||
| 140 | - $175_2@128 = ADDS(c@2) | ||
| 141 | - $177_2@130 = ADDS($175_2@128) | ||
| 142 | - $182_2@133 = ADDS(c@2) | ||
| 143 | - $184_2@135 = ADDS($182_2@133) | ||
| 144 | - $189_2@138 = ADDS(c@2) | ||
| 145 | - $191_2@140 = ADDS($189_2@138) | ||
| 146 | - $196_2@143 = ADDS(c@2) | ||
| 147 | - $198_2@145 = ADDS($196_2@143) | ||
| 148 | - $203_2@148 = ADDS(c@2) | ||
| 149 | - $205_2@150 = ADDS($203_2@148) | ||
| 150 | - $210_2@153 = ADDS(c@2) | ||
| 151 | - $212_2@155 = ADDS($210_2@153) | ||
| 152 | - $217_2@158 = ADDS(c@2) | ||
| 153 | - $219_2@160 = ADDS($217_2@158) | ||
| 154 | - $222@162 = ADDS($219_2@160) | ||
| 155 | - b_39 = ir.yield_($222@162) | ||
| 156 | - b_54 = ir.yield_(b_39@1) | ||
| 157 | - else: | ||
| 158 | - if ((loop_idx_54+31)==(((RUNTIME_GetInputShapeDim(ARG_a,0)+loop_idx_30)-RUNTIME_GetInputShapeDim(ARG_a,1))/32)): | ||
| 159 | - $0_5@3 = ADDS(c@2) | ||
| 160 | - $2@5 = ADDS($0_5@3) | ||
| 161 | - $7_5@8 = ADDS(c@2) | ||
| 162 | - $9_5@10 = ADDS($7_5@8) | ||
| 163 | - $14_5@13 = ADDS(c@2) | ||
| 164 | - $16_5@15 = ADDS($14_5@13) | ||
| 165 | - $21_5@18 = ADDS(c@2) | ||
| 166 | - $23_5@20 = ADDS($21_5@18) | ||
| 167 | - $28_5@23 = ADDS(c@2) | ||
| 168 | - $30_5@25 = ADDS($28_5@23) | ||
| 169 | - $35_5@28 = ADDS(c@2) | ||
| 170 | - $37_5@30 = ADDS($35_5@28) | ||
| 171 | - $42_5@33 = ADDS(c@2) | ||
| 172 | - $44_5@35 = ADDS($42_5@33) | ||
| 173 | - $49_5@38 = ADDS(c@2) | ||
| 174 | - $51_5@40 = ADDS($49_5@38) | ||
| 175 | - $56_5@43 = ADDS(c@2) | ||
| 176 | - $58_5@45 = ADDS($56_5@43) | ||
| 177 | - $63_5@48 = ADDS(c@2) | ||
| 178 | - $65_5@50 = ADDS($63_5@48) | ||
| 179 | - $70_5@53 = ADDS(c@2) | ||
| 180 | - $72_5@55 = ADDS($70_5@53) | ||
| 181 | - $77_5@58 = ADDS(c@2) | ||
| 182 | - $79_5@60 = ADDS($77_5@58) | ||
| 183 | - $84_5@63 = ADDS(c@2) | ||
| 184 | - $86_5@65 = ADDS($84_5@63) | ||
| 185 | - $91_5@68 = ADDS(c@2) | ||
| 186 | - $93_5@70 = ADDS($91_5@68) | ||
| 187 | - $98_5@73 = ADDS(c@2) | ||
| 188 | - $100_5@75 = ADDS($98_5@73) | ||
| 189 | - $105_5@78 = ADDS(c@2) | ||
| 190 | - $107_5@80 = ADDS($105_5@78) | ||
| 191 | - $112_5@83 = ADDS(c@2) | ||
| 192 | - $114_5@85 = ADDS($112_5@83) | ||
| 193 | - $119_5@88 = ADDS(c@2) | ||
| 194 | - $121_5@90 = ADDS($119_5@88) | ||
| 195 | - $126_5@93 = ADDS(c@2) | ||
| 196 | - $128_5@95 = ADDS($126_5@93) | ||
| 197 | - $133_5@98 = ADDS(c@2) | ||
| 198 | - $135_5@100 = ADDS($133_5@98) | ||
| 199 | - $140_5@103 = ADDS(c@2) | ||
| 200 | - $142_5@105 = ADDS($140_5@103) | ||
| 201 | - $147_5@108 = ADDS(c@2) | ||
| 202 | - $149_5@110 = ADDS($147_5@108) | ||
| 203 | - $154_5@113 = ADDS(c@2) | ||
| 204 | - $156_5@115 = ADDS($154_5@113) | ||
| 205 | - $161_5@118 = ADDS(c@2) | ||
| 206 | - $163_5@120 = ADDS($161_5@118) | ||
| 207 | - $168_5@123 = ADDS(c@2) | ||
| 208 | - $170_5@125 = ADDS($168_5@123) | ||
| 209 | - $175_5@128 = ADDS(c@2) | ||
| 210 | - $177_5@130 = ADDS($175_5@128) | ||
| 211 | - $182_5@133 = ADDS(c@2) | ||
| 212 | - $184_5@135 = ADDS($182_5@133) | ||
| 213 | - $189_5@138 = ADDS(c@2) | ||
| 214 | - $191_5@140 = ADDS($189_5@138) | ||
| 215 | - $196_5@143 = ADDS(c@2) | ||
| 216 | - $198_5@145 = ADDS($196_5@143) | ||
| 217 | - $203_5@148 = ADDS(c@2) | ||
| 218 | - $205_5@150 = ADDS($203_5@148) | ||
| 219 | - $210_5@153 = ADDS(c@2) | ||
| 220 | - $212_5@155 = ADDS($210_5@153) | ||
| 221 | - $217_5@158 = ADDS(c@2) | ||
| 222 | - $219_5@160 = ADDS($217_5@158) | ||
| 223 | - $221_0@1 = ADDS($219_5@160) | ||
| 224 | - b_57 = ir.yield_($221_0@1) | ||
| 225 | - else: | ||
| 226 | - $0_4@3 = ADDS(c@2) | ||
| 227 | - $2_1@5 = ADDS($0_4@3) | ||
| 228 | - $7_4@8 = ADDS(c@2) | ||
| 229 | - $9_4@10 = ADDS($7_4@8) | ||
| 230 | - $14_4@13 = ADDS(c@2) | ||
| 231 | - $16_4@15 = ADDS($14_4@13) | ||
| 232 | - $21_4@18 = ADDS(c@2) | ||
| 233 | - $23_4@20 = ADDS($21_4@18) | ||
| 234 | - $28_4@23 = ADDS(c@2) | ||
| 235 | - $30_4@25 = ADDS($28_4@23) | ||
| 236 | - $35_4@28 = ADDS(c@2) | ||
| 237 | - $37_4@30 = ADDS($35_4@28) | ||
| 238 | - $42_4@33 = ADDS(c@2) | ||
| 239 | - $44_4@35 = ADDS($42_4@33) | ||
| 240 | - $49_4@38 = ADDS(c@2) | ||
| 241 | - $51_4@40 = ADDS($49_4@38) | ||
| 242 | - $56_4@43 = ADDS(c@2) | ||
| 243 | - $58_4@45 = ADDS($56_4@43) | ||
| 244 | - $63_4@48 = ADDS(c@2) | ||
| 245 | - $65_4@50 = ADDS($63_4@48) | ||
| 246 | - $70_4@53 = ADDS(c@2) | ||
| 247 | - $72_4@55 = ADDS($70_4@53) | ||
| 248 | - $77_4@58 = ADDS(c@2) | ||
| 249 | - $79_4@60 = ADDS($77_4@58) | ||
| 250 | - $84_4@63 = ADDS(c@2) | ||
| 251 | - $86_4@65 = ADDS($84_4@63) | ||
| 252 | - $91_4@68 = ADDS(c@2) | ||
| 253 | - $93_4@70 = ADDS($91_4@68) | ||
| 254 | - $98_4@73 = ADDS(c@2) | ||
| 255 | - $100_4@75 = ADDS($98_4@73) | ||
| 256 | - $105_4@78 = ADDS(c@2) | ||
| 257 | - $107_4@80 = ADDS($105_4@78) | ||
| 258 | - $112_4@83 = ADDS(c@2) | ||
| 259 | - $114_4@85 = ADDS($112_4@83) | ||
| 260 | - $119_4@88 = ADDS(c@2) | ||
| 261 | - $121_4@90 = ADDS($119_4@88) | ||
| 262 | - $126_4@93 = ADDS(c@2) | ||
| 263 | - $128_4@95 = ADDS($126_4@93) | ||
| 264 | - $133_4@98 = ADDS(c@2) | ||
| 265 | - $135_4@100 = ADDS($133_4@98) | ||
| 266 | - $140_4@103 = ADDS(c@2) | ||
| 267 | - $142_4@105 = ADDS($140_4@103) | ||
| 268 | - $147_4@108 = ADDS(c@2) | ||
| 269 | - $149_4@110 = ADDS($147_4@108) | ||
| 270 | - $154_4@113 = ADDS(c@2) | ||
| 271 | - $156_4@115 = ADDS($154_4@113) | ||
| 272 | - $161_4@118 = ADDS(c@2) | ||
| 273 | - $163_4@120 = ADDS($161_4@118) | ||
| 274 | - $168_4@123 = ADDS(c@2) | ||
| 275 | - $170_4@125 = ADDS($168_4@123) | ||
| 276 | - $175_4@128 = ADDS(c@2) | ||
| 277 | - $177_4@130 = ADDS($175_4@128) | ||
| 278 | - $182_4@133 = ADDS(c@2) | ||
| 279 | - $184_4@135 = ADDS($182_4@133) | ||
| 280 | - $189_4@138 = ADDS(c@2) | ||
| 281 | - $191_4@140 = ADDS($189_4@138) | ||
| 282 | - $196_4@143 = ADDS(c@2) | ||
| 283 | - $198_4@145 = ADDS($196_4@143) | ||
| 284 | - $203_4@148 = ADDS(c@2) | ||
| 285 | - $205_4@150 = ADDS($203_4@148) | ||
| 286 | - $210_4@153 = ADDS(c@2) | ||
| 287 | - $212_4@155 = ADDS($210_4@153) | ||
| 288 | - $217_4@158 = ADDS(c@2) | ||
| 289 | - $219_4@160 = ADDS($217_4@158) | ||
| 290 | - $222_0@162 = ADDS($219_4@160) | ||
| 291 | - b_57 = ir.yield_($222_0@162) | ||
| 292 | - b_54 = ir.yield_(b_57@1) | ||
| 293 | - b_41 = continue b_54@1 | ||
| 294 | - for loop_idx_54_0, (b_43,) in ir.range((((((((RUNTIME_GetInputShapeDim(ARG_a,0)-((RUNTIME_GetInputShapeDim(ARG_a,1)-1)-loop_idx_30))+32)-1)/32)-0)/32)*32), ((((RUNTIME_GetInputShapeDim(ARG_a,0)-((RUNTIME_GetInputShapeDim(ARG_a,1)-1)-loop_idx_30))+32)-1)/32), 1, init_values=(b_41@1,), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 295 | - if (loop_idx_54_0==0): | ||
| 296 | - if (loop_idx_54_0==(((RUNTIME_GetInputShapeDim(ARG_a,0)+loop_idx_30)-RUNTIME_GetInputShapeDim(ARG_a,1))/32)): | ||
| 297 | - $224@163 = ADDS(c@2) | ||
| 298 | - $225@164 = ADDS($224@163) | ||
| 299 | - $228@1 = ADDS($225@164) | ||
| 300 | - b_44 = ir.yield_($228@1) | ||
| 301 | - else: | ||
| 302 | - $224_2@163 = ADDS(c@2) | ||
| 303 | - $225_1@164 = ADDS($224_2@163) | ||
| 304 | - $229@167 = ADDS($225_1@164) | ||
| 305 | - b_44 = ir.yield_($229@167) | ||
| 306 | - b_59 = ir.yield_(b_44@1) | ||
| 307 | - else: | ||
| 308 | - if (loop_idx_54_0==(((RUNTIME_GetInputShapeDim(ARG_a,0)+loop_idx_30)-RUNTIME_GetInputShapeDim(ARG_a,1))/32)): | ||
| 309 | - $224_5@163 = ADDS(c@2) | ||
| 310 | - $226@165 = ADDS($224_5@163) | ||
| 311 | - $228_0@1 = ADDS($226@165) | ||
| 312 | - b_62 = ir.yield_($228_0@1) | ||
| 313 | - else: | ||
| 314 | - $224_4@163 = ADDS(c@2) | ||
| 315 | - $226_1@165 = ADDS($224_4@163) | ||
| 316 | - $229_0@167 = ADDS($226_1@165) | ||
| 317 | - b_62 = ir.yield_($229_0@167) | ||
| 318 | - b_59 = ir.yield_(b_62@1) | ||
| 319 | - b_46 = continue b_59@1 | ||
| 320 | - b_48 = continue b_46@1 | ||
| 321 | - b_50 = continue b_48@1 | ||
| 322 | - b_52 = continue b_50@1 | ||
| 323 | - return a@0, b_52@1, c@2 | ||
| 324 | -""" # noqa: E501 | ||
| 325 | 19 | ||
| 326 | 20 | ||
| 327 | def test_unroll_list(): | 21 | def test_unroll_list(): |
| @@ -0,0 +1,326 @@ | |||
| 1 | +function foo incast(logical_tensor %a, logical_tensor %b, logical_tensor %c) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %b_52 = for %loop_idx_18 inrange 0, 10, 1 iter {logical_tensor %b_1 = %b;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + logical_tensor %b_50 = for %loop_idx_24 inrange 0, 10, 1 iter {logical_tensor %b_3 = %b_1;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 4 | + logical_tensor %b_48 = for %loop_idx_30 inrange 0, scalar_expr, 1 iter {logical_tensor %b_5 = %b_3;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + logical_tensor %b_41 = for %loop_idx_54 inrange 0, scalar_expr, 32 iter {logical_tensor %b_7 = %b_5;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(32) { | ||
| 6 | + logical_tensor %b_54 = if scalar_expr then { | ||
| 7 | + logical_tensor %b_39 = if scalar_expr then { | ||
| 8 | + logical_tensor %$0 = ADDS(%c) token(); | ||
| 9 | + logical_tensor %$1 = ADDS(%$0) token(); | ||
| 10 | + logical_tensor %$7 = ADDS(%c) token(); | ||
| 11 | + logical_tensor %$9 = ADDS(%$7) token(); | ||
| 12 | + logical_tensor %$14 = ADDS(%c) token(); | ||
| 13 | + logical_tensor %$16 = ADDS(%$14) token(); | ||
| 14 | + logical_tensor %$21 = ADDS(%c) token(); | ||
| 15 | + logical_tensor %$23 = ADDS(%$21) token(); | ||
| 16 | + logical_tensor %$28 = ADDS(%c) token(); | ||
| 17 | + logical_tensor %$30 = ADDS(%$28) token(); | ||
| 18 | + logical_tensor %$35 = ADDS(%c) token(); | ||
| 19 | + logical_tensor %$37 = ADDS(%$35) token(); | ||
| 20 | + logical_tensor %$42 = ADDS(%c) token(); | ||
| 21 | + logical_tensor %$44 = ADDS(%$42) token(); | ||
| 22 | + logical_tensor %$49 = ADDS(%c) token(); | ||
| 23 | + logical_tensor %$51 = ADDS(%$49) token(); | ||
| 24 | + logical_tensor %$56 = ADDS(%c) token(); | ||
| 25 | + logical_tensor %$58 = ADDS(%$56) token(); | ||
| 26 | + logical_tensor %$63 = ADDS(%c) token(); | ||
| 27 | + logical_tensor %$65 = ADDS(%$63) token(); | ||
| 28 | + logical_tensor %$70 = ADDS(%c) token(); | ||
| 29 | + logical_tensor %$72 = ADDS(%$70) token(); | ||
| 30 | + logical_tensor %$77 = ADDS(%c) token(); | ||
| 31 | + logical_tensor %$79 = ADDS(%$77) token(); | ||
| 32 | + logical_tensor %$84 = ADDS(%c) token(); | ||
| 33 | + logical_tensor %$86 = ADDS(%$84) token(); | ||
| 34 | + logical_tensor %$91 = ADDS(%c) token(); | ||
| 35 | + logical_tensor %$93 = ADDS(%$91) token(); | ||
| 36 | + logical_tensor %$98 = ADDS(%c) token(); | ||
| 37 | + logical_tensor %$100 = ADDS(%$98) token(); | ||
| 38 | + logical_tensor %$105 = ADDS(%c) token(); | ||
| 39 | + logical_tensor %$107 = ADDS(%$105) token(); | ||
| 40 | + logical_tensor %$112 = ADDS(%c) token(); | ||
| 41 | + logical_tensor %$114 = ADDS(%$112) token(); | ||
| 42 | + logical_tensor %$119 = ADDS(%c) token(); | ||
| 43 | + logical_tensor %$121 = ADDS(%$119) token(); | ||
| 44 | + logical_tensor %$126 = ADDS(%c) token(); | ||
| 45 | + logical_tensor %$128 = ADDS(%$126) token(); | ||
| 46 | + logical_tensor %$133 = ADDS(%c) token(); | ||
| 47 | + logical_tensor %$135 = ADDS(%$133) token(); | ||
| 48 | + logical_tensor %$140 = ADDS(%c) token(); | ||
| 49 | + logical_tensor %$142 = ADDS(%$140) token(); | ||
| 50 | + logical_tensor %$147 = ADDS(%c) token(); | ||
| 51 | + logical_tensor %$149 = ADDS(%$147) token(); | ||
| 52 | + logical_tensor %$154 = ADDS(%c) token(); | ||
| 53 | + logical_tensor %$156 = ADDS(%$154) token(); | ||
| 54 | + logical_tensor %$161 = ADDS(%c) token(); | ||
| 55 | + logical_tensor %$163 = ADDS(%$161) token(); | ||
| 56 | + logical_tensor %$168 = ADDS(%c) token(); | ||
| 57 | + logical_tensor %$170 = ADDS(%$168) token(); | ||
| 58 | + logical_tensor %$175 = ADDS(%c) token(); | ||
| 59 | + logical_tensor %$177 = ADDS(%$175) token(); | ||
| 60 | + logical_tensor %$182 = ADDS(%c) token(); | ||
| 61 | + logical_tensor %$184 = ADDS(%$182) token(); | ||
| 62 | + logical_tensor %$189 = ADDS(%c) token(); | ||
| 63 | + logical_tensor %$191 = ADDS(%$189) token(); | ||
| 64 | + logical_tensor %$196 = ADDS(%c) token(); | ||
| 65 | + logical_tensor %$198 = ADDS(%$196) token(); | ||
| 66 | + logical_tensor %$203 = ADDS(%c) token(); | ||
| 67 | + logical_tensor %$205 = ADDS(%$203) token(); | ||
| 68 | + logical_tensor %$210 = ADDS(%c) token(); | ||
| 69 | + logical_tensor %$212 = ADDS(%$210) token(); | ||
| 70 | + logical_tensor %$217 = ADDS(%c) token(); | ||
| 71 | + logical_tensor %$219 = ADDS(%$217) token(); | ||
| 72 | + logical_tensor %$221 = ADDS(%$219) token(); | ||
| 73 | + yield %$221; | ||
| 74 | + } | ||
| 75 | + else { | ||
| 76 | + logical_tensor %$0_2 = ADDS(%c) token(); | ||
| 77 | + logical_tensor %$1_1 = ADDS(%$0_2) token(); | ||
| 78 | + logical_tensor %$7_2 = ADDS(%c) token(); | ||
| 79 | + logical_tensor %$9_2 = ADDS(%$7_2) token(); | ||
| 80 | + logical_tensor %$14_2 = ADDS(%c) token(); | ||
| 81 | + logical_tensor %$16_2 = ADDS(%$14_2) token(); | ||
| 82 | + logical_tensor %$21_2 = ADDS(%c) token(); | ||
| 83 | + logical_tensor %$23_2 = ADDS(%$21_2) token(); | ||
| 84 | + logical_tensor %$28_2 = ADDS(%c) token(); | ||
| 85 | + logical_tensor %$30_2 = ADDS(%$28_2) token(); | ||
| 86 | + logical_tensor %$35_2 = ADDS(%c) token(); | ||
| 87 | + logical_tensor %$37_2 = ADDS(%$35_2) token(); | ||
| 88 | + logical_tensor %$42_2 = ADDS(%c) token(); | ||
| 89 | + logical_tensor %$44_2 = ADDS(%$42_2) token(); | ||
| 90 | + logical_tensor %$49_2 = ADDS(%c) token(); | ||
| 91 | + logical_tensor %$51_2 = ADDS(%$49_2) token(); | ||
| 92 | + logical_tensor %$56_2 = ADDS(%c) token(); | ||
| 93 | + logical_tensor %$58_2 = ADDS(%$56_2) token(); | ||
| 94 | + logical_tensor %$63_2 = ADDS(%c) token(); | ||
| 95 | + logical_tensor %$65_2 = ADDS(%$63_2) token(); | ||
| 96 | + logical_tensor %$70_2 = ADDS(%c) token(); | ||
| 97 | + logical_tensor %$72_2 = ADDS(%$70_2) token(); | ||
| 98 | + logical_tensor %$77_2 = ADDS(%c) token(); | ||
| 99 | + logical_tensor %$79_2 = ADDS(%$77_2) token(); | ||
| 100 | + logical_tensor %$84_2 = ADDS(%c) token(); | ||
| 101 | + logical_tensor %$86_2 = ADDS(%$84_2) token(); | ||
| 102 | + logical_tensor %$91_2 = ADDS(%c) token(); | ||
| 103 | + logical_tensor %$93_2 = ADDS(%$91_2) token(); | ||
| 104 | + logical_tensor %$98_2 = ADDS(%c) token(); | ||
| 105 | + logical_tensor %$100_2 = ADDS(%$98_2) token(); | ||
| 106 | + logical_tensor %$105_2 = ADDS(%c) token(); | ||
| 107 | + logical_tensor %$107_2 = ADDS(%$105_2) token(); | ||
| 108 | + logical_tensor %$112_2 = ADDS(%c) token(); | ||
| 109 | + logical_tensor %$114_2 = ADDS(%$112_2) token(); | ||
| 110 | + logical_tensor %$119_2 = ADDS(%c) token(); | ||
| 111 | + logical_tensor %$121_2 = ADDS(%$119_2) token(); | ||
| 112 | + logical_tensor %$126_2 = ADDS(%c) token(); | ||
| 113 | + logical_tensor %$128_2 = ADDS(%$126_2) token(); | ||
| 114 | + logical_tensor %$133_2 = ADDS(%c) token(); | ||
| 115 | + logical_tensor %$135_2 = ADDS(%$133_2) token(); | ||
| 116 | + logical_tensor %$140_2 = ADDS(%c) token(); | ||
| 117 | + logical_tensor %$142_2 = ADDS(%$140_2) token(); | ||
| 118 | + logical_tensor %$147_2 = ADDS(%c) token(); | ||
| 119 | + logical_tensor %$149_2 = ADDS(%$147_2) token(); | ||
| 120 | + logical_tensor %$154_2 = ADDS(%c) token(); | ||
| 121 | + logical_tensor %$156_2 = ADDS(%$154_2) token(); | ||
| 122 | + logical_tensor %$161_2 = ADDS(%c) token(); | ||
| 123 | + logical_tensor %$163_2 = ADDS(%$161_2) token(); | ||
| 124 | + logical_tensor %$168_2 = ADDS(%c) token(); | ||
| 125 | + logical_tensor %$170_2 = ADDS(%$168_2) token(); | ||
| 126 | + logical_tensor %$175_2 = ADDS(%c) token(); | ||
| 127 | + logical_tensor %$177_2 = ADDS(%$175_2) token(); | ||
| 128 | + logical_tensor %$182_2 = ADDS(%c) token(); | ||
| 129 | + logical_tensor %$184_2 = ADDS(%$182_2) token(); | ||
| 130 | + logical_tensor %$189_2 = ADDS(%c) token(); | ||
| 131 | + logical_tensor %$191_2 = ADDS(%$189_2) token(); | ||
| 132 | + logical_tensor %$196_2 = ADDS(%c) token(); | ||
| 133 | + logical_tensor %$198_2 = ADDS(%$196_2) token(); | ||
| 134 | + logical_tensor %$203_2 = ADDS(%c) token(); | ||
| 135 | + logical_tensor %$205_2 = ADDS(%$203_2) token(); | ||
| 136 | + logical_tensor %$210_2 = ADDS(%c) token(); | ||
| 137 | + logical_tensor %$212_2 = ADDS(%$210_2) token(); | ||
| 138 | + logical_tensor %$217_2 = ADDS(%c) token(); | ||
| 139 | + logical_tensor %$219_2 = ADDS(%$217_2) token(); | ||
| 140 | + logical_tensor %$222 = ADDS(%$219_2) token(); | ||
| 141 | + yield %$222; | ||
| 142 | + } | ||
| 143 | + yield %b_39; | ||
| 144 | + } | ||
| 145 | + else { | ||
| 146 | + logical_tensor %b_57 = if scalar_expr then { | ||
| 147 | + logical_tensor %$0_5 = ADDS(%c) token(); | ||
| 148 | + logical_tensor %$2 = ADDS(%$0_5) token(); | ||
| 149 | + logical_tensor %$7_5 = ADDS(%c) token(); | ||
| 150 | + logical_tensor %$9_5 = ADDS(%$7_5) token(); | ||
| 151 | + logical_tensor %$14_5 = ADDS(%c) token(); | ||
| 152 | + logical_tensor %$16_5 = ADDS(%$14_5) token(); | ||
| 153 | + logical_tensor %$21_5 = ADDS(%c) token(); | ||
| 154 | + logical_tensor %$23_5 = ADDS(%$21_5) token(); | ||
| 155 | + logical_tensor %$28_5 = ADDS(%c) token(); | ||
| 156 | + logical_tensor %$30_5 = ADDS(%$28_5) token(); | ||
| 157 | + logical_tensor %$35_5 = ADDS(%c) token(); | ||
| 158 | + logical_tensor %$37_5 = ADDS(%$35_5) token(); | ||
| 159 | + logical_tensor %$42_5 = ADDS(%c) token(); | ||
| 160 | + logical_tensor %$44_5 = ADDS(%$42_5) token(); | ||
| 161 | + logical_tensor %$49_5 = ADDS(%c) token(); | ||
| 162 | + logical_tensor %$51_5 = ADDS(%$49_5) token(); | ||
| 163 | + logical_tensor %$56_5 = ADDS(%c) token(); | ||
| 164 | + logical_tensor %$58_5 = ADDS(%$56_5) token(); | ||
| 165 | + logical_tensor %$63_5 = ADDS(%c) token(); | ||
| 166 | + logical_tensor %$65_5 = ADDS(%$63_5) token(); | ||
| 167 | + logical_tensor %$70_5 = ADDS(%c) token(); | ||
| 168 | + logical_tensor %$72_5 = ADDS(%$70_5) token(); | ||
| 169 | + logical_tensor %$77_5 = ADDS(%c) token(); | ||
| 170 | + logical_tensor %$79_5 = ADDS(%$77_5) token(); | ||
| 171 | + logical_tensor %$84_5 = ADDS(%c) token(); | ||
| 172 | + logical_tensor %$86_5 = ADDS(%$84_5) token(); | ||
| 173 | + logical_tensor %$91_5 = ADDS(%c) token(); | ||
| 174 | + logical_tensor %$93_5 = ADDS(%$91_5) token(); | ||
| 175 | + logical_tensor %$98_5 = ADDS(%c) token(); | ||
| 176 | + logical_tensor %$100_5 = ADDS(%$98_5) token(); | ||
| 177 | + logical_tensor %$105_5 = ADDS(%c) token(); | ||
| 178 | + logical_tensor %$107_5 = ADDS(%$105_5) token(); | ||
| 179 | + logical_tensor %$112_5 = ADDS(%c) token(); | ||
| 180 | + logical_tensor %$114_5 = ADDS(%$112_5) token(); | ||
| 181 | + logical_tensor %$119_5 = ADDS(%c) token(); | ||
| 182 | + logical_tensor %$121_5 = ADDS(%$119_5) token(); | ||
| 183 | + logical_tensor %$126_5 = ADDS(%c) token(); | ||
| 184 | + logical_tensor %$128_5 = ADDS(%$126_5) token(); | ||
| 185 | + logical_tensor %$133_5 = ADDS(%c) token(); | ||
| 186 | + logical_tensor %$135_5 = ADDS(%$133_5) token(); | ||
| 187 | + logical_tensor %$140_5 = ADDS(%c) token(); | ||
| 188 | + logical_tensor %$142_5 = ADDS(%$140_5) token(); | ||
| 189 | + logical_tensor %$147_5 = ADDS(%c) token(); | ||
| 190 | + logical_tensor %$149_5 = ADDS(%$147_5) token(); | ||
| 191 | + logical_tensor %$154_5 = ADDS(%c) token(); | ||
| 192 | + logical_tensor %$156_5 = ADDS(%$154_5) token(); | ||
| 193 | + logical_tensor %$161_5 = ADDS(%c) token(); | ||
| 194 | + logical_tensor %$163_5 = ADDS(%$161_5) token(); | ||
| 195 | + logical_tensor %$168_5 = ADDS(%c) token(); | ||
| 196 | + logical_tensor %$170_5 = ADDS(%$168_5) token(); | ||
| 197 | + logical_tensor %$175_5 = ADDS(%c) token(); | ||
| 198 | + logical_tensor %$177_5 = ADDS(%$175_5) token(); | ||
| 199 | + logical_tensor %$182_5 = ADDS(%c) token(); | ||
| 200 | + logical_tensor %$184_5 = ADDS(%$182_5) token(); | ||
| 201 | + logical_tensor %$189_5 = ADDS(%c) token(); | ||
| 202 | + logical_tensor %$191_5 = ADDS(%$189_5) token(); | ||
| 203 | + logical_tensor %$196_5 = ADDS(%c) token(); | ||
| 204 | + logical_tensor %$198_5 = ADDS(%$196_5) token(); | ||
| 205 | + logical_tensor %$203_5 = ADDS(%c) token(); | ||
| 206 | + logical_tensor %$205_5 = ADDS(%$203_5) token(); | ||
| 207 | + logical_tensor %$210_5 = ADDS(%c) token(); | ||
| 208 | + logical_tensor %$212_5 = ADDS(%$210_5) token(); | ||
| 209 | + logical_tensor %$217_5 = ADDS(%c) token(); | ||
| 210 | + logical_tensor %$219_5 = ADDS(%$217_5) token(); | ||
| 211 | + logical_tensor %$221_0 = ADDS(%$219_5) token(); | ||
| 212 | + yield %$221_0; | ||
| 213 | + } | ||
| 214 | + else { | ||
| 215 | + logical_tensor %$0_4 = ADDS(%c) token(); | ||
| 216 | + logical_tensor %$2_1 = ADDS(%$0_4) token(); | ||
| 217 | + logical_tensor %$7_4 = ADDS(%c) token(); | ||
| 218 | + logical_tensor %$9_4 = ADDS(%$7_4) token(); | ||
| 219 | + logical_tensor %$14_4 = ADDS(%c) token(); | ||
| 220 | + logical_tensor %$16_4 = ADDS(%$14_4) token(); | ||
| 221 | + logical_tensor %$21_4 = ADDS(%c) token(); | ||
| 222 | + logical_tensor %$23_4 = ADDS(%$21_4) token(); | ||
| 223 | + logical_tensor %$28_4 = ADDS(%c) token(); | ||
| 224 | + logical_tensor %$30_4 = ADDS(%$28_4) token(); | ||
| 225 | + logical_tensor %$35_4 = ADDS(%c) token(); | ||
| 226 | + logical_tensor %$37_4 = ADDS(%$35_4) token(); | ||
| 227 | + logical_tensor %$42_4 = ADDS(%c) token(); | ||
| 228 | + logical_tensor %$44_4 = ADDS(%$42_4) token(); | ||
| 229 | + logical_tensor %$49_4 = ADDS(%c) token(); | ||
| 230 | + logical_tensor %$51_4 = ADDS(%$49_4) token(); | ||
| 231 | + logical_tensor %$56_4 = ADDS(%c) token(); | ||
| 232 | + logical_tensor %$58_4 = ADDS(%$56_4) token(); | ||
| 233 | + logical_tensor %$63_4 = ADDS(%c) token(); | ||
| 234 | + logical_tensor %$65_4 = ADDS(%$63_4) token(); | ||
| 235 | + logical_tensor %$70_4 = ADDS(%c) token(); | ||
| 236 | + logical_tensor %$72_4 = ADDS(%$70_4) token(); | ||
| 237 | + logical_tensor %$77_4 = ADDS(%c) token(); | ||
| 238 | + logical_tensor %$79_4 = ADDS(%$77_4) token(); | ||
| 239 | + logical_tensor %$84_4 = ADDS(%c) token(); | ||
| 240 | + logical_tensor %$86_4 = ADDS(%$84_4) token(); | ||
| 241 | + logical_tensor %$91_4 = ADDS(%c) token(); | ||
| 242 | + logical_tensor %$93_4 = ADDS(%$91_4) token(); | ||
| 243 | + logical_tensor %$98_4 = ADDS(%c) token(); | ||
| 244 | + logical_tensor %$100_4 = ADDS(%$98_4) token(); | ||
| 245 | + logical_tensor %$105_4 = ADDS(%c) token(); | ||
| 246 | + logical_tensor %$107_4 = ADDS(%$105_4) token(); | ||
| 247 | + logical_tensor %$112_4 = ADDS(%c) token(); | ||
| 248 | + logical_tensor %$114_4 = ADDS(%$112_4) token(); | ||
| 249 | + logical_tensor %$119_4 = ADDS(%c) token(); | ||
| 250 | + logical_tensor %$121_4 = ADDS(%$119_4) token(); | ||
| 251 | + logical_tensor %$126_4 = ADDS(%c) token(); | ||
| 252 | + logical_tensor %$128_4 = ADDS(%$126_4) token(); | ||
| 253 | + logical_tensor %$133_4 = ADDS(%c) token(); | ||
| 254 | + logical_tensor %$135_4 = ADDS(%$133_4) token(); | ||
| 255 | + logical_tensor %$140_4 = ADDS(%c) token(); | ||
| 256 | + logical_tensor %$142_4 = ADDS(%$140_4) token(); | ||
| 257 | + logical_tensor %$147_4 = ADDS(%c) token(); | ||
| 258 | + logical_tensor %$149_4 = ADDS(%$147_4) token(); | ||
| 259 | + logical_tensor %$154_4 = ADDS(%c) token(); | ||
| 260 | + logical_tensor %$156_4 = ADDS(%$154_4) token(); | ||
| 261 | + logical_tensor %$161_4 = ADDS(%c) token(); | ||
| 262 | + logical_tensor %$163_4 = ADDS(%$161_4) token(); | ||
| 263 | + logical_tensor %$168_4 = ADDS(%c) token(); | ||
| 264 | + logical_tensor %$170_4 = ADDS(%$168_4) token(); | ||
| 265 | + logical_tensor %$175_4 = ADDS(%c) token(); | ||
| 266 | + logical_tensor %$177_4 = ADDS(%$175_4) token(); | ||
| 267 | + logical_tensor %$182_4 = ADDS(%c) token(); | ||
| 268 | + logical_tensor %$184_4 = ADDS(%$182_4) token(); | ||
| 269 | + logical_tensor %$189_4 = ADDS(%c) token(); | ||
| 270 | + logical_tensor %$191_4 = ADDS(%$189_4) token(); | ||
| 271 | + logical_tensor %$196_4 = ADDS(%c) token(); | ||
| 272 | + logical_tensor %$198_4 = ADDS(%$196_4) token(); | ||
| 273 | + logical_tensor %$203_4 = ADDS(%c) token(); | ||
| 274 | + logical_tensor %$205_4 = ADDS(%$203_4) token(); | ||
| 275 | + logical_tensor %$210_4 = ADDS(%c) token(); | ||
| 276 | + logical_tensor %$212_4 = ADDS(%$210_4) token(); | ||
| 277 | + logical_tensor %$217_4 = ADDS(%c) token(); | ||
| 278 | + logical_tensor %$219_4 = ADDS(%$217_4) token(); | ||
| 279 | + logical_tensor %$222_0 = ADDS(%$219_4) token(); | ||
| 280 | + yield %$222_0; | ||
| 281 | + } | ||
| 282 | + yield %b_57; | ||
| 283 | + } | ||
| 284 | + continue %b_54; | ||
| 285 | + } | ||
| 286 | + logical_tensor %b_46 = for %loop_idx_54_0 inrange scalar_expr, scalar_expr, 1 iter {logical_tensor %b_43 = %b_41;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 287 | + logical_tensor %b_59 = if scalar_expr then { | ||
| 288 | + logical_tensor %b_44 = if scalar_expr then { | ||
| 289 | + logical_tensor %$224 = ADDS(%c) token(); | ||
| 290 | + logical_tensor %$225 = ADDS(%$224) token(); | ||
| 291 | + logical_tensor %$228 = ADDS(%$225) token(); | ||
| 292 | + yield %$228; | ||
| 293 | + } | ||
| 294 | + else { | ||
| 295 | + logical_tensor %$224_2 = ADDS(%c) token(); | ||
| 296 | + logical_tensor %$225_1 = ADDS(%$224_2) token(); | ||
| 297 | + logical_tensor %$229 = ADDS(%$225_1) token(); | ||
| 298 | + yield %$229; | ||
| 299 | + } | ||
| 300 | + yield %b_44; | ||
| 301 | + } | ||
| 302 | + else { | ||
| 303 | + logical_tensor %b_62 = if scalar_expr then { | ||
| 304 | + logical_tensor %$224_5 = ADDS(%c) token(); | ||
| 305 | + logical_tensor %$226 = ADDS(%$224_5) token(); | ||
| 306 | + logical_tensor %$228_0 = ADDS(%$226) token(); | ||
| 307 | + yield %$228_0; | ||
| 308 | + } | ||
| 309 | + else { | ||
| 310 | + logical_tensor %$224_4 = ADDS(%c) token(); | ||
| 311 | + logical_tensor %$226_1 = ADDS(%$224_4) token(); | ||
| 312 | + logical_tensor %$229_0 = ADDS(%$226_1) token(); | ||
| 313 | + yield %$229_0; | ||
| 314 | + } | ||
| 315 | + yield %b_62; | ||
| 316 | + } | ||
| 317 | + continue %b_59; | ||
| 318 | + } | ||
| 319 | + continue %b_46; | ||
| 320 | + } | ||
| 321 | + continue %b_48; | ||
| 322 | + } | ||
| 323 | + continue %b_50; | ||
| 324 | + } | ||
| 325 | + return %a, %b_52, %c; | ||
| 326 | +} | ||
| @@ -6,23 +6,15 @@ | |||
| 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | +from pathlib import Path | ||
| 10 | + | ||
| 9 | import pypto | 11 | import pypto |
| 10 | 12 | ||
| 11 | from ..test_common import check_snapshot, run_merge_pass | 13 | from ..test_common import check_snapshot, run_merge_pass |
| 12 | 14 | ||
| 13 | -IR = """ | 15 | +_GOLDEN_DIR = Path(__file__).parent |
| 14 | -@ir.function | 16 | + |
| 15 | -def foo(x@0: ir.Tensor, y@1: ir.Tensor): | 17 | +IR = (_GOLDEN_DIR / "test_yield_scalar.pypto").read_text() |
| 16 | - for loop_idx_5 in ir.range(0, 10, 1, attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 17 | - if (loop_idx_5==0): | ||
| 18 | - y@1 = ASSEMBLE(x@0, attrs=["toOffset": [32, 32]]) | ||
| 19 | - ir.yield_() | ||
| 20 | - else: | ||
| 21 | - y@1 = ASSEMBLE(x@0, attrs=["toOffset": [64, 64]]) | ||
| 22 | - ir.yield_() | ||
| 23 | - continue | ||
| 24 | - return x@0, y@1 | ||
| 25 | -""" | ||
| 26 | 18 | ||
| 27 | def test_yield_symbolic_scalar(): | 19 | def test_yield_symbolic_scalar(): |
| 28 | def foo(x, y): | 20 | def foo(x, y): |
| @@ -0,0 +1,14 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %y) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + for %loop_idx_5 inrange 0, 10, 1 iter {} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + if scalar_expr then { | ||
| 4 | + logical_tensor %y = ASSEMBLE(%x) token(); | ||
| 5 | + yield; | ||
| 6 | + } | ||
| 7 | + else { | ||
| 8 | + logical_tensor %y = ASSEMBLE(%x) token(); | ||
| 9 | + yield; | ||
| 10 | + } | ||
| 11 | + continue; | ||
| 12 | + } | ||
| 13 | + return %x, %y; | ||
| 14 | +} | ||
| @@ -976,8 +976,8 @@ def test_printer(): | |||
| 976 | x = pypto.Tensor((32, 32), pypto.DT_FP32, 'x') | 976 | x = pypto.Tensor((32, 32), pypto.DT_FP32, 'x') |
| 977 | y = pypto.Tensor((32, 32), pypto.DT_FP32, 'y') | 977 | y = pypto.Tensor((32, 32), pypto.DT_FP32, 'y') |
| 978 | func = pil.compile(foo, x, y) | 978 | func = pil.compile(foo, x, y) |
| 979 | - assert "= continue" in str(func) | 979 | + assert "continue %loop_idx_" in str(func) |
| 980 | - assert "= ir.yield_" in str(func) | 980 | + assert "yield" in str(func) |
| 981 | 981 | ||
| 982 | 982 | ||
| 983 | def nest1(a, b, out): | 983 | def nest1(a, b, out): |
| @@ -8,33 +8,16 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | """Root-function outcast tests for Assemble LogicalTensor versions.""" | 9 | """Root-function outcast tests for Assemble LogicalTensor versions.""" |
| 10 | 10 | ||
| 11 | +from pathlib import Path | ||
| 12 | + | ||
| 11 | import pypto | 13 | import pypto |
| 12 | from pypto import ir, pil | 14 | from pypto import ir, pil |
| 13 | 15 | ||
| 14 | from ..test_common import _ssa_verify, check_snapshot | 16 | from ..test_common import _ssa_verify, check_snapshot |
| 15 | 17 | ||
| 16 | -IR = """ | 18 | +_GOLDEN_DIR = Path(__file__).parent |
| 17 | -# ir.program: main | 19 | + |
| 18 | -@ir.function(type=ir.FunctionType.Orchestration) | 20 | +IR = (_GOLDEN_DIR / "test_assemble_outcast_versions.pypto").read_text() |
| 19 | -def foo(a@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor): | ||
| 20 | - [aux_3@1, out_0@2] = CALL(a@0, attrs=["callee": "foo_PATH0_7"]) | ||
| 21 | - return a@0, aux_3@1, out_0@2 | ||
| 22 | -@ir.function(type=ir.FunctionType.InCore) | ||
| 23 | -def foo_PATH0_7(a_3@11: ir.Tensor, aux_7@13: ir.Tensor, out_4@15: ir.Tensor): | ||
| 24 | - INCAST_LOCAL_BUF0_0@12 = VIEW(a_3@11, attrs=["fromOffset": [0, 0], "toValidShape": [32, 16]]) | ||
| 25 | - [OUTCAST_LOCAL_BUF0@14, OUTCAST_LOCAL_BUF1_0@16] = CALL(INCAST_LOCAL_BUF0_0@12, attrs=["callee": "foo_PATH0_hiddenfunc_5"]) | ||
| 26 | - aux_7@13 = ASSEMBLE(OUTCAST_LOCAL_BUF0@14, attrs=["toOffset": [0, 0]]) | ||
| 27 | - out_4@15 = ASSEMBLE(OUTCAST_LOCAL_BUF1_0@16, attrs=["toOffset": [0, 0]]) | ||
| 28 | -@ir.function(type=ir.FunctionType.InCore) | ||
| 29 | -def foo_PATH0_hiddenfunc_5(a_1@6: ir.Tensor, aux_5@8: ir.Tensor, out_2@9: ir.Tensor): | ||
| 30 | - INCAST_LOCAL_BUF0@7 = VIEW(a_1@6, attrs=["fromOffset": [0, 0], "toValidShape": [32, 16]]) | ||
| 31 | - $0@3 = VEC_DUP() | ||
| 32 | - aux_1@8 = ASSEMBLE($0@3, attrs=["toOffset": [0, 0]]) | ||
| 33 | - $1@4 = VEC_DUP() | ||
| 34 | - aux_5@8 = ASSEMBLE($1@4, attrs=["toOffset": [16, 0]]) | ||
| 35 | - OUTCAST_LOCAL_BUF1@10 = ADD(INCAST_LOCAL_BUF0@7, aux_5@8) | ||
| 36 | - out_2@9 = ASSEMBLE(OUTCAST_LOCAL_BUF1@10, attrs=["toOffset": [0, 0]]) | ||
| 37 | -""" # noqa: E501 | ||
| 38 | 21 | ||
| 39 | 22 | ||
| 40 | def _run_root_builder(func, *args): | 23 | def _run_root_builder(func, *args): |
| @@ -0,0 +1,21 @@ | |||
| 1 | +program #entry(foo) { | ||
| 2 | + function foo incast(logical_tensor %a, logical_tensor %aux, logical_tensor %out) outcast() #type(Orchestration) #entry(true) { | ||
| 3 | + logical_tensor %aux_3, logical_tensor %out_0 = CALL(%a) token() #callee(Unsupported); | ||
| 4 | + return %a, %aux_3, %out_0; | ||
| 5 | + } | ||
| 6 | + function foo_PATH0_7 incast(logical_tensor %a_3, logical_tensor %aux_7, logical_tensor %out_4) outcast() #type(InCore) #entry(false) { | ||
| 7 | + logical_tensor %INCAST_LOCAL_BUF0_0 = VIEW(%a_3) token(); | ||
| 8 | + logical_tensor %OUTCAST_LOCAL_BUF0, logical_tensor %OUTCAST_LOCAL_BUF1_0 = CALL(%INCAST_LOCAL_BUF0_0) token() #callee(Unsupported); | ||
| 9 | + logical_tensor %aux_7 = ASSEMBLE(%OUTCAST_LOCAL_BUF0) token(); | ||
| 10 | + logical_tensor %out_4 = ASSEMBLE(%OUTCAST_LOCAL_BUF1_0) token(); | ||
| 11 | + } | ||
| 12 | + function foo_PATH0_hiddenfunc_5 incast(logical_tensor %a_1, logical_tensor %aux_5, logical_tensor %out_2) outcast() #type(InCore) #entry(false) { | ||
| 13 | + logical_tensor %INCAST_LOCAL_BUF0 = VIEW(%a_1) token(); | ||
| 14 | + logical_tensor %$0 = VEC_DUP() token(); | ||
| 15 | + logical_tensor %aux_1 = ASSEMBLE(%$0) token(); | ||
| 16 | + logical_tensor %$1 = VEC_DUP() token(); | ||
| 17 | + logical_tensor %aux_5 = ASSEMBLE(%$1) token(); | ||
| 18 | + logical_tensor %OUTCAST_LOCAL_BUF1 = ADD(%INCAST_LOCAL_BUF0, %aux_5) token(); | ||
| 19 | + logical_tensor %out_2 = ASSEMBLE(%OUTCAST_LOCAL_BUF1) token(); | ||
| 20 | + } | ||
| 21 | +} | ||
| @@ -9,6 +9,7 @@ | |||
| 9 | # See LICENSE in the root of the software repository for the full text of the License. | 9 | # See LICENSE in the root of the software repository for the full text of the License. |
| 10 | """Tests for ir.Pass.infer_token_pass.""" | 10 | """Tests for ir.Pass.infer_token_pass.""" |
| 11 | 11 | ||
| 12 | +from pathlib import Path | ||
| 12 | import re | 13 | import re |
| 13 | 14 | ||
| 14 | import pypto | 15 | import pypto |
| @@ -17,6 +18,8 @@ from pypto.pil.compile_pipeline import compile_new_ir | |||
| 17 | 18 | ||
| 18 | from ..test_common import check_snapshot | 19 | from ..test_common import check_snapshot |
| 19 | 20 | ||
| 21 | +_GOLDEN_DIR = Path(__file__).parent | ||
| 22 | + | ||
| 20 | 23 | ||
| 21 | def _run_infer_token_pass(func, *args): | 24 | def _run_infer_token_pass(func, *args): |
| 22 | pipeline = [("infer_token_pass", ir.Pass.infer_token_pass())] | 25 | pipeline = [("infer_token_pass", ir.Pass.infer_token_pass())] |
| @@ -57,14 +60,7 @@ def _check_snapshot(func, golden): | |||
| 57 | check_snapshot(_NormalizedSnapshot(func), _normalize_token_names(golden)) | 60 | check_snapshot(_NormalizedSnapshot(func), _normalize_token_names(golden)) |
| 58 | 61 | ||
| 59 | 62 | ||
| 60 | -IR_0 = """ | 63 | +IR_0 = (_GOLDEN_DIR / "test_infer_pass_test_repeated_input.pypto").read_text() |
| 61 | -@ir.function | ||
| 62 | -def foo(x@0: ir.Tensor): | ||
| 63 | - $0@1, $0_w, x_r = ADD(x@0, x@0) | ||
| 64 | - return x@0 | ||
| 65 | -""" | ||
| 66 | - | ||
| 67 | - | ||
| 68 | def test_repeated_input(): | 64 | def test_repeated_input(): |
| 69 | def foo(x): | 65 | def foo(x): |
| 70 | pypto.add(x, x) | 66 | pypto.add(x, x) |
| @@ -73,14 +69,7 @@ def test_repeated_input(): | |||
| 73 | check_snapshot(func, IR_0) | 69 | check_snapshot(func, IR_0) |
| 74 | 70 | ||
| 75 | 71 | ||
| 76 | -IR_1 = """ | 72 | +IR_1 = (_GOLDEN_DIR / "test_infer_pass_test_multiple_outputs.pypto").read_text() |
| 77 | -@ir.function | ||
| 78 | -def foo(x@0: ir.Tensor): | ||
| 79 | - [$1@2, $0@1], $1_w, $0_w, x_r = TOPK(x@0) | ||
| 80 | - return x@0 | ||
| 81 | -""" | ||
| 82 | - | ||
| 83 | - | ||
| 84 | def test_multiple_outputs(): | 73 | def test_multiple_outputs(): |
| 85 | def foo(x): | 74 | def foo(x): |
| 86 | pypto.topk(x, 2) | 75 | pypto.topk(x, 2) |
| @@ -89,16 +78,7 @@ def test_multiple_outputs(): | |||
| 89 | check_snapshot(func, IR_1) | 78 | check_snapshot(func, IR_1) |
| 90 | 79 | ||
| 91 | 80 | ||
| 92 | -IR_2 = """ | 81 | +IR_2 = (_GOLDEN_DIR / "test_infer_pass_test_multiple_reads.pypto").read_text() |
| 93 | -@ir.function | ||
| 94 | -def foo(x@0: ir.Tensor): | ||
| 95 | - $0@1, $0_w, x_r = ADDS(x@0) | ||
| 96 | - $1@2, $1_w, x_r = SUBS(x@0) | ||
| 97 | - $2@3, $2_w, $0_r, $1_r = ADD($0@1, $1@2, tokens=[$0_w, $1_w]) | ||
| 98 | - return x@0 | ||
| 99 | -""" | ||
| 100 | - | ||
| 101 | - | ||
| 102 | def test_multiple_reads(): | 82 | def test_multiple_reads(): |
| 103 | def foo(x): | 83 | def foo(x): |
| 104 | lhs = x + 1.0 | 84 | lhs = x + 1.0 |
| @@ -109,17 +89,7 @@ def test_multiple_reads(): | |||
| 109 | check_snapshot(func, IR_2) | 89 | check_snapshot(func, IR_2) |
| 110 | 90 | ||
| 111 | 91 | ||
| 112 | -IR_3 = """ | 92 | +IR_3 = (_GOLDEN_DIR / "test_infer_pass_test_read_after_write.pypto").read_text() |
| 113 | -@ir.function | ||
| 114 | -def foo(a@0: ir.Tensor, b@1: ir.Tensor): | ||
| 115 | - $0@2, $0_w, b_r = EXP(b@1) | ||
| 116 | - a_1@0, a_1_w, $0_r = ASSEMBLE($0@2, tokens=[$0_w], attrs=["toOffset": [0, 0]]) | ||
| 117 | - $1@3, $1_w, a_1_r = EXP(a_1@0, tokens=[a_1_w]) | ||
| 118 | - $2@4, $2_w, a_1_r = EXP(a_1@0, tokens=[a_1_w]) | ||
| 119 | - return a_1@0, b@1 | ||
| 120 | -""" | ||
| 121 | - | ||
| 122 | - | ||
| 123 | def test_read_after_write(): | 93 | def test_read_after_write(): |
| 124 | def foo(a, b): | 94 | def foo(a, b): |
| 125 | value = pypto.exp(b) | 95 | value = pypto.exp(b) |
| @@ -131,18 +101,7 @@ def test_read_after_write(): | |||
| 131 | check_snapshot(func, IR_3) | 101 | check_snapshot(func, IR_3) |
| 132 | 102 | ||
| 133 | 103 | ||
| 134 | -IR_4 = """ | 104 | +IR_4 = (_GOLDEN_DIR / "test_infer_pass_test_write_after_read.pypto").read_text() |
| 135 | -@ir.function | ||
| 136 | -def foo(x@0: ir.Tensor): | ||
| 137 | - aux@1, aux_w = TENSOR_ALLOC() | ||
| 138 | - $0@2, $0_w, aux_r = ADDS(aux@1, tokens=[aux_w]) | ||
| 139 | - $1@3, $1_w = VEC_DUP() | ||
| 140 | - aux_1@1, aux_1_w, $1_r = ASSEMBLE($1@3, tokens=[$1_w, aux_r], attrs=["toOffset": [0, 0]]) | ||
| 141 | - $2@4, $2_w, $0_r, x_r = ADD($0@2, x@0, tokens=[$0_w]) | ||
| 142 | - return x@0 | ||
| 143 | -""" | ||
| 144 | - | ||
| 145 | - | ||
| 146 | def test_write_after_read(): | 105 | def test_write_after_read(): |
| 147 | def foo(x): | 106 | def foo(x): |
| 148 | pypto.set_vec_tile_shapes(16, 16) | 107 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -156,16 +115,7 @@ def test_write_after_read(): | |||
| 156 | check_snapshot(func, IR_4) | 115 | check_snapshot(func, IR_4) |
| 157 | 116 | ||
| 158 | 117 | ||
| 159 | -IR_5 = """ | 118 | +IR_5 = (_GOLDEN_DIR / "test_infer_pass_test_read_read_write.pypto").read_text() |
| 160 | -@ir.function | ||
| 161 | -def foo(a@0: ir.Tensor): | ||
| 162 | - $0@1, $0_w, a_r = EXP(a@0) | ||
| 163 | - $1@2, $1_w, a_r = EXP(a@0) | ||
| 164 | - a_1@0, a_1_w, $0_r = ASSEMBLE($0@1, tokens=[$0_w, a_r], attrs=["toOffset": [0, 0]]) | ||
| 165 | - return a_1@0 | ||
| 166 | -""" | ||
| 167 | - | ||
| 168 | - | ||
| 169 | def test_read_read_write(): | 119 | def test_read_read_write(): |
| 170 | def foo(a): | 120 | def foo(a): |
| 171 | value = pypto.exp(a) | 121 | value = pypto.exp(a) |
| @@ -176,18 +126,7 @@ def test_read_read_write(): | |||
| 176 | check_snapshot(func, IR_5) | 126 | check_snapshot(func, IR_5) |
| 177 | 127 | ||
| 178 | 128 | ||
| 179 | -IR_6 = """ | 129 | +IR_6 = (_GOLDEN_DIR / "test_infer_pass_test_write_write_read.pypto").read_text() |
| 180 | -@ir.function | ||
| 181 | -def foo(a@0: ir.Tensor, b@1: ir.Tensor, c@2: ir.Tensor): | ||
| 182 | - $0@3, $0_w, b_r = EXP(b@1) | ||
| 183 | - a_1@0, a_1_w, $0_r = ASSEMBLE($0@3, tokens=[$0_w], attrs=["toOffset": [0, 0]]) | ||
| 184 | - $1@4, $1_w, c_r = EXP(c@2) | ||
| 185 | - a_3@0, a_3_w, $1_r = ASSEMBLE($1@4, tokens=[$1_w, a_1_w], attrs=["toOffset": [0, 0]]) | ||
| 186 | - $2@5, $2_w, a_3_r = EXP(a_3@0, tokens=[a_3_w]) | ||
| 187 | - return a_3@0, b@1, c@2 | ||
| 188 | -""" | ||
| 189 | - | ||
| 190 | - | ||
| 191 | def test_write_write_read(): | 130 | def test_write_write_read(): |
| 192 | def foo(a, b, c): | 131 | def foo(a, b, c): |
| 193 | first = pypto.exp(b) | 132 | first = pypto.exp(b) |
| @@ -200,22 +139,7 @@ def test_write_write_read(): | |||
| 200 | check_snapshot(func, IR_6) | 139 | check_snapshot(func, IR_6) |
| 201 | 140 | ||
| 202 | 141 | ||
| 203 | -IR_7 = """ | 142 | +IR_7 = (_GOLDEN_DIR / "test_infer_pass_test_if_input.pypto").read_text() |
| 204 | -@ir.function | ||
| 205 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor, condition@3: ir.Tensor): | ||
| 206 | - $0@4, $0_w = VEC_DUP() | ||
| 207 | - aux_1@1, aux_1_w, $0_r = ASSEMBLE($0@4, tokens=[$0_w], attrs=["toOffset": [0, 0]]) | ||
| 208 | - if (0<RUNTIME_GetInputShapeDim(ARG_condition,0)): | ||
| 209 | - $1@5, $1_w, aux_1_r, x_r = ADD(aux_1@1, x@0, tokens=[aux_1_w]) | ||
| 210 | - result, result_w_if = ir.yield_($1@5, $1_w) | ||
| 211 | - else: | ||
| 212 | - $2@6, $2_w, aux_1_r_0, x_r_0 = SUB(aux_1@1, x@0, tokens=[aux_1_w]) | ||
| 213 | - result, result_w_if = ir.yield_($2@6, $2_w) | ||
| 214 | - out_1@2, out_1_w, result_r = ASSEMBLE(result@5, tokens=[result_w_if], attrs=["toOffset": [0, 0]]) | ||
| 215 | - return x@0, aux_1@1, out_1@2, condition@3 | ||
| 216 | -""" | ||
| 217 | - | ||
| 218 | - | ||
| 219 | def test_if_input(): | 143 | def test_if_input(): |
| 220 | def foo(x, aux, out, condition): | 144 | def foo(x, aux, out, condition): |
| 221 | pypto.set_vec_tile_shapes(16, 16) | 145 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -231,23 +155,7 @@ def test_if_input(): | |||
| 231 | _check_snapshot(func, IR_7) | 155 | _check_snapshot(func, IR_7) |
| 232 | 156 | ||
| 233 | 157 | ||
| 234 | -IR_8 = """ | 158 | +IR_8 = (_GOLDEN_DIR / "test_infer_pass_test_if_output.pypto").read_text() |
| 235 | -@ir.function | ||
| 236 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor, condition@3: ir.Tensor): | ||
| 237 | - if (0<RUNTIME_GetInputShapeDim(ARG_condition,0)): | ||
| 238 | - $0@4, $0_w = VEC_DUP() | ||
| 239 | - aux_1@1, aux_1_w, $0_r = ASSEMBLE($0@4, tokens=[$0_w], attrs=["toOffset": [0, 0]]) | ||
| 240 | - src_else, src_then, src_else_w_if, src_then_w_if, aux_1_w_if = ir.yield_(None, $0@4, None, $0_w, aux_1_w) | ||
| 241 | - else: | ||
| 242 | - $1@5, $1_w = VEC_DUP() | ||
| 243 | - aux_3@1, aux_3_w, $1_r = ASSEMBLE($1@5, tokens=[$1_w], attrs=["toOffset": [0, 0]]) | ||
| 244 | - src_else, src_then, src_else_w_if, src_then_w_if, aux_1_w_if = ir.yield_($1@5, None, $1_w, None, aux_3_w) | ||
| 245 | - $4@6, $4_w, aux_r, x_r = ADD(aux@1, x@0, tokens=[aux_1_w_if]) | ||
| 246 | - out_1@2, out_1_w, $4_r = ASSEMBLE($4@6, tokens=[$4_w], attrs=["toOffset": [0, 0]]) | ||
| 247 | - return x@0, aux@1, out_1@2, condition@3 | ||
| 248 | -""" | ||
| 249 | - | ||
| 250 | - | ||
| 251 | def test_if_output(): | 159 | def test_if_output(): |
| 252 | def foo(x, aux, out, condition): | 160 | def foo(x, aux, out, condition): |
| 253 | pypto.set_vec_tile_shapes(16, 16) | 161 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -264,23 +172,7 @@ def test_if_output(): | |||
| 264 | _check_snapshot(func, IR_8) | 172 | _check_snapshot(func, IR_8) |
| 265 | 173 | ||
| 266 | 174 | ||
| 267 | -IR_9 = """ | 175 | +IR_9 = (_GOLDEN_DIR / "test_infer_pass_test_if_passthrough.pypto").read_text() |
| 268 | -@ir.function | ||
| 269 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor, condition@3: ir.Tensor): | ||
| 270 | - $0@4, $0_w = VEC_DUP() | ||
| 271 | - aux_1@1, aux_1_w, $0_r = ASSEMBLE($0@4, tokens=[$0_w], attrs=["toOffset": [0, 0]]) | ||
| 272 | - if (0<RUNTIME_GetInputShapeDim(ARG_condition,0)): | ||
| 273 | - $1@5, $1_w = VEC_DUP() | ||
| 274 | - aux_3@1, aux_3_w, $1_r = ASSEMBLE($1@5, tokens=[$1_w, aux_1_w], attrs=["toOffset": [0, 0]]) | ||
| 275 | - inside, inside_w_if, aux_1_w_if = ir.yield_($1@5, $1_w, aux_3_w) | ||
| 276 | - else: | ||
| 277 | - inside, inside_w_if, aux_1_w_if = ir.yield_(None, None, aux_1_w) | ||
| 278 | - $3@6, $3_w, aux_1_r, x_r = ADD(aux_1@1, x@0, tokens=[aux_1_w_if]) | ||
| 279 | - out_1@2, out_1_w, $3_r = ASSEMBLE($3@6, tokens=[$3_w], attrs=["toOffset": [0, 0]]) | ||
| 280 | - return x@0, aux_1@1, out_1@2, condition@3 | ||
| 281 | -""" | ||
| 282 | - | ||
| 283 | - | ||
| 284 | def test_if_passthrough(): | 176 | def test_if_passthrough(): |
| 285 | def foo(x, aux, out, condition): | 177 | def foo(x, aux, out, condition): |
| 286 | pypto.set_vec_tile_shapes(16, 16) | 178 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -296,24 +188,7 @@ def test_if_passthrough(): | |||
| 296 | _check_snapshot(func, IR_9) | 188 | _check_snapshot(func, IR_9) |
| 297 | 189 | ||
| 298 | 190 | ||
| 299 | -IR_10 = """ | 191 | +IR_10 = (_GOLDEN_DIR / "test_infer_pass_test_if_multiple_reads.pypto").read_text() |
| 300 | -@ir.function | ||
| 301 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor, condition@3: ir.Tensor): | ||
| 302 | - if (0<RUNTIME_GetInputShapeDim(ARG_condition,0)): | ||
| 303 | - $0@4, $0_w, aux_r = ADDS(aux@1) | ||
| 304 | - $1@5, $1_w, aux_r = SUBS(aux@1) | ||
| 305 | - $2@6, $2_w, $0_r, $1_r = ADD($0@4, $1@5, tokens=[$0_w, $1_w]) | ||
| 306 | - read0, read1, result, read0_w_if, read1_w_if, result_w_if, aux_r_if = ir.yield_($0@4, $1@5, $2@6, $0_w, $1_w, $2_w, aux_r) | ||
| 307 | - else: | ||
| 308 | - $3@7, $3_w, x_r = ADDS(x@0) | ||
| 309 | - read0, read1, result, read0_w_if, read1_w_if, result_w_if, aux_r_if = ir.yield_(None, None, $3@7, None, None, $3_w, None) | ||
| 310 | - $7@8, $7_w = VEC_DUP() | ||
| 311 | - aux_1@1, aux_1_w, $7_r = ASSEMBLE($7@8, tokens=[$7_w, aux_r_if], attrs=["toOffset": [0, 0]]) | ||
| 312 | - out_1@2, out_1_w, result_r = ASSEMBLE(result@6, tokens=[result_w_if], attrs=["toOffset": [0, 0]]) | ||
| 313 | - return x@0, aux_1@1, out_1@2, condition@3 | ||
| 314 | -""" | ||
| 315 | - | ||
| 316 | - | ||
| 317 | def test_if_multiple_reads(): | 192 | def test_if_multiple_reads(): |
| 318 | def foo(x, aux, out, condition): | 193 | def foo(x, aux, out, condition): |
| 319 | pypto.set_vec_tile_shapes(16, 16) | 194 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -331,19 +206,7 @@ def test_if_multiple_reads(): | |||
| 331 | _check_snapshot(func, IR_10) | 206 | _check_snapshot(func, IR_10) |
| 332 | 207 | ||
| 333 | 208 | ||
| 334 | -IR_11 = """ | 209 | +IR_11 = (_GOLDEN_DIR / "test_infer_pass_test_for_input.pypto").read_text() |
| 335 | -@ir.function | ||
| 336 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor): | ||
| 337 | - $0@3, $0_w = VEC_DUP() | ||
| 338 | - aux_1@1, aux_1_w, $0_r = ASSEMBLE($0@3, tokens=[$0_w], attrs=["toOffset": [0, 0]]) | ||
| 339 | - for loop_idx_N, (_, result, result_0_w_for_iter) in ir.range(0, 2, 1, init_values=(None, None, None), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 340 | - $1@4, $1_w, aux_1_r, x_r = ADD(aux_1@1, x@0, tokens=[aux_1_w]) | ||
| 341 | - __0, result_0, result_0_w_for = continue loop_idx_N, $1@4, $1_w | ||
| 342 | - out_1@2, out_1_w, result_0_r = ASSEMBLE(result_0@4, tokens=[result_0_w_for], attrs=["toOffset": [0, 0]]) | ||
| 343 | - return x@0, aux_1@1, out_1@2 | ||
| 344 | -""" | ||
| 345 | - | ||
| 346 | - | ||
| 347 | def test_for_input(): | 210 | def test_for_input(): |
| 348 | def foo(x, aux, out): | 211 | def foo(x, aux, out): |
| 349 | pypto.set_vec_tile_shapes(16, 16) | 212 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -357,19 +220,7 @@ def test_for_input(): | |||
| 357 | _check_snapshot(func, IR_11) | 220 | _check_snapshot(func, IR_11) |
| 358 | 221 | ||
| 359 | 222 | ||
| 360 | -IR_12 = """ | 223 | +IR_12 = (_GOLDEN_DIR / "test_infer_pass_test_for_output.pypto").read_text() |
| 361 | -@ir.function | ||
| 362 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor): | ||
| 363 | - for loop_idx_N, (i, src, src_0_w_for_iter, aux_1_w_for_iter) in ir.range(0, 2, 1, init_values=(None, None, None, None), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 364 | - $0@3, $0_w = VEC_DUP() | ||
| 365 | - aux_1@1, aux_1_w, $0_r = ASSEMBLE($0@3, tokens=[$0_w], attrs=["toOffset": [(loop_idx_N*8), 0]]) | ||
| 366 | - i_0, src_0, src_0_w_for, aux_1_w_for = continue loop_idx_N, $0@3, $0_w, aux_1_w | ||
| 367 | - $2@4, $2_w, x_r, aux_1_r = ADD(x@0, aux_1@1, tokens=[aux_1_w_for]) | ||
| 368 | - out_1@2, out_1_w, $2_r = ASSEMBLE($2@4, tokens=[$2_w], attrs=["toOffset": [0, 0]]) | ||
| 369 | - return x@0, aux_1@1, out_1@2 | ||
| 370 | -""" | ||
| 371 | - | ||
| 372 | - | ||
| 373 | def test_for_output(): | 224 | def test_for_output(): |
| 374 | def foo(x, aux, out): | 225 | def foo(x, aux, out): |
| 375 | pypto.set_vec_tile_shapes(16, 16) | 226 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -383,21 +234,7 @@ def test_for_output(): | |||
| 383 | _check_snapshot(func, IR_12) | 234 | _check_snapshot(func, IR_12) |
| 384 | 235 | ||
| 385 | 236 | ||
| 386 | -IR_13 = """ | 237 | +IR_13 = (_GOLDEN_DIR / "test_infer_pass_test_if_none.pypto").read_text() |
| 387 | -@ir.function | ||
| 388 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor, condition@3: ir.Tensor): | ||
| 389 | - if (0<RUNTIME_GetInputShapeDim(ARG_condition,0)): | ||
| 390 | - $0@4, $0_w = VEC_DUP() | ||
| 391 | - aux_1@1, aux_1_w, $0_r = ASSEMBLE($0@4, tokens=[$0_w], attrs=["toOffset": [0, 0]]) | ||
| 392 | - inside, inside_w_if, aux_1_w_if = ir.yield_($0@4, $0_w, aux_1_w) | ||
| 393 | - else: | ||
| 394 | - inside, inside_w_if, aux_1_w_if = ir.yield_(None, None, None) | ||
| 395 | - $2@5, $2_w, aux_r, x_r = ADD(aux@1, x@0, tokens=[aux_1_w_if]) | ||
| 396 | - out_1@2, out_1_w, $2_r = ASSEMBLE($2@5, tokens=[$2_w], attrs=["toOffset": [0, 0]]) | ||
| 397 | - return x@0, aux@1, out_1@2, condition@3 | ||
| 398 | -""" | ||
| 399 | - | ||
| 400 | - | ||
| 401 | def test_if_none(): | 238 | def test_if_none(): |
| 402 | def foo(x, aux, out, condition): | 239 | def foo(x, aux, out, condition): |
| 403 | pypto.set_vec_tile_shapes(16, 16) | 240 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -411,19 +248,7 @@ def test_if_none(): | |||
| 411 | _check_snapshot(func, IR_13) | 248 | _check_snapshot(func, IR_13) |
| 412 | 249 | ||
| 413 | 250 | ||
| 414 | -IR_14 = """ | 251 | +IR_14 = (_GOLDEN_DIR / "test_infer_pass_test_for_read_output.pypto").read_text() |
| 415 | -@ir.function | ||
| 416 | -def foo(x@0: ir.Tensor, aux@1: ir.Tensor, out@2: ir.Tensor): | ||
| 417 | - for loop_idx_N, (_, read, read_0_w_for_iter, aux_r_for_iter) in ir.range(0, 2, 1, init_values=(None, None, None, None), attrs={"parallel": False, "submit_before_loop": False, "unroll_times": 1}): | ||
| 418 | - $0@3, $0_w, aux_r, x_r = ADD(aux@1, x@0) | ||
| 419 | - __0, read_0, read_0_w_for, aux_r_for = continue loop_idx_N, $0@3, $0_w, aux_r | ||
| 420 | - $2@4, $2_w = VEC_DUP() | ||
| 421 | - aux_1@1, aux_1_w, $2_r = ASSEMBLE($2@4, tokens=[$2_w, aux_r_for], attrs=["toOffset": [0, 0]]) | ||
| 422 | - out_1@2, out_1_w, read_0_r = ASSEMBLE(read_0@3, tokens=[read_0_w_for], attrs=["toOffset": [0, 0]]) | ||
| 423 | - return x@0, aux_1@1, out_1@2 | ||
| 424 | -""" | ||
| 425 | - | ||
| 426 | - | ||
| 427 | def test_for_read_output(): | 252 | def test_for_read_output(): |
| 428 | def foo(x, aux, out): | 253 | def foo(x, aux, out): |
| 429 | pypto.set_vec_tile_shapes(16, 16) | 254 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -0,0 +1,10 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w = VEC_DUP() token(); | ||
| 3 | + logical_tensor %aux_1, token %aux_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 4 | + int64_t %__0, logical_tensor %result_0, token %result_0_w_for = for %loop_idx_N inrange 0, 2, 1 iter {none %_ = %None;none %result = %None;token %result_0_w_for_iter = %None;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 5 | + logical_tensor %$1, token %$1_w, token %aux_1_r, token %x_r = ADD(%aux_1, %x) token(%aux_1_w); | ||
| 6 | + continue %loop_idx_N, %$1, %$1_w; | ||
| 7 | + } | ||
| 8 | + logical_tensor %out_1, token %out_1_w, token %result_0_r = ASSEMBLE(%result_0) token(%result_0_w_for); | ||
| 9 | + return %x, %aux_1, %out_1; | ||
| 10 | +} | ||
| @@ -0,0 +1,10 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + int64_t %i_0, logical_tensor %src_0, token %src_0_w_for, token %aux_1_w_for = for %loop_idx_N inrange 0, 2, 1 iter {none %i = %None;none %src = %None;token %src_0_w_for_iter = %None;token %aux_1_w_for_iter = %None;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + logical_tensor %$0, token %$0_w = VEC_DUP() token(); | ||
| 4 | + logical_tensor %aux_1, token %aux_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 5 | + continue %loop_idx_N, %$0, %$0_w, %aux_1_w; | ||
| 6 | + } | ||
| 7 | + logical_tensor %$2, token %$2_w, token %x_r, token %aux_1_r = ADD(%x, %aux_1) token(%aux_1_w_for); | ||
| 8 | + logical_tensor %out_1, token %out_1_w, token %$2_r = ASSEMBLE(%$2) token(%$2_w); | ||
| 9 | + return %x, %aux_1, %out_1; | ||
| 10 | +} | ||
| @@ -0,0 +1,10 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + int64_t %__0, logical_tensor %read_0, token %read_0_w_for, token %aux_r_for = for %loop_idx_N inrange 0, 2, 1 iter {none %_ = %None;none %read = %None;token %read_0_w_for_iter = %None;token %aux_r_for_iter = %None;} #parallel(false) #submit_before_loop(false) #_loop_conds(Unsupported) #_config_scope(Unsupported) #unroll_times(1) { | ||
| 3 | + logical_tensor %$0, token %$0_w, token %aux_r, token %x_r = ADD(%aux, %x) token(); | ||
| 4 | + continue %loop_idx_N, %$0, %$0_w, %aux_r; | ||
| 5 | + } | ||
| 6 | + logical_tensor %$2, token %$2_w = VEC_DUP() token(); | ||
| 7 | + logical_tensor %aux_1, token %aux_1_w, token %$2_r = ASSEMBLE(%$2) token(%$2_w, %aux_r_for); | ||
| 8 | + logical_tensor %out_1, token %out_1_w, token %read_0_r = ASSEMBLE(%read_0) token(%read_0_w_for); | ||
| 9 | + return %x, %aux_1, %out_1; | ||
| 10 | +} | ||
| @@ -0,0 +1,14 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out, logical_tensor %condition) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w = VEC_DUP() token(); | ||
| 3 | + logical_tensor %aux_1, token %aux_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 4 | + logical_tensor %result, token %result_w_if = if scalar_expr then { | ||
| 5 | + logical_tensor %$1, token %$1_w, token %aux_1_r, token %x_r = ADD(%aux_1, %x) token(%aux_1_w); | ||
| 6 | + yield %$1, %$1_w; | ||
| 7 | + } | ||
| 8 | + else { | ||
| 9 | + logical_tensor %$2, token %$2_w, token %aux_1_r_0, token %x_r_0 = SUB(%aux_1, %x) token(%aux_1_w); | ||
| 10 | + yield %$2, %$2_w; | ||
| 11 | + } | ||
| 12 | + logical_tensor %out_1, token %out_1_w, token %result_r = ASSEMBLE(%result) token(%result_w_if); | ||
| 13 | + return %x, %aux_1, %out_1, %condition; | ||
| 14 | +} | ||
| @@ -0,0 +1,16 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out, logical_tensor %condition) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %read0, logical_tensor %read1, logical_tensor %result, token %read0_w_if, token %read1_w_if, token %result_w_if, token %aux_r_if = if scalar_expr then { | ||
| 3 | + logical_tensor %$0, token %$0_w, token %aux_r = ADDS(%aux) token(); | ||
| 4 | + logical_tensor %$1, token %$1_w, token %aux_r = SUBS(%aux) token(); | ||
| 5 | + logical_tensor %$2, token %$2_w, token %$0_r, token %$1_r = ADD(%$0, %$1) token(%$0_w, %$1_w); | ||
| 6 | + yield %$0, %$1, %$2, %$0_w, %$1_w, %$2_w, %aux_r; | ||
| 7 | + } | ||
| 8 | + else { | ||
| 9 | + logical_tensor %$3, token %$3_w, token %x_r = ADDS(%x) token(); | ||
| 10 | + yield %None, %None, %$3, %None, %None, %$3_w, %None; | ||
| 11 | + } | ||
| 12 | + logical_tensor %$7, token %$7_w = VEC_DUP() token(); | ||
| 13 | + logical_tensor %aux_1, token %aux_1_w, token %$7_r = ASSEMBLE(%$7) token(%$7_w, %aux_r_if); | ||
| 14 | + logical_tensor %out_1, token %out_1_w, token %result_r = ASSEMBLE(%result) token(%result_w_if); | ||
| 15 | + return %x, %aux_1, %out_1, %condition; | ||
| 16 | +} | ||
| @@ -0,0 +1,13 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out, logical_tensor %condition) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %inside, token %inside_w_if, token %aux_1_w_if = if scalar_expr then { | ||
| 3 | + logical_tensor %$0, token %$0_w = VEC_DUP() token(); | ||
| 4 | + logical_tensor %aux_1, token %aux_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 5 | + yield %$0, %$0_w, %aux_1_w; | ||
| 6 | + } | ||
| 7 | + else { | ||
| 8 | + yield %None, %None, %None; | ||
| 9 | + } | ||
| 10 | + logical_tensor %$2, token %$2_w, token %aux_r, token %x_r = ADD(%aux, %x) token(%aux_1_w_if); | ||
| 11 | + logical_tensor %out_1, token %out_1_w, token %$2_r = ASSEMBLE(%$2) token(%$2_w); | ||
| 12 | + return %x, %aux, %out_1, %condition; | ||
| 13 | +} | ||
| @@ -0,0 +1,15 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out, logical_tensor %condition) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %src_else, logical_tensor %src_then, token %src_else_w_if, token %src_then_w_if, token %aux_1_w_if = if scalar_expr then { | ||
| 3 | + logical_tensor %$0, token %$0_w = VEC_DUP() token(); | ||
| 4 | + logical_tensor %aux_1, token %aux_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 5 | + yield %None, %$0, %None, %$0_w, %aux_1_w; | ||
| 6 | + } | ||
| 7 | + else { | ||
| 8 | + logical_tensor %$1, token %$1_w = VEC_DUP() token(); | ||
| 9 | + logical_tensor %aux_3, token %aux_3_w, token %$1_r = ASSEMBLE(%$1) token(%$1_w); | ||
| 10 | + yield %$1, %None, %$1_w, %None, %aux_3_w; | ||
| 11 | + } | ||
| 12 | + logical_tensor %$4, token %$4_w, token %aux_r, token %x_r = ADD(%aux, %x) token(%aux_1_w_if); | ||
| 13 | + logical_tensor %out_1, token %out_1_w, token %$4_r = ASSEMBLE(%$4) token(%$4_w); | ||
| 14 | + return %x, %aux, %out_1, %condition; | ||
| 15 | +} | ||
| @@ -0,0 +1,15 @@ | |||
| 1 | +function foo incast(logical_tensor %x, logical_tensor %aux, logical_tensor %out, logical_tensor %condition) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w = VEC_DUP() token(); | ||
| 3 | + logical_tensor %aux_1, token %aux_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 4 | + logical_tensor %inside, token %inside_w_if, token %aux_1_w_if = if scalar_expr then { | ||
| 5 | + logical_tensor %$1, token %$1_w = VEC_DUP() token(); | ||
| 6 | + logical_tensor %aux_3, token %aux_3_w, token %$1_r = ASSEMBLE(%$1) token(%$1_w, %aux_1_w); | ||
| 7 | + yield %$1, %$1_w, %aux_3_w; | ||
| 8 | + } | ||
| 9 | + else { | ||
| 10 | + yield %None, %None, %aux_1_w; | ||
| 11 | + } | ||
| 12 | + logical_tensor %$3, token %$3_w, token %aux_1_r, token %x_r = ADD(%aux_1, %x) token(%aux_1_w_if); | ||
| 13 | + logical_tensor %out_1, token %out_1_w, token %$3_r = ASSEMBLE(%$3) token(%$3_w); | ||
| 14 | + return %x, %aux_1, %out_1, %condition; | ||
| 15 | +} | ||
| @@ -0,0 +1,4 @@ | |||
| 1 | +function foo incast(logical_tensor %x) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$1, logical_tensor %$0, token %$1_w, token %$0_w, token %x_r = TOPK(%x) token(); | ||
| 3 | + return %x; | ||
| 4 | +} | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +function foo incast(logical_tensor %x) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w, token %x_r = ADDS(%x) token(); | ||
| 3 | + logical_tensor %$1, token %$1_w, token %x_r = SUBS(%x) token(); | ||
| 4 | + logical_tensor %$2, token %$2_w, token %$0_r, token %$1_r = ADD(%$0, %$1) token(%$0_w, %$1_w); | ||
| 5 | + return %x; | ||
| 6 | +} | ||
| @@ -0,0 +1,7 @@ | |||
| 1 | +function foo incast(logical_tensor %a, logical_tensor %b) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w, token %b_r = EXP(%b) token(); | ||
| 3 | + logical_tensor %a_1, token %a_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 4 | + logical_tensor %$1, token %$1_w, token %a_1_r = EXP(%a_1) token(%a_1_w); | ||
| 5 | + logical_tensor %$2, token %$2_w, token %a_1_r = EXP(%a_1) token(%a_1_w); | ||
| 6 | + return %a_1, %b; | ||
| 7 | +} | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +function foo incast(logical_tensor %a) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w, token %a_r = EXP(%a) token(); | ||
| 3 | + logical_tensor %$1, token %$1_w, token %a_r = EXP(%a) token(); | ||
| 4 | + logical_tensor %a_1, token %a_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w, %a_r); | ||
| 5 | + return %a_1; | ||
| 6 | +} | ||
| @@ -0,0 +1,4 @@ | |||
| 1 | +function foo incast(logical_tensor %x) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w, token %x_r = ADD(%x, %x) token(); | ||
| 3 | + return %x; | ||
| 4 | +} | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +function foo incast(logical_tensor %x) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %aux, token %aux_w = TENSOR_ALLOC() token(); | ||
| 3 | + logical_tensor %$0, token %$0_w, token %aux_r = ADDS(%aux) token(%aux_w); | ||
| 4 | + logical_tensor %$1, token %$1_w = VEC_DUP() token(); | ||
| 5 | + logical_tensor %aux_1, token %aux_1_w, token %$1_r = ASSEMBLE(%$1) token(%$1_w, %aux_r); | ||
| 6 | + logical_tensor %$2, token %$2_w, token %$0_r, token %x_r = ADD(%$0, %x) token(%$0_w); | ||
| 7 | + return %x; | ||
| 8 | +} | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +function foo incast(logical_tensor %a, logical_tensor %b, logical_tensor %c) outcast() #type(Opaque) #entry(false) { | ||
| 2 | + logical_tensor %$0, token %$0_w, token %b_r = EXP(%b) token(); | ||
| 3 | + logical_tensor %a_1, token %a_1_w, token %$0_r = ASSEMBLE(%$0) token(%$0_w); | ||
| 4 | + logical_tensor %$1, token %$1_w, token %c_r = EXP(%c) token(); | ||
| 5 | + logical_tensor %a_3, token %a_3_w, token %$1_r = ASSEMBLE(%$1) token(%$1_w, %a_1_w); | ||
| 6 | + logical_tensor %$2, token %$2_w, token %a_3_r = EXP(%a_3) token(%a_3_w); | ||
| 7 | + return %a_3, %b, %c; | ||
| 8 | +} | ||
| @@ -75,7 +75,7 @@ def test_contiguous_addr_auto_offset(): | |||
| 75 | 75 | ||
| 76 | ir_str = _ir_to_str(_parse_kernel(k)) | 76 | ir_str = _ir_to_str(_parse_kernel(k)) |
| 77 | # 128*128*2 bytes = 32768 -> second tile at base + 32768. | 77 | # 128*128*2 bytes = 32768 -> second tile at base + 32768. |
| 78 | - assert "ir.MemRef" in ir_str | 78 | + assert "memref_addr=" in ir_str |
| 79 | assert "32768" in ir_str | 79 | assert "32768" in ir_str |
| 80 | 80 | ||
| 81 | 81 | ||
| @@ -90,7 +90,7 @@ def test_discrete_addrs_list(): | |||
| 90 | pl.load(cur1, a, [0, 0]) | 90 | pl.load(cur1, a, [0, 0]) |
| 91 | 91 | ||
| 92 | ir_str = _ir_to_str(_parse_kernel(k)) | 92 | ir_str = _ir_to_str(_parse_kernel(k)) |
| 93 | - assert "ir.MemRef" in ir_str | 93 | + assert "memref_addr=" in ir_str |
| 94 | assert "65536" in ir_str | 94 | assert "65536" in ir_str |
| 95 | 95 | ||
| 96 | 96 | ||
| @@ -293,7 +293,7 @@ def test_subscript_const_index_materializes_mutex_companions(): | |||
| 293 | assert ir_str.count("block.make_tile") == 2, ir_str | 293 | assert ir_str.count("block.make_tile") == 2, ir_str |
| 294 | assert "_bufidx" not in ir_str, ir_str | 294 | assert "_bufidx" not in ir_str, ir_str |
| 295 | assert ir_str.count("system.mutex_lock_dyn") == 2, ir_str | 295 | assert ir_str.count("system.mutex_lock_dyn") == 2, ir_str |
| 296 | - assert "mutex_ids=\"mutex_ids\": [6, 7]" in ir_str, ir_str | 296 | + assert "mutex_ids=[6, 7]" in ir_str, ir_str |
| 297 | 297 | ||
| 298 | 298 | ||
| 299 | def test_subscript_negative_index_rejected(): | 299 | def test_subscript_negative_index_rejected(): |
| @@ -361,7 +361,7 @@ def test_subscript_dynamic_index_expression(): | |||
| 361 | ir_str = _ir_to_str(_parse_kernel(k)) | 361 | ir_str = _ir_to_str(_parse_kernel(k)) |
| 362 | assert "mutex_lock_dyn" in ir_str, ir_str | 362 | assert "mutex_lock_dyn" in ir_str, ir_str |
| 363 | assert ir_str.count("_bufidx") >= 2, ir_str | 363 | assert ir_str.count("_bufidx") >= 2, ir_str |
| 364 | - assert " % " in ir_str, ir_str | 364 | + assert " mod " in ir_str, ir_str |
| 365 | 365 | ||
| 366 | 366 | ||
| 367 | def test_subscript_single_tile_group_requires_bounded_index(): | 367 | def test_subscript_single_tile_group_requires_bounded_index(): |
| @@ -377,7 +377,7 @@ def test_subscript_single_tile_group_requires_bounded_index(): | |||
| 377 | ir_str = _ir_to_str(_parse_kernel(k)) | 377 | ir_str = _ir_to_str(_parse_kernel(k)) |
| 378 | assert "mutex_lock_dyn" in ir_str, ir_str | 378 | assert "mutex_lock_dyn" in ir_str, ir_str |
| 379 | assert "_bufidx" in ir_str, ir_str | 379 | assert "_bufidx" in ir_str, ir_str |
| 380 | - assert " % " in ir_str, ir_str | 380 | + assert " mod " in ir_str, ir_str |
| 381 | 381 | ||
| 382 | 382 | ||
| 383 | def test_subscript_two_slots_in_one_op_dedup(): | 383 | def test_subscript_two_slots_in_one_op_dedup(): |
| @@ -603,8 +603,8 @@ def test_const_multi_mutex_ids_use_one_dedup_op(): | |||
| 603 | ir_str = _ir_to_str(_parse_kernel(k)) | 603 | ir_str = _ir_to_str(_parse_kernel(k)) |
| 604 | assert ir_str.count("system.mutex_lock_dyn") == 1, ir_str | 604 | assert ir_str.count("system.mutex_lock_dyn") == 1, ir_str |
| 605 | assert ir_str.count("system.mutex_unlock_dyn") == 1, ir_str | 605 | assert ir_str.count("system.mutex_unlock_dyn") == 1, ir_str |
| 606 | - assert "mutex_id_owner_indices=\"mutex_id_owner_indices\": [0, 0]" in ir_str, ir_str | 606 | + assert "mutex_id_owner_indices=[0, 0]" in ir_str, ir_str |
| 607 | - assert "mutex_ids=\"mutex_ids\": [2, 3]" in ir_str, ir_str | 607 | + assert "mutex_ids=[2, 3]" in ir_str, ir_str |
| 608 | 608 | ||
| 609 | 609 | ||
| 610 | def test_dynamic_multi_mutex_ids_use_one_dedup_op(): | 610 | def test_dynamic_multi_mutex_ids_use_one_dedup_op(): |
| @@ -457,10 +457,11 @@ def test_enum_in_tuple_folds_to_selected_branch(): | |||
| 457 | An enum operand cannot be lowered to an IR constant, so the membership test | 457 | An enum operand cannot be lowered to an IR constant, so the membership test |
| 458 | must be decided while parsing and the enclosing ternary collapsed. | 458 | must be decided while parsing and the enclosing ternary collapsed. |
| 459 | """ | 459 | """ |
| 460 | - assert "ir.MemRef(ir.MemorySpace.Mat, 32768" in _tile_group_addr_ir(pl.DT_FP32, _addr_for) | 460 | + assert "target_memory=Mat" in _tile_group_addr_ir(pl.DT_FP32, _addr_for) |
| 461 | - assert "ir.MemRef(ir.MemorySpace.Mat, 16384" in _tile_group_addr_ir(pl.DT_FP16, _addr_for) | 461 | + assert "memref_addr=32768" in _tile_group_addr_ir(pl.DT_FP32, _addr_for) |
| 462 | + assert "memref_addr=16384" in _tile_group_addr_ir(pl.DT_FP16, _addr_for) | ||
| 462 | 463 | ||
| 463 | 464 | ||
| 464 | def test_enum_not_in_tuple_folds_to_selected_branch(): | 465 | def test_enum_not_in_tuple_folds_to_selected_branch(): |
| 465 | - assert "ir.MemRef(ir.MemorySpace.Mat, 4096" in _tile_group_addr_ir(pl.DT_FP16, _addr_for_not_in) | 466 | + assert "memref_addr=4096" in _tile_group_addr_ir(pl.DT_FP16, _addr_for_not_in) |
| 466 | - assert "ir.MemRef(ir.MemorySpace.Mat, 8192" in _tile_group_addr_ir(pl.DT_FP32, _addr_for_not_in) | 467 | + assert "memref_addr=8192" in _tile_group_addr_ir(pl.DT_FP32, _addr_for_not_in) |
| @@ -674,7 +674,7 @@ def test_dtype_kwarg_from_closure_enum_list(): | |||
| 674 | return result | 674 | return result |
| 675 | 675 | ||
| 676 | assert isinstance(func, ir.Function) | 676 | assert isinstance(func, ir.Function) |
| 677 | - assert "ir.FP32" in str(func) | 677 | + assert "target_type=float" in str(func) |
| 678 | 678 | ||
| 679 | 679 | ||
| 680 | @pytest.mark.soc("950") | 680 | @pytest.mark.soc("950") |
| @@ -687,7 +687,7 @@ def test_dtype_kwarg_from_helper_returning_enum(): | |||
| 687 | return result | 687 | return result |
| 688 | 688 | ||
| 689 | assert isinstance(func, ir.Function) | 689 | assert isinstance(func, ir.Function) |
| 690 | - assert "ir.FP32" in str(func) | 690 | + assert "target_type=float" in str(func) |
| 691 | 691 | ||
| 692 | 692 | ||
| 693 | @pytest.mark.soc("950") | 693 | @pytest.mark.soc("950") |
| @@ -49,9 +49,9 @@ def _make_ptr_then_addptr_kernel(p: pl.Ptr[pl.DT_UINT8]): | |||
| 49 | def test_make_ptr_emits_ptr_make_ptr_call_with_new_dtype(): | 49 | def test_make_ptr_emits_ptr_make_ptr_call_with_new_dtype(): |
| 50 | s = _ir_str(_make_ptr_change_dtype_kernel) | 50 | s = _ir_str(_make_ptr_change_dtype_kernel) |
| 51 | assert "ptr.make_ptr" in s | 51 | assert "ptr.make_ptr" in s |
| 52 | - assert "ir.FP16" in s | 52 | + assert "dtype=half" in s |
| 53 | # The tensor view built on the reinterpreted pointer carries the new dtype. | 53 | # The tensor view built on the reinterpreted pointer carries the new dtype. |
| 54 | - assert "ir.Tensor[[64, 128], ir.FP16" in s | 54 | + assert "tensor<64 x 128, half, tensor_view<, 128 x 1, ND, %fp16_ptr>>" in s |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | def test_make_ptr_result_type_is_ptr_with_changed_dtype(): | 57 | def test_make_ptr_result_type_is_ptr_with_changed_dtype(): |
| @@ -136,7 +136,7 @@ def test_make_tensor_from_tensor_ir_type(): | |||
| 136 | def test_make_tensor_from_tensor_reinterpret_dtype_ir(): | 136 | def test_make_tensor_from_tensor_reinterpret_dtype_ir(): |
| 137 | s = _ir_str(_retensor_dtype_kernel) | 137 | s = _ir_str(_retensor_dtype_kernel) |
| 138 | assert "ptr.make_tensor" in s | 138 | assert "ptr.make_tensor" in s |
| 139 | - assert "ir.Tensor[[64, 256], ir.UINT8" in s | 139 | + assert "tensor<64 x 256, uint8_t, tensor_view<, 256 x 1, ND, %src>>" in s |
| 140 | 140 | ||
| 141 | 141 | ||
| 142 | def test_make_tensor_view_of_view_ir(): | 142 | def test_make_tensor_view_of_view_ir(): |
| @@ -149,7 +149,7 @@ def test_tiling_field_access_lowers_to_getitem(): | |||
| 149 | assert len(kernel.params) == 1 | 149 | assert len(kernel.params) == 1 |
| 150 | assert kernel.params[0].name == "tiling" | 150 | assert kernel.params[0].name == "tiling" |
| 151 | # tiling.x lowers to tiling[0] (field index 0 of the struct). | 151 | # tiling.x lowers to tiling[0] (field index 0 of the struct). |
| 152 | - assert "tiling[0]" in str(kernel) | 152 | + assert "getitem(%tiling, 0)" in str(kernel) |
| 153 | 153 | ||
| 154 | 154 | ||
| 155 | def test_tiling_registry_reset_between_functions(): | 155 | def test_tiling_registry_reset_between_functions(): |
| @@ -361,7 +361,7 @@ def test_array_bare_name_resolves_to_nested_tuple(): | |||
| 361 | 361 | ||
| 362 | assert isinstance(kernel, ir.Function) | 362 | assert isinstance(kernel, ir.Function) |
| 363 | # tiling.offsets lowers to tiling[0], the nested tuple holding the array elements. | 363 | # tiling.offsets lowers to tiling[0], the nested tuple holding the array elements. |
| 364 | - assert "tiling[0]" in str(kernel) | 364 | + assert "getitem(%tiling, 0)" in str(kernel) |
| 365 | 365 | ||
| 366 | 366 | ||
| 367 | def test_array_out_of_bounds_raises_error(): | 367 | def test_array_out_of_bounds_raises_error(): |