Skip to content

Commit c36b424

Browse files
authored
[MLIR][Python] add value attr for PyAffineMapAttribute (#97254)
Similar to other attributes in Binding, the `PyAffineMapAttribute` should include a value attribute to enable users to directly retrieve the `AffineMap` from the `AffineMapAttr`.
1 parent 5c287ef commit c36b424

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mlir/lib/Bindings/Python/IRAttributes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class PyAffineMapAttribute : public PyConcreteAttribute<PyAffineMapAttribute> {
142142
return PyAffineMapAttribute(affineMap.getContext(), attr);
143143
},
144144
py::arg("affine_map"), "Gets an attribute wrapping an AffineMap.");
145+
c.def_property_readonly("value", mlirAffineMapAttrGetValue,
146+
"Returns the value of the AffineMap attribute");
145147
}
146148
};
147149

mlir/test/python/ir/attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def testAffineMapAttr():
157157
# CHECK: affine_map<(d0, d1)[s0, s1, s2] -> ()>
158158
attr_built = AffineMapAttr.get(map0)
159159
print(str(attr_built))
160-
160+
assert attr_built.value == map0
161161
attr_parsed = Attribute.parse(str(attr_built))
162162
assert attr_built == attr_parsed
163163

0 commit comments

Comments
 (0)