Shortcuts

VerificationOptions

class torch.onnx.verification.VerificationOptions(flatten=True, ignore_none=True, check_shape=True, check_dtype=True, backend=OnnxBackend.ONNX_RUNTIME_CPU, rtol=0.001, atol=1e-07, remained_onnx_input_idx=None, acceptable_error_percentage=None)[source]

Options for ONNX export verification.

Variables:
  • flatten (bool) – If True, unpack nested list/tuple/dict inputs into a flattened list of Tensors for ONNX. Set this to False if nested structures are to be preserved for ONNX, which is usually the case with exporting ScriptModules. Default True.

  • ignore_none (bool) – Whether to ignore None type in torch output, which is usually the case with tracing. Set this to False, if torch output should keep None type, which is usually the case with exporting ScriptModules. Default to True.

  • check_shape (bool) – Whether to check the shapes between PyTorch and ONNX Runtime outputs are exactly the same. Set this to False to allow output shape broadcasting. Default to True.

  • check_dtype (bool) – Whether to check the dtypes between PyTorch and ONNX Runtime outputs are consistent. Default to True.

  • backend (torch.onnx.verification.OnnxBackend) – ONNX backend for verification. Default to OnnxBackend.ONNX_RUNTIME_CPU.

  • rtol (float) – relative tolerance in comparison between ONNX and PyTorch outputs.

  • atol (float) – absolute tolerance in comparison between ONNX and PyTorch outputs.

  • remained_onnx_input_idx (Optional[Sequence[int]]) – If provided, only the specified inputs will be passed to the ONNX model. Supply a list when there are unused inputs in the model. Since unused inputs will be removed in the exported ONNX model, supplying all inputs will cause an error on unexpected inputs. This parameter tells the verifier which inputs to pass into the ONNX model.

  • acceptable_error_percentage (Optional[float]) – acceptable percentage of element mismatches in comparison. It should be a float of value between 0.0 and 1.0.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources