[Mlir-commits] [mlir] c36b424 - [MLIR][Python] add value attr for PyAffineMapAttribute (#97254)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Jul 1 08:44:43 PDT 2024
Author: Bimo
Date: 2024-07-01T23:44:40+08:00
New Revision: c36b4248286c4546df0c0e93137a340facc75e17
URL: https://github.com/llvm/llvm-project/commit/c36b4248286c4546df0c0e93137a340facc75e17
DIFF: https://github.com/llvm/llvm-project/commit/c36b4248286c4546df0c0e93137a340facc75e17.diff
LOG: [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`.
Added:
Modified:
mlir/lib/Bindings/Python/IRAttributes.cpp
mlir/test/python/ir/attributes.py
Removed:
################################################################################
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index b5f31aa5dec54..b4049bd7972d4 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -142,6 +142,8 @@ class PyAffineMapAttribute : public PyConcreteAttribute<PyAffineMapAttribute> {
return PyAffineMapAttribute(affineMap.getContext(), attr);
},
py::arg("affine_map"), "Gets an attribute wrapping an AffineMap.");
+ c.def_property_readonly("value", mlirAffineMapAttrGetValue,
+ "Returns the value of the AffineMap attribute");
}
};
diff --git a/mlir/test/python/ir/attributes.py b/mlir/test/python/ir/attributes.py
index 8a4e19463c3ee..4b475db634645 100644
--- a/mlir/test/python/ir/attributes.py
+++ b/mlir/test/python/ir/attributes.py
@@ -157,7 +157,7 @@ def testAffineMapAttr():
# CHECK: affine_map<(d0, d1)[s0, s1, s2] -> ()>
attr_built = AffineMapAttr.get(map0)
print(str(attr_built))
-
+ assert attr_built.value == map0
attr_parsed = Attribute.parse(str(attr_built))
assert attr_built == attr_parsed
More information about the Mlir-commits
mailing list