File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
onnxscript/rewriter/ort_fusions Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments