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.
This commit is contained in:
Mehdi Amini
2023-05-15 12:12:28 -07:00
parent 27b739228b
commit a58ed7fcf6

View File

@@ -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(