Skip to content

Commit

Permalink
Update onnx examples to change /A/Add->Add_1 etc
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Sep 6, 2023
1 parent ce187cb commit 7222224
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
30 changes: 15 additions & 15 deletions examples/ONNX/ab.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"format": "ModECI MDF v0.4",
"generating_application": "Python modeci-mdf v0.4.7",
"graphs": {
"torch_jit": {
"torch-jit-export": {
"nodes": {
"/A/Add": {
"Add_1": {
"input_ports": {
"input": {
"shape": [
Expand All @@ -19,7 +19,7 @@
"B": {
"value": 1.0
},
"/A/Add": {
"Add_1": {
"function": "onnx::Add",
"args": {
"A": "input",
Expand All @@ -28,14 +28,14 @@
}
},
"output_ports": {
"_A_Add_output_0": {
"value": "/A/Add"
"onnx_Mul_2": {
"value": "Add_1"
}
}
},
"/B/Mul": {
"Mul_3": {
"input_ports": {
"_A_Add_output_0": {
"onnx_Mul_2": {
"shape": [
2,
3
Expand All @@ -47,27 +47,27 @@
"B": {
"value": 5.0
},
"/B/Mul": {
"Mul_3": {
"function": "onnx::Mul",
"args": {
"A": "_A_Add_output_0",
"A": "onnx_Mul_2",
"B": "B"
}
}
},
"output_ports": {
"_4": {
"value": "/B/Mul"
"value": "Mul_3"
}
}
}
},
"edges": {
"/A/Add._A_Add_output_0_/B/Mul._A_Add_output_0": {
"sender": "/A/Add",
"receiver": "/B/Mul",
"sender_port": "_A_Add_output_0",
"receiver_port": "_A_Add_output_0"
"Add_1.onnx_Mul_2_Mul_3.onnx_Mul_2": {
"sender": "Add_1",
"receiver": "Mul_3",
"sender_port": "onnx_Mul_2",
"receiver_port": "onnx_Mul_2"
}
}
}
Expand Down
Binary file modified examples/ONNX/ab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions examples/ONNX/ab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ ONNX Model:
format: ModECI MDF v0.4
generating_application: Python modeci-mdf v0.4.7
graphs:
torch_jit:
torch-jit-export:
nodes:
/A/Add:
Add_1:
input_ports:
input:
shape:
Expand All @@ -14,35 +14,35 @@ ONNX Model:
parameters:
B:
value: 1.0
/A/Add:
Add_1:
function: onnx::Add
args:
A: input
B: B
output_ports:
_A_Add_output_0:
value: /A/Add
/B/Mul:
onnx_Mul_2:
value: Add_1
Mul_3:
input_ports:
_A_Add_output_0:
onnx_Mul_2:
shape:
- 2
- 3
type: float
parameters:
B:
value: 5.0
/B/Mul:
Mul_3:
function: onnx::Mul
args:
A: _A_Add_output_0
A: onnx_Mul_2
B: B
output_ports:
_4:
value: /B/Mul
value: Mul_3
edges:
/A/Add._A_Add_output_0_/B/Mul._A_Add_output_0:
sender: /A/Add
receiver: /B/Mul
sender_port: _A_Add_output_0
receiver_port: _A_Add_output_0
Add_1.onnx_Mul_2_Mul_3.onnx_Mul_2:
sender: Add_1
receiver: Mul_3
sender_port: onnx_Mul_2
receiver_port: onnx_Mul_2
16 changes: 8 additions & 8 deletions examples/ONNX/abc.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"nodes": {
"Div_5": {
"input_ports": {
"x_11": {
"x.11": {
"shape": [
2,
3
Expand All @@ -72,7 +72,7 @@
"Div_5": {
"function": "onnx::Div",
"args": {
"A": "x_11",
"A": "x.11",
"B": "B"
}
}
Expand Down Expand Up @@ -118,14 +118,14 @@
}
},
"output_ports": {
"x_3": {
"x.3": {
"value": "Loop_3"
}
}
},
"Mul_8": {
"input_ports": {
"x_3": {
"x.3": {
"shape": [
1
],
Expand All @@ -139,7 +139,7 @@
"Mul_8": {
"function": "onnx::Mul",
"args": {
"A": "x_3",
"A": "x.3",
"B": "B"
}
}
Expand All @@ -158,11 +158,11 @@
"sender_port": "onnx_Loop_3",
"receiver_port": "onnx_Loop_3"
},
"Loop_3.x_3_Mul_8.x_3": {
"Loop_3.x.3_Mul_8.x.3": {
"sender": "Loop_3",
"receiver": "Mul_8",
"sender_port": "x_3",
"receiver_port": "x_3"
"sender_port": "x.3",
"receiver_port": "x.3"
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions examples/ONNX/abc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ONNX Model:
nodes:
Div_5:
input_ports:
x_11:
x.11:
shape:
- 2
- 3
Expand All @@ -52,7 +52,7 @@ ONNX Model:
Div_5:
function: onnx::Div
args:
A: x_11
A: x.11
B: B
output_ports:
x:
Expand All @@ -77,11 +77,11 @@ ONNX Model:
cond: cond
v_initial: onnx_Loop_3
output_ports:
x_3:
x.3:
value: Loop_3
Mul_8:
input_ports:
x_3:
x.3:
shape:
- 1
type: float
Expand All @@ -91,7 +91,7 @@ ONNX Model:
Mul_8:
function: onnx::Mul
args:
A: x_3
A: x.3
B: B
output_ports:
_13:
Expand All @@ -102,8 +102,8 @@ ONNX Model:
receiver: Loop_3
sender_port: onnx_Loop_3
receiver_port: onnx_Loop_3
Loop_3.x_3_Mul_8.x_3:
Loop_3.x.3_Mul_8.x.3:
sender: Loop_3
receiver: Mul_8
sender_port: x_3
receiver_port: x_3
sender_port: x.3
receiver_port: x.3
2 changes: 1 addition & 1 deletion examples/ONNX/simple_ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def main():
for t in test_values:
print("===================\nEvaluating MDF model with input: %s" % t)
eg.evaluate(initializer={"input": t})
print("Output: %s" % eg.enodes["/B/Mul"].evaluable_outputs["_4"].curr_value)
print("Output: %s" % eg.enodes["Mul_3"].evaluable_outputs["_4"].curr_value)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/interfaces/onnx/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_ab():
mdf_executable = EvaluableGraph(mdf_model.graphs[0], verbose=False)

mdf_executable.evaluate(initializer={"input": test_input})
mdf_output = mdf_executable.enodes["/B/Mul"].evaluable_outputs["_4"].curr_value
mdf_output = mdf_executable.enodes["Mul_3"].evaluable_outputs["_4"].curr_value

# Get the translated ONNX model
onnx_models = mdf_to_onnx(mdf_model)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_execution_engine_onnx(tmpdir):
eg = modeci_mdf.execution_engine.main(
"examples/ONNX/ab.%s" % mdf_format, array_format=array_format
)
output = eg.enodes["/B/Mul"].evaluable_outputs["_4"].curr_value
output = eg.enodes["Mul_3"].evaluable_outputs["_4"].curr_value
assert np.array_equal(output, np.full((2, 3), 5))


Expand Down

0 comments on commit 7222224

Please sign in to comment.