However, some ONNX models may have this domain located elsewhere, leading to incorrect opset identification, for example:
Proposed solution:
def get_opset(model: onnx.ModelProto) -> int:
opset = [x.version for x in model.opset_import if x.domain == ""]
if opset:
return opset[0]
else:
return None
Note that in the above code snippet x.domain == "" indicates the default domain which is ai.onnx.
The current opset retrieval function assumes the default opset (ai.onnx) domain is always at the first index as shown below:
https://github.com/onnx/turnkeyml/blob/69a203e9d45cbce5c256c2bfe9238255a7227c7e/src/turnkeyml/build/onnx_helpers.py#L135-L136
However, some ONNX models may have this domain located elsewhere, leading to incorrect opset identification, for example:
Proposed solution:
Note that in the above code snippet
x.domain == ""
indicates the default domain which is ai.onnx.