Skip to content

Commit

Permalink
Revert "Enable ClipQuantFusion exclusively on CPU EP (#20627)"
Browse files Browse the repository at this point in the history
This reverts commit 49d197a.
  • Loading branch information
cloudhan committed Oct 28, 2024
1 parent d897f0f commit a322263
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion onnxruntime/core/optimizer/graph_transformer_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ InlinedVector<std::unique_ptr<RewriteRule>> GenerateRewriteRules(
rules.push_back(std::make_unique<ConvBNFusion>());
rules.push_back(std::make_unique<PadFusion>());
rules.push_back(std::make_unique<MatmulBNFusion>());
rules.push_back(std::make_unique<ClipQuantFusion>());
rules.push_back(std::make_unique<ReluQuantFusion>());
rules.push_back(std::make_unique<LabelEncoderFusion>());
break;

case TransformerLevel::Level2:
rules.push_back(std::make_unique<ClipQuantFusion>());
rules.push_back(std::make_unique<GemmTransposeFusion>());
// No level2 rules available today
break;

case TransformerLevel::Level3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ static bool GetQConstantLowerUpper(const Graph& graph, const Node& node, float&

bool ClipQuantFusion::SatisfyCondition(const Graph& graph, const Node& node, const logging::Logger& /*logger*/) const {
if (!graph_utils::IsSupportedOptypeVersionAndDomain(node, "Clip", {1, 6, 11, 12, 13}) ||
!graph_utils::IsSupportedProvider(node, {kCpuExecutionProvider}) ||
!optimizer_utils::CheckOutputEdges(graph, node, 1)) {
return false;
}

// if Clip is followed by QuantizeLinear, it can be fused into QuantizeLinear potentially
const auto& next_node = *node.OutputNodesBegin();
if (!graph_utils::IsSupportedProvider(next_node, {kCpuExecutionProvider}) ||
!QDQ::MatchQNode(next_node)) {
if (!QDQ::MatchQNode(next_node)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/test/optimizer/qdq_transformer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3037,7 +3037,7 @@ TEST(QDQTransformerTests, Clip) {

TransformerTester(build_test_case, check_clip_graph,
TransformerLevel::Default,
TransformerLevel::Level2,
TransformerLevel::Level1,
opset_version,
epsilon,
epsilon);
Expand Down

0 comments on commit a322263

Please sign in to comment.