[MLIR][LoopFusion] Add computeToleranceThreshold as an option of initialization

Forked from
f15c68aa5f
This commit is contained in:
Guojie Luo 2022-11-23 21:22:00 +08:00
parent 89525cbf28
commit d3cf3685a7
2 changed files with 12 additions and 9 deletions

View File

@ -70,11 +70,10 @@ std::unique_ptr<OperationPass<func::FuncOp>> createLoopCoalescingPass();
/// Creates a loop fusion pass which fuses loops according to type of fusion
/// specified in `fusionMode`. Buffers of size less than or equal to
/// `localBufSizeThreshold` are promoted to memory space `fastMemorySpace`.
std::unique_ptr<OperationPass<func::FuncOp>>
createLoopFusionPass(unsigned fastMemorySpace = 0,
uint64_t localBufSizeThreshold = 0,
bool maximalFusion = false,
enum FusionMode fusionMode = FusionMode::Greedy);
std::unique_ptr<OperationPass<func::FuncOp>> createLoopFusionPass(
double computeToleranceThreshold = 0.3, unsigned fastMemorySpace = 0,
uint64_t localBufSizeThreshold = 0, bool maximalFusion = false,
enum FusionMode fusionMode = FusionMode::Greedy);
/// Creates a pass to perform tiling on loop nests.
std::unique_ptr<OperationPass<func::FuncOp>>

View File

@ -48,8 +48,10 @@ namespace {
struct LoopFusion : public AffineLoopFusionBase<LoopFusion> {
LoopFusion() = default;
LoopFusion(unsigned fastMemorySpace, uint64_t localBufSizeThresholdBytes,
bool maximalFusion, enum FusionMode affineFusionMode) {
LoopFusion(double computeToleranceThreshold, unsigned fastMemorySpace,
uint64_t localBufSizeThresholdBytes, bool maximalFusion,
enum FusionMode affineFusionMode) {
this->computeToleranceThreshold = computeToleranceThreshold;
this->fastMemorySpace = fastMemorySpace;
this->localBufSizeThreshold = localBufSizeThresholdBytes / 1024;
this->maximalFusion = maximalFusion;
@ -62,10 +64,12 @@ struct LoopFusion : public AffineLoopFusionBase<LoopFusion> {
} // namespace
std::unique_ptr<OperationPass<FuncOp>>
mlir::createLoopFusionPass(unsigned fastMemorySpace,
mlir::createLoopFusionPass(double computeToleranceThreshold,
unsigned fastMemorySpace,
uint64_t localBufSizeThreshold, bool maximalFusion,
enum FusionMode affineFusionMode) {
return std::make_unique<LoopFusion>(fastMemorySpace, localBufSizeThreshold,
return std::make_unique<LoopFusion>(computeToleranceThreshold,
fastMemorySpace, localBufSizeThreshold,
maximalFusion, affineFusionMode);
}