Skip to content

Commit 8972962

Browse files
committed
add passes to ort_fusion
1 parent f06cfa5 commit 8972962

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

onnxscript/rewriter/ort_fusions/_core.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,19 @@ def optimize_for_ort(
140140
)
141141
# Apply the ORT pattern rewrite rules.
142142
rewrite(model, ORT_PATTERN_REWRITE_RULES)
143+
144+
passes = ir.passes.Sequential(
145+
# TODO(exporter team): Fold transpose into initializers
146+
# Apply the ORT optimization passes.
147+
# https://github.com/microsoft/onnxruntime/blob/74dcf7e296639095dfa55d31336998b6f719ed76/onnxruntime/python/tools/transformers/dynamo_onnx_helper.py#L172
148+
common_passes.ClearMetadataAndDocStringPass(),
149+
# https://github.com/microsoft/onnxruntime/blob/74dcf7e296639095dfa55d31336998b6f719ed76/onnxruntime/python/tools/transformers/dynamo_onnx_helper.py#L139
150+
common_passes.LiftConstantsToInitializersPass(lift_all_constants=False, size_limit=1),
151+
common_passes.RemoveInitializersFromInputsPass(),
152+
common_passes.ShapeInferencePass(),
153+
common_passes.CheckerPass(),
154+
)
155+
assert passes.in_place
156+
result = passes(model)
157+
assert result.model is model
143158
return model, fusion_count

0 commit comments

Comments
 (0)