Skip to content

Commit ea84ae4

Browse files
committed
Addr. comments
1 parent 58398a0 commit ea84ae4

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

onnxscript/utils/model_proto_to_function_proto.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,14 @@ def _initializers_to_constants(model: onnx.ModelProto) -> onnx.ModelProto:
3939

4040

4141
def convert_model_proto_to_function_proto(
42-
model: onnx.ModelProto, domain, name
42+
model: onnx.ModelProto, domain: str, name: str
4343
) -> onnx.FunctionProto:
4444
"""Converts an arbitrary ModelProto to a FunctionProto.
4545
4646
Since function protos don't support initializers (or rather it does not make sense in the context of a function)
4747
we need to convert them to constants first.
4848
"""
49-
model = _initializers_to_constants(
50-
model
51-
) # theres some work to do here...maybe contribute to open source?
49+
model = _initializers_to_constants(model)
5250
model_ir = onnx_ir.serde.deserialize_model(model)
5351
function_ir = onnx_ir.Function(
5452
domain=domain, name=name, graph=model_ir.graph, attributes={}

tests/utils/model_proto_to_function_proto_test.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,12 @@ def diff_square(x, y):
3030
def sum_func(z):
3131
return op.ReduceSum(z, keepdims=1)
3232

33-
@script()
34-
def l2norm(x: FLOAT["N"], y: FLOAT["N"]) -> FLOAT[1]: # noqa: F821
35-
return op.Sqrt(sum_func(diff_square(x, y)))
36-
3733
@script()
3834
def l2norm_with_functions(x: FLOAT["N"], y: FLOAT["N"]) -> FLOAT[1]: # noqa: F821
3935
return op.Sqrt(sum_func(diff_square(x, y)))
4036

4137
self.diff_square = diff_square
4238
self.sum_func = sum_func
43-
self.l2norm = l2norm
4439
self.l2norm_with_functions = l2norm_with_functions
4540

4641
def test_multiple_functions_in_model_proto(self):

0 commit comments

Comments
 (0)