File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
onnxscript/rewriter/ort_fusions Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -140,4 +140,18 @@ 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+ # Apply the ORT optimization passes.
146+ # https://github.com/microsoft/onnxruntime/blob/74dcf7e296639095dfa55d31336998b6f719ed76/onnxruntime/python/tools/transformers/dynamo_onnx_helper.py#L172
147+ common_passes .ClearMetadataAndDocStringPass (),
148+ # https://github.com/microsoft/onnxruntime/blob/74dcf7e296639095dfa55d31336998b6f719ed76/onnxruntime/python/tools/transformers/dynamo_onnx_helper.py#L139
149+ common_passes .LiftConstantsToInitializersPass (lift_all_constants = False , size_limit = 1 ),
150+ common_passes .RemoveInitializersFromInputsPass (),
151+ common_passes .ShapeInferencePass (),
152+ common_passes .CheckerPass (),
153+ )
154+ assert passes .in_place
155+ result = passes (model )
156+ assert result .model is model
143157 return model , fusion_count
You can’t perform that action at this time.
0 commit comments