Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][SCF] Add a ParallelCombiningOpInterface to decouple scf::Perfo…
…rmConcurrently from its contained operations This allows purging references of scf.ForeachThreadOp and scf.PerformConcurrentlyOp from ParallelInsertSliceOp. This will allowmoving the op closer to tensor::InsertSliceOp with which it should share much more code. In the future, the decoupling will also allow extending the type of ops that can be used in the parallel combinator as well as semantics related to multiple concurrent inserts to the same result. Differential Revision: https://reviews.llvm.org/D128857
- Loading branch information
1 parent
6a57d8f
commit b994d38
Showing
10 changed files
with
205 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
mlir/include/mlir/Interfaces/ParallelCombiningOpInterface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//===- ParallelCombiningOpInterface.h - Parallel combining op interface ---===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements the operation interface for ops that parallel combining | ||
// operations. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE_H_ | ||
#define MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE_H_ | ||
|
||
#include "mlir/IR/OpDefinition.h" | ||
|
||
namespace mlir { | ||
namespace detail { | ||
// TODO: Single region single block interface on interfaces ? | ||
LogicalResult verifyParallelCombiningOpInterface(Operation *op); | ||
} // namespace detail | ||
} // namespace mlir | ||
|
||
/// Include the generated interface declarations. | ||
#include "mlir/Interfaces/ParallelCombiningOpInterface.h.inc" | ||
|
||
#endif // MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE_H_ |
75 changes: 75 additions & 0 deletions
75
mlir/include/mlir/Interfaces/ParallelCombiningOpInterface.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//===- ParallelCombiningOpInterface.td - Parallel iface ----*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Defines the interface for ops that perform parallel combining operations. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE | ||
#define MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def ParallelCombiningOpInterface : OpInterface<"ParallelCombiningOpInterface"> { | ||
let description = [{ | ||
A parallel combining op is an op with a region, that is not isolated from | ||
above and yields values to its parent op without itself returning an SSA | ||
value. The yielded values are determined by subvalues produced by the ops | ||
contained in the region (the `yieldingOps`) and combined in any unspecified | ||
order to produce the values yielded to the parent op. | ||
|
||
This is useful as a terminator to parallel operations that iterate over | ||
some set and return tensors while avoiding tight coupling between the | ||
iterating op, the combining op and the individual subtensor producing ops. | ||
}]; | ||
let cppNamespace = "::mlir"; | ||
|
||
let methods = [ | ||
InterfaceMethod< | ||
/*desc=*/[{ | ||
Return `idx`^th result of the parent operation. | ||
}], | ||
/*retTy=*/"::mlir::OpResult", | ||
/*methodName=*/"getParentResult", | ||
/*args=*/(ins "int64_t":$idx), | ||
/*methodBody=*/[{ | ||
return $_op.getParentResult(idx); | ||
}] | ||
>, | ||
InterfaceMethod< | ||
/*desc=*/[{ | ||
Return the contained ops that yield subvalues that this op combines to | ||
yield to its parent. | ||
}], | ||
/*retTy=*/"::llvm::iterator_range<Block::iterator>", | ||
/*methodName=*/"getYieldingOps", | ||
/*args=*/(ins), | ||
/*methodBody=*/[{ | ||
return $_op.getYieldingOps(); | ||
}] | ||
>, | ||
InterfaceMethod< | ||
/*desc=*/[{ | ||
Return the contained ops that yield subvalues that this op combines to | ||
yield to its parent. | ||
}], | ||
/*retTy=*/"::llvm::SmallVector<::mlir::Type>", | ||
/*methodName=*/"getYieldedTypes", | ||
/*args=*/(ins), | ||
/*methodBody=*/[{ | ||
return $_op.getYieldedTypes(); | ||
}] | ||
>, | ||
]; | ||
// TODO: Single region single block interface on interfaces ? | ||
let verify = [{ | ||
return verifyParallelCombiningOpInterface($_op); | ||
}]; | ||
} | ||
|
||
#endif // MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.