Skip to content

Check exported onnx using onnx lib

Description

It seems that some exported ONNX are not compliant with the standard even when using non-custom operators.

Proposal

  • Add a check triggered through an environment variable "AIDGE_ONNX_CHECK_EXPORT=yes" using the onnx lib
import onnx

    if os.getenv("AIDGE_ONNX_CHECK_EXPORT").lower() == "yes":
       m = onnx.load(exported_filename)
       onnx.checker.check_model(m)
       onnx.shape_inference.infer_shapes(m,check_type = True, strict_mode = True, data_prop = True)