[Mlir-commits] [mlir] 16a776f - [mlir][py] Add StrAttr convenience builder.
Jacques Pienaar
llvmlistbot at llvm.org
Wed Dec 28 16:02:14 PST 2022
Author: Jacques Pienaar
Date: 2022-12-28T16:02:08-08:00
New Revision: 16a776ffef2b4862c27f73260362c56392b1b091
URL: https://github.com/llvm/llvm-project/commit/16a776ffef2b4862c27f73260362c56392b1b091
DIFF: https://github.com/llvm/llvm-project/commit/16a776ffef2b4862c27f73260362c56392b1b091.diff
LOG: [mlir][py] Add StrAttr convenience builder.
Added:
Modified:
mlir/python/mlir/ir.py
mlir/test/python/dialects/shape.py
Removed:
################################################################################
diff --git a/mlir/python/mlir/ir.py b/mlir/python/mlir/ir.py
index 82468e8b76b40..1e24fcbf99e40 100644
--- a/mlir/python/mlir/ir.py
+++ b/mlir/python/mlir/ir.py
@@ -32,6 +32,10 @@ def _i64Attr(x, context):
return IntegerAttr.get(
IntegerType.get_signless(64, context=context), x)
+ at register_attribute_builder("StrAttr")
+def _stringAttr(x, context):
+ return StringAttr.get(x, context=context)
+
@register_attribute_builder("SymbolNameAttr")
def _symbolNameAttr(x, context):
return StringAttr.get(x, context=context)
diff --git a/mlir/test/python/dialects/shape.py b/mlir/test/python/dialects/shape.py
index 2d2a2034bfb34..3e7a8b27d4c09 100644
--- a/mlir/test/python/dialects/shape.py
+++ b/mlir/test/python/dialects/shape.py
@@ -25,11 +25,14 @@ def const_shape_tensor(arg):
shape.ConstWitnessOp(False)
shape.ConstSizeOp(30)
shape.ConstSizeOp(IntegerAttr.get(IndexType.get(), 40))
- shape.ConstShapeOp([1, 2])
+ x = shape.ConstShapeOp([1, 2])
+ shape.MeetOp(x, x, error="impossible")
return shape.ConstShapeOp(
DenseElementsAttr.get(
np.array([3, 4], dtype=np.int64), type=IndexType.get()))
+
+
# CHECK-LABEL: func @const_shape_tensor(%arg0: tensor<12x?xf32>)
# CHECK-DAG: shape.const_witness false
# CHECK-DAG: shape.const_size 30
More information about the Mlir-commits
mailing list