diff --git a/mlir/include/mlir/IR/BuiltinTypes.h b/mlir/include/mlir/IR/BuiltinTypes.h --- a/mlir/include/mlir/IR/BuiltinTypes.h +++ b/mlir/include/mlir/IR/BuiltinTypes.h @@ -287,11 +287,11 @@ } /// Create a new RankedTensor by erasing a dim from shape @pos. - RankedTensorType dropDim(unsigned pos) { + RankedTensorType dropDim(unsigned pos) const { assert(pos < shape.size() && "overflow"); SmallVector newShape(shape.begin(), shape.end()); newShape.erase(newShape.begin() + pos); - return setShape(newShape); + return RankedTensorType::get(newShape, elementType, encoding); } operator RankedTensorType() { @@ -334,13 +334,13 @@ /// In the particular case where the vector has a single dimension that we /// drop, return the scalar element type. // TODO: unify once we have a VectorType that supports 0-D. - Type dropDim(unsigned pos) { + Type dropDim(unsigned pos) const { assert(pos < shape.size() && "overflow"); if (shape.size() == 1) return elementType; SmallVector newShape(shape.begin(), shape.end()); newShape.erase(newShape.begin() + pos); - return setShape(newShape); + return VectorType::get(newShape, elementType); } operator VectorType() { return VectorType::get(shape, elementType); }