From a58ed7fcf6fcae7b622f8a1873459f28725ce7d6 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 15 May 2023 12:12:28 -0700 Subject: [PATCH] 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. --- mlir/lib/Dialect/Shape/IR/Shape.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 2430254..58d0e6a 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 &inferredReturnTypes) { Builder b(context); Properties *prop = properties.as(); - 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("shape"); if (!shape) return emitOptionalError(location, "missing shape attribute"); inferredReturnTypes.assign({RankedTensorType::get( -- 2.7.4