summaryrefslogtreecommitdiff
path: root/mlir
diff options
context:
space:
mode:
authorMehdi Amini <joker.eph@gmail.com>2023-05-15 12:12:28 -0700
committerMehdi Amini <joker.eph@gmail.com>2023-05-15 12:12:28 -0700
commita58ed7fcf6fcae7b622f8a1873459f28725ce7d6 (patch)
treeb2a1305666b3f2a4f8e23b49e38eb0e6cb87ca86 /mlir
parent27b739228b42ecc7c15664670859e2bbad3b7749 (diff)
downloadllvm-a58ed7fcf6fcae7b622f8a1873459f28725ce7d6.tar.gz
Fix ConstShapeOp::inferReturnTypes to be resilient to lack of properties
The Python bindings test aren't using properties yet, this is a bit of a hack to support this here, but hopefully it'll be temporary.
Diffstat (limited to 'mlir')
-rw-r--r--mlir/lib/Dialect/Shape/IR/Shape.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index 24302544ea06..58d0e6aa3964 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -921,7 +921,13 @@ LogicalResult mlir::shape::ConstShapeOp::inferReturnTypes(
SmallVectorImpl<Type> &inferredReturnTypes) {
Builder b(context);
Properties *prop = properties.as<Properties *>();
- DenseIntElementsAttr shape = prop->shape;
+ DenseIntElementsAttr shape;
+ // TODO: this is only exercised by the Python bindings codepath which does not
+ // support properties
+ if (prop)
+ shape = prop->shape;
+ else
+ shape = attributes.getAs<DenseIntElementsAttr>("shape");
if (!shape)
return emitOptionalError(location, "missing shape attribute");
inferredReturnTypes.assign({RankedTensorType::get(