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