-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change transfers to do pulls on multi transfer (#19931)
Scatter-gather reduction operations are preferable due to non-parallel data transfers. To adjust for this we should only push tensors when they are mono-transfers. When distributing to multiple devices it is preferable to have the device fetch as the case of 1...8 -> 1 -> 1...8 we would prefer each device to handle its own data transfers.
- Loading branch information
Showing
15 changed files
with
285 additions
and
99 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
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
79 changes: 79 additions & 0 deletions
79
compiler/src/iree/compiler/Dialect/Stream/Transforms/ExecutionPlacement.cpp
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,79 @@ | ||
// Copyright 2025 The IREE Authors | ||
// | ||
// Licensed 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 | ||
|
||
#include "iree/compiler/Dialect/Stream/Analysis/Partitioning.h" | ||
#include "iree/compiler/Dialect/Stream/IR/StreamDialect.h" | ||
#include "iree/compiler/Dialect/Stream/IR/StreamOps.h" | ||
#include "iree/compiler/Dialect/Stream/IR/StreamTypes.h" | ||
#include "iree/compiler/Dialect/Stream/Transforms/Passes.h" | ||
#include "iree/compiler/Dialect/Util/IR/UtilDialect.h" | ||
#include "iree/compiler/Dialect/Util/IR/UtilOps.h" | ||
#include "iree/compiler/Dialect/Util/IR/UtilTypes.h" | ||
#include "llvm/ADT/EquivalenceClasses.h" | ||
#include "llvm/Support/Debug.h" | ||
#include "mlir/Analysis/TopologicalSortUtils.h" | ||
#include "mlir/Dialect/SCF/IR/SCF.h" | ||
#include "mlir/IR/Attributes.h" | ||
#include "mlir/IR/Builders.h" | ||
#include "mlir/IR/BuiltinOps.h" | ||
#include "mlir/IR/Dominance.h" | ||
#include "mlir/IR/IRMapping.h" | ||
#include "mlir/IR/Location.h" | ||
#include "mlir/IR/Matchers.h" | ||
#include "mlir/IR/PatternMatch.h" | ||
#include "mlir/Pass/Pass.h" | ||
#include "mlir/Pass/PassRegistry.h" | ||
#include "mlir/Transforms/GreedyPatternRewriteDriver.h" | ||
|
||
#define DEBUG_TYPE "iree-stream-execution-placement" | ||
|
||
namespace mlir::iree_compiler::IREE::Stream { | ||
|
||
#define GEN_PASS_DEF_EXECUTIONPLACEMENTPASS | ||
#include "iree/compiler/Dialect/Stream/Transforms/Passes.h.inc" | ||
|
||
namespace { | ||
|
||
struct ExecutionPlacementPass | ||
: public IREE::Stream::impl::ExecutionPlacementPassBase< | ||
ExecutionPlacementPass> { | ||
void runOnOperation() override { | ||
|
||
getOperation()->walk([](IREE::Stream::AsyncTransferOp transfer) { | ||
if (transfer.getAffinityAttr()) | ||
return; | ||
|
||
auto operand = transfer.getSource(); | ||
auto producer = operand.getDefiningOp(); | ||
auto streamable = | ||
dyn_cast_or_null<IREE::Stream::StreamableOpInterface>(producer); | ||
auto srcAffinity = | ||
dyn_cast_or_null<IREE::Stream::AffinityOpInterface>(producer); | ||
|
||
bool hasOneUse = operand.hasOneUse(); | ||
if (hasOneUse && streamable && srcAffinity && | ||
srcAffinity.getAffinityAttr()) { | ||
transfer.setAffinityAttr(srcAffinity.getAffinityAttr()); | ||
return; | ||
} | ||
|
||
if (transfer.getResultAffinityAttr()) { | ||
transfer.setAffinityAttr(transfer.getResultAffinityAttr()); | ||
return; | ||
} | ||
|
||
if (transfer.getSourceAffinityAttr()) { | ||
transfer.setAffinityAttr(transfer.getSourceAffinityAttr()); | ||
return; | ||
} | ||
|
||
transfer->emitOpError("Unknown src/dest affinity"); | ||
}); | ||
} | ||
}; | ||
|
||
} // namespace | ||
} // namespace mlir::iree_compiler::IREE::Stream |
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
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.