Skip to content

Commit

Permalink
dialects: (affine) add result_types to For from_region helper
Browse files Browse the repository at this point in the history
  • Loading branch information
superlopuh committed Jun 26, 2023
1 parent f2c69dc commit 73b1fe5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/dialects/test_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def test_simple_for():
f = For.from_region([], 0, 5, Region())
f = For.from_region([], [], 0, 5, Region())
assert f.lower_bound.value.data == 0
assert f.upper_bound.value.data == 5

Expand Down
2 changes: 1 addition & 1 deletion tests/test_frontend_op_inserter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_raises_exception_on_op_with_no_regions():

def test_raises_exception_on_op_with_no_blocks():
inserter = OpInserter(Block())
op_with_no_region = For.from_region([], 0, 10, Region())
op_with_no_region = For.from_region([], [], 0, 10, Region())
with pytest.raises(FrontendProgramException) as err:
inserter.set_insertion_point_from_op(op_with_no_region)
assert err.value.msg == (
Expand Down
4 changes: 2 additions & 2 deletions xdsl/dialects/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def verify_(self) -> None:
@staticmethod
def from_region(
operands: Sequence[Operation | SSAValue],
result_types: Sequence[Attribute],
lower_bound: int | AnyIntegerAttr,
upper_bound: int | AnyIntegerAttr,
region: Region,
Expand All @@ -74,14 +75,13 @@ def from_region(
upper_bound = IntegerAttr.from_index_int_value(upper_bound)
if isinstance(step, int):
step = IntegerAttr.from_index_int_value(step)
result_types = [SSAValue.get(op).typ for op in operands]
attributes: dict[str, Attribute] = {
"lower_bound": lower_bound,
"upper_bound": upper_bound,
"step": step,
}
return For.build(
operands=[[operand for operand in operands]],
operands=[operands],
result_types=[result_types],
attributes=attributes,
regions=[region],
Expand Down
2 changes: 1 addition & 1 deletion xdsl/frontend/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def visit_For(self, node: ast.For):
and isinstance(end, int)
and isinstance(step, int)
)
op = affine.For.from_region([], start, end, body, step)
op = affine.For.from_region([], [], start, end, body, step)
else:
self.inserter.insert_op(scf.Yield.get())
assert (
Expand Down

0 comments on commit 73b1fe5

Please sign in to comment.