1 //===- LinalgInterface.h - Linalg operations interfaces -------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements the operation interfaces for Linalg operations. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef MLIR_DIALECT_LINALG_IR_LINALGINTERFACES_H_ 14 #define MLIR_DIALECT_LINALG_IR_LINALGINTERFACES_H_ 15 16 #include "mlir/Dialect/Utils/StructuredOpsUtils.h" 17 #include "mlir/IR/AffineMap.h" 18 #include "mlir/IR/BlockAndValueMapping.h" 19 #include "mlir/IR/BuiltinTypes.h" 20 #include "mlir/IR/ImplicitLocOpBuilder.h" 21 #include "mlir/IR/OpDefinition.h" 22 #include "mlir/Interfaces/InferTypeOpInterface.h" 23 #include "mlir/Interfaces/ViewLikeInterface.h" 24 25 namespace mlir { 26 namespace linalg { 27 class LinalgOp; 28 29 /// OpOperand vector that implicitly converts to a Value vector. 30 struct OpOperandVector : public SmallVector<OpOperand *> { 31 operator SmallVector<Value>(); 32 }; 33 34 namespace detail { 35 /// Implementation of the method that that check if given operands 36 /// can be dropped, i.e. the remaining operands can compute the loop 37 /// bounds of the op. 38 bool canOpOperandsBeDroppedImpl(linalg::LinalgOp linalgOp, 39 ArrayRef<OpOperand *> droppedOperands); 40 } // namespace detail 41 42 /// Checks whether `linalgOp` conforms to ContractionOpInterface. 43 // TODO: embed within `isa<ContractionOpInterface>` if possible / natural. 44 bool isaContractionOpInterface(LinalgOp linalgOp); 45 46 namespace detail { 47 48 /// Verify that `op` conforms to ContractionOpInterface. 49 LogicalResult verifyContractionInterface(Operation *op); 50 51 /// Verify that `op` conforms to the ConvolutionOpInterface. 52 LogicalResult verifyConvolutionInterface(Operation *op); 53 54 /// Verify that `op` conforms to the FillOpInterface. 55 LogicalResult verifyFillInterface(Operation *op); 56 57 /// Verify that `op` conforms to the invariants of StructuredOpInterface 58 LogicalResult verifyStructuredOpInterface(Operation *op); 59 60 } // namespace detail 61 } // namespace linalg 62 } // namespace mlir 63 64 #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.h.inc" 65 66 /// Include the generated interface declarations. 67 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h.inc" 68 69 #endif // MLIR_DIALECT_LINALG_IR_LINALGINTERFACES_H_ 70