Skip to content

feat(optim): add algebraic graph rewrites#1126

Open
xieofxie wants to merge 1 commit into
mainfrom
hualxie/optimize_qnn
Open

feat(optim): add algebraic graph rewrites#1126
xieofxie wants to merge 1 commit into
mainfrom
hualxie/optimize_qnn

Conversation

@xieofxie

Copy link
Copy Markdown
Contributor

Summary

  • add an opt-in algebraic rewrite pipe after ORT constant folding
  • replace statically bounded Split nodes with Slice nodes
  • fold safe channel-wise affine branches into producing Conv weights and bias
  • fold inference Conv + static Add + BatchNormalization patterns
  • guard graph outputs, nested subgraph captures, shared consumers, dynamic shapes, and repeated optimizer runs
  • add generated ONNX numerical-equivalence and graph-safety coverage

QNN result

On the evaluated fixed-batch U-Net, the combined rewrites plus htp_graph_finalization_optimization_mode=3 reduced p50 latency from 31.125 ms to 22.729 ms and reduced QNN DDR traffic by roughly 30%.

Add opt-in static Split-to-Slice conversion and safe Conv affine/BatchNormalization folding with topology-based guards and generated-graph coverage.
@xieofxie xieofxie requested a review from a team as a code owner July 16, 2026 07:53
from typing import Any, ClassVar

import numpy as np
import onnx
if not self.should_process(config):
return model

import onnx
if not self.should_process(config):
return model

import onnx
from typing import TYPE_CHECKING

import numpy as np
import onnx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants