Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "iree/compiler/Dialect/Util/Analysis/Constant/ConstExpr.h"

#include "iree/compiler/Dialect/LinalgExt/IR/LinalgExtDialect.h"
#include "iree/compiler/Dialect/LinalgExt/Utils/Utils.h"
#include "iree/compiler/Dialect/Util/Analysis/Constant/OpOracle.h"
#include "iree/compiler/Dialect/Util/Analysis/Explorer.h"
#include "iree/compiler/Dialect/Util/IR/UtilOps.h"
Expand Down Expand Up @@ -502,6 +504,28 @@ void ConstExprHoistingPolicy::makeDecision(
return;
}

// Check if this operation or any of its producers is a bit-extend operation
// (e.g., i8→f32 dequantization). Don't hoist these to keep quantized weights
// compact and avoid pulling dequantization into global initializers.
if (IREE::LinalgExt::isBitExtendOp(info->getOperation())) {
decision->disableHoist();
return;
}

// Also check if any producer is a bit-extend op - this catches the case
// where we're trying to hoist the result of: i8 -> sitofp -> mulf(scale)
for (auto *producer : info->producers) {
if (IREE::LinalgExt::isBitExtendOp(producer->getOperation())) {
LLVM_DEBUG({
llvm::dbgs()
<< "[ConstExprPolicy] Detected bit-extend producer, "
<< "disabling hoisting to keep quantized weights compact\n";
});
decision->disableHoist();
return;
}
}

// Otherwise, we can conditionally enable hoisting (based on cost model, etc).
// TODO: Implement further conditions.
decision->enableHoist();
Expand Down