better spat computes merging
All checks were successful
Validate Operations / validate-operations (push) Successful in 21m14s
All checks were successful
Validate Operations / validate-operations (push) Successful in 21m14s
This commit is contained in:
@@ -96,8 +96,8 @@ bool hasSpatialChannelTargetCoreIdAttr(mlir::Value channel) {
|
||||
return channelNewOp && channelNewOp->hasAttr(kChannelTargetCoreIdAttrName);
|
||||
}
|
||||
|
||||
mlir::Value createPimReceiveFromSpatialChannel(
|
||||
PatternRewriter& rewriter, Location loc, mlir::Value output, mlir::Value channel) {
|
||||
mlir::Value
|
||||
createPimReceiveFromSpatialChannel(PatternRewriter& rewriter, Location loc, mlir::Value output, mlir::Value channel) {
|
||||
mlir::Value outputBuffer = getBestOutputTensorFromOperandsOrAllocate(rewriter, output.getDefiningOp());
|
||||
auto sizeAttr = getTensorSizeInBytesAttr(rewriter, output);
|
||||
auto sourceCoreIdAttr = getSpatialChannelSourceCoreIdAttr(rewriter, channel);
|
||||
@@ -127,6 +127,16 @@ SmallVector<mlir::Value> getOpOperandsSortedByUses(Operation* operation) {
|
||||
return map_to_vector(operandsAndUses, [](auto operandAndUse) { return operandAndUse.first; });
|
||||
}
|
||||
|
||||
bool hasLaterUserInBlock(mlir::Value value, Operation* operation) {
|
||||
for (Operation* user : value.getUsers()) {
|
||||
if (user->getBlock() != operation->getBlock())
|
||||
return true;
|
||||
if (operation->isBeforeInBlock(user))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
mlir::Value getBestOutputTensorFromOperandsOrAllocate(PatternRewriter& rewriter, Operation* operation) {
|
||||
assert("Only support operations with a single result" && operation->getNumResults() == 1);
|
||||
mlir::Value result = operation->getResult(0);
|
||||
@@ -134,8 +144,9 @@ mlir::Value getBestOutputTensorFromOperandsOrAllocate(PatternRewriter& rewriter,
|
||||
assert("Only support result ShapedType as result type" && isa<ShapedType>(resultType));
|
||||
|
||||
SmallVector<mlir::Value> operands = getOpOperandsSortedByUses(operation);
|
||||
auto validOperands =
|
||||
make_filter_range(operands, [resultType](mlir::Value operand) { return operand.getType() == resultType; });
|
||||
auto validOperands = make_filter_range(operands, [operation, resultType](mlir::Value operand) {
|
||||
return operand.getType() == resultType && !hasLaterUserInBlock(operand, operation);
|
||||
});
|
||||
auto bestOperand = validOperands.begin();
|
||||
|
||||
if (bestOperand != validOperands.end())
|
||||
|
||||
Reference in New Issue
Block a user