From e73bb4fba7092f7e1ef807812063a0f655a185af Mon Sep 17 00:00:00 2001 From: Frederik Gossen Date: Thu, 28 May 2020 13:35:51 +0000 Subject: [PATCH] [MLIR] Move `ConcatOp` to its lexicographic position Purely cosmetic change. The operation implementations in `Shape.cpp` are now lexicographic order. Differential Revision: https://reviews.llvm.org/D80277 --- mlir/lib/Dialect/Shape/IR/Shape.cpp | 56 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index c4a8b152981..fc8f9b23e1e 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -181,6 +181,34 @@ OpFoldResult BroadcastOp::fold(ArrayRef operands) { } //===----------------------------------------------------------------------===// +// ConcatOp +//===----------------------------------------------------------------------===// + +LogicalResult +ConcatOp::inferReturnTypes(MLIRContext *context, Optional location, + ValueRange operands, DictionaryAttr attributes, + RegionRange regions, + SmallVectorImpl &inferredReturnTypes) { + auto shapeType = ShapeType::get(context); + inferredReturnTypes.push_back(shapeType); + return success(); +} + +OpFoldResult ConcatOp::fold(ArrayRef operands) { + if (!operands[0] || !operands[1]) + return nullptr; + auto lhsShape = llvm::to_vector<6>( + operands[0].cast().getValues()); + auto rhsShape = llvm::to_vector<6>( + operands[1].cast().getValues()); + SmallVector resultShape; + resultShape.append(lhsShape.begin(), lhsShape.end()); + resultShape.append(rhsShape.begin(), rhsShape.end()); + Builder builder(getContext()); + return builder.getIndexTensorAttr(resultShape); +} + +//===----------------------------------------------------------------------===// // ConstShapeOp //===----------------------------------------------------------------------===// @@ -342,34 +370,6 @@ LogicalResult SplitAtOp::fold(ArrayRef operands, } //===----------------------------------------------------------------------===// -// ConcatOp -//===----------------------------------------------------------------------===// - -LogicalResult -ConcatOp::inferReturnTypes(MLIRContext *context, Optional location, - ValueRange operands, DictionaryAttr attributes, - RegionRange regions, - SmallVectorImpl &inferredReturnTypes) { - auto shapeType = ShapeType::get(context); - inferredReturnTypes.push_back(shapeType); - return success(); -} - -OpFoldResult ConcatOp::fold(ArrayRef operands) { - if (!operands[0] || !operands[1]) - return nullptr; - auto lhsShape = llvm::to_vector<6>( - operands[0].cast().getValues()); - auto rhsShape = llvm::to_vector<6>( - operands[1].cast().getValues()); - SmallVector resultShape; - resultShape.append(lhsShape.begin(), lhsShape.end()); - resultShape.append(rhsShape.begin(), rhsShape.end()); - Builder builder(getContext()); - return builder.getIndexTensorAttr(resultShape); -} - -//===----------------------------------------------------------------------===// // ToExtentTensorOp //===----------------------------------------------------------------------===// -- 2.11.0