xref: /llvm-project/mlir/include/mlir/Interfaces/ParallelCombiningOpInterface.td (revision 0a1569a400491e264060b8a6ff7b7f64e1865496)
1//===- ParallelCombiningOpInterface.td - Parallel iface ----*- tablegen -*-===//
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// Defines the interface for ops that perform parallel combining operations.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE
14#define MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE
15
16include "mlir/IR/OpBase.td"
17
18def ParallelCombiningOpInterface : OpInterface<"ParallelCombiningOpInterface"> {
19  let description = [{
20    A parallel combining op is an op with a region.
21
22    This is useful as a terminator to parallel operations that iterate over
23    some set and return tensors while avoiding tight coupling between the
24    iterating op, the combining op and the individual subtensor producing ops.
25  }];
26  let cppNamespace = "::mlir";
27
28  let methods = [
29    InterfaceMethod<
30      /*desc=*/[{
31        Return `idx`^th result of the parent operation.
32      }],
33      /*retTy=*/"::mlir::OpResult",
34      /*methodName=*/"getParentResult",
35      /*args=*/(ins "int64_t":$idx),
36      /*methodBody=*/[{
37        return $_op.getParentResult(idx);
38      }]
39    >,
40    InterfaceMethod<
41      /*desc=*/[{
42        Return the contained ops that yield subvalues that this op combines to
43        yield to its parent.
44      }],
45      /*retTy=*/"::llvm::iterator_range<Block::iterator>",
46      /*methodName=*/"getYieldingOps",
47      /*args=*/(ins),
48      /*methodBody=*/[{
49        return $_op.getYieldingOps();
50      }]
51    >,
52  ];
53  // TODO: Single region single block interface on interfaces ?
54  let verify = [{
55    return verifyParallelCombiningOpInterface($_op);
56  }];
57}
58
59#endif // MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE
60