|
6 | 6 | import pytest
|
7 | 7 |
|
8 | 8 | import spox.opset.ai.onnx.v17 as op
|
| 9 | +from spox import Tensor, Var, argument, build, inline |
9 | 10 | from spox._graph import arguments, results
|
10 | 11 | from spox._inline import rename_in_graph
|
11 |
| -from spox._public import inline |
12 |
| -from spox._type_system import Tensor |
13 | 12 | from spox._utils import from_array
|
14 |
| -from spox._var import Var |
15 | 13 |
|
16 | 14 |
|
17 | 15 | @pytest.fixture
|
@@ -342,3 +340,21 @@ def example_rename(n: str) -> str:
|
342 | 340 | _duplicate_subgraphs_to_list(relu_proto.graph), example_rename
|
343 | 341 | )
|
344 | 342 | assert rename_then_duplicate.node == duplicate_then_rename.node
|
| 343 | + |
| 344 | + |
| 345 | +def test_subgraph_with_nodes_with_optional_inputs(): |
| 346 | + """Unset optional inputs must not be prefixed by `inline`.""" |
| 347 | + |
| 348 | + def inline_model() -> onnx.ModelProto: |
| 349 | + a = argument(Tensor(numpy.float64, ("N",))) |
| 350 | + return build({"a": a}, {"b": op.clip(a, None, op.const(1.0, numpy.float64))}) |
| 351 | + |
| 352 | + foo = argument(Tensor(numpy.float64, ("N",))) |
| 353 | + (bar,) = inline(inline_model())(foo).values() |
| 354 | + |
| 355 | + model_proto = build({"foo": foo}, {"bar": bar}) |
| 356 | + |
| 357 | + (clip_node,) = (n for n in model_proto.graph.node if n.op_type == "Clip") |
| 358 | + assert len(clip_node.input) == 3 |
| 359 | + assert clip_node.input[1] == "" |
| 360 | + assert clip_node.input[2] != "" |
0 commit comments