1 //===- SubsetOpInterface.h - Tensor Subsets ---------------------*- C++ -*-===// 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 #ifndef MLIR_INTERFACES_SUBSETOPINTERFACE_H_ 10 #define MLIR_INTERFACES_SUBSETOPINTERFACE_H_ 11 12 #include "mlir/IR/OpDefinition.h" 13 #include "mlir/Interfaces/ValueBoundsOpInterface.h" 14 15 namespace mlir { 16 class SubsetOpInterface; 17 class SubsetExtractionOpInterface; 18 class SubsetInsertionOpInterface; 19 20 namespace detail { 21 22 /// Return the destination/"init" operand of the op if it implements the 23 /// `DestinationStyleOpInterface` and has exactly one "init" operand. Asserts 24 /// otherwise. 25 OpOperand &defaultGetDestinationOperand(Operation *op); 26 27 /// Return the updated destination result of the op if it implements the 28 /// `DestinationStyleOpInterface`. 29 OpResult defaultGetUpdatedDestination(Operation *op); 30 31 /// Default implementation of `SubsetInsertionOpInterface::isEquivalentSubset`. 32 bool defaultIsEquivalentSubset(Operation *op, Value candidate, 33 function_ref<bool(Value, Value)> equivalenceFn); 34 35 /// Default implementation of `SubsetOpInterface::operatesOnEquivalentSubset`. 36 bool defaultOperatesOnEquivalentSubset( 37 Operation *op, SubsetOpInterface candidate, 38 function_ref<bool(Value, Value)> equivalenceFn); 39 40 /// Default implementation of `SubsetOpInterface::operatesOnDisjointSubset`. 41 bool defaultOperatesOnDisjointSubset( 42 Operation *op, SubsetOpInterface candidate, 43 function_ref<bool(Value, Value)> equivalenceFn); 44 45 /// Return the container that the given subset op is operating on. 46 Value getTensorContainer(Operation *op); 47 48 /// Verify `SubsetOpInterface`. 49 LogicalResult verifySubsetOpInterface(SubsetOpInterface op); 50 51 /// Verify `SubsetExtractionOpInterface`. 52 LogicalResult verifySubsetExtractionOpInterface(SubsetExtractionOpInterface op); 53 54 } // namespace detail 55 } // namespace mlir 56 57 #include "mlir/Interfaces/SubsetOpInterface.h.inc" 58 59 #endif // MLIR_INTERFACES_SUBSETOPINTERFACE_H_ 60