Skip to content

Commit 977c10e

Browse files
committed
draft
1 parent c1bfdfc commit 977c10e

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

onnxscript/utils/replace.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44

55
from typing import Sequence
66

7-
import onnx
87
import onnx_ir as ir
98
import onnx_ir.passes.common as common_passes
109

1110

12-
def replace_functions(
13-
model: onnx.ModelProto, functions: Sequence[onnx.FunctionProto]
14-
) -> onnx.ModelProto:
11+
def replace_functions(irmodel: ir.Model, irfunctions: Sequence[ir.Function]) -> None:
1512
"""A utility function to replace custom operations in a model with their expansions:
1613
Args:
1714
model: An ONNX ModelProto possibly containing calls to custom operations.
@@ -20,8 +17,6 @@ def replace_functions(
2017
Returns:
2118
An updated ModelProto with custom operations replaced by their expansions.
2219
"""
23-
irmodel = ir.from_proto(model)
24-
irfunctions = [ir.from_proto(func) for func in functions]
2520
model_functions = irmodel.functions
2621
if len(model_functions) != 0:
2722
# Since we use inlining, check that there are no model-local functions.
@@ -32,4 +27,3 @@ def replace_functions(
3227
# TODO (rama): Ideally, we should provide users more control over renaming strategy for inlined values.
3328
common_passes.InlinePass()(irmodel)
3429
common_passes.RemoveUnusedOpsetsPass()(irmodel)
35-
return ir.to_proto(irmodel)

0 commit comments

Comments
 (0)