You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Pull Request
### What change is being made
Allow to parameterize onnx opset and ir version.
### Why this change is being made
More flexibility for onnx runtime usage.
### Tested
Good to go if CI passes.
GitOrigin-RevId: 4d406775f9b082ae568fb33ea7a0632435005ffc
Copy file name to clipboardExpand all lines: exporter/exporter/exporter.py
+14-21Lines changed: 14 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,8 @@ def export_environment_as_onnx(
22
22
filename: str="policy.onnx",
23
23
model_source: dict|None=None,
24
24
verbose: bool=False,
25
+
opset_version: int=20,
26
+
ir_version: int=11,
25
27
):
26
28
"""Export policy into a Torch ONNX file.
27
29
@@ -33,6 +35,8 @@ def export_environment_as_onnx(
33
35
filename: The name of exported ONNX file. Defaults to "policy.onnx".
34
36
model_source: Information about the policy's origin (e.g., wandb, local file, etc.), added to the ONNX metadata.
35
37
verbose: Whether to print the model summary. Defaults to False.
38
+
opset_version: Version of the operator specification referenced by the ONNX graph. Needs to be compatible with ONNX Runtime in deployment environment, check https://onnxruntime.ai/docs/reference/compatibility.html
39
+
ir_version: Version of the intermediate representation specifications. Needs to be compatible with ONNX Runtime in deployment environment, check https://onnxruntime.ai/docs/reference/compatibility.html
36
40
"""
37
41
ifmodel_sourceisNone:
38
42
model_source= {}
@@ -43,6 +47,8 @@ def export_environment_as_onnx(
43
47
actor=actor,
44
48
normalizer=normalizer,
45
49
verbose=verbose,
50
+
opset_version=opset_version,
51
+
ir_version=ir_version,
46
52
)
47
53
48
54
policy_exporter.export(
@@ -69,6 +75,8 @@ def __init__(
69
75
self,
70
76
env: ExportableEnvironment,
71
77
actor: torch.nn.Module,
78
+
opset_version: int,
79
+
ir_version: int,
72
80
normalizer: torch.nn.Module|None=None,
73
81
verbose: bool=False,
74
82
):
@@ -86,10 +94,8 @@ def __init__(
86
94
else:
87
95
self.normalizer=torch.nn.Identity()
88
96
89
-
# Compatible versions with onnxruntime used in control (1.17)
90
-
# See https://onnxruntime.ai/docs/reference/compatibility.html
91
-
self._opset_version=20
92
-
self._ir_version=9
97
+
self._opset_version=opset_version
98
+
self._ir_version=ir_version
93
99
94
100
defforward(
95
101
self,
@@ -98,29 +104,16 @@ def forward(
98
104
"""Use the robot's state to compute policy actions, joint position targets, and policy observations, and outputs
99
105
that support history.
100
106
101
-
This method sets the environment's data sources (e.g., the articulation data and the IMU sensor data) such that
102
-
computing this method's outputs results in embedding the task's observation and action managers to be part of
103
-
the computational graph. This implementation's design is discussed in this design doc:
0 commit comments