concrete.ml.onnx.convertONNX conversion related code.
IMPLEMENTED_ONNX_OPS
OPSET_VERSION_FOR_ONNX_EXPORT
get_equivalent_numpy_forward_and_onnx_modelGet the numpy equivalent forward of the provided torch Module.
Args:
torch_module (torch.nn.Module): the torch Module for which to get the equivalent numpy forward.
dummy_input (Union[torch.Tensor, Tuple[torch.Tensor, ...]]): dummy inputs for ONNX export.
output_onnx_file (Optional[Union[Path, str]]): Path to save the ONNX file to. Will use a temp file if not provided. Defaults to None.
Returns:
Tuple[Callable[..., Tuple[numpy.ndarray, ...]], onnx.GraphProto]: The function that will execute the equivalent numpy code to the passed torch_module and the generated ONNX model.
get_equivalent_numpy_forwardGet the numpy equivalent forward of the provided ONNX model.
Args:
onnx_model (onnx.ModelProto): the ONNX model for which to get the equivalent numpy forward.
check_model (bool): set to True to run the onnx checker on the model. Defaults to True.
Raises:
ValueError: Raised if there is an unsupported ONNX operator required to convert the torch model to numpy.
Returns:
Callable[..., Tuple[numpy.ndarray, ...]]: The function that will execute the equivalent numpy function.
get_equivalent_numpy_forward_and_onnx_model(
torch_module: Module,
dummy_input: Union[Tensor, Tuple[Tensor, ]],
output_onnx_file: Optional[Path, str] = None
) → Tuple[Callable[, Tuple[ndarray, ]], GraphProto]get_equivalent_numpy_forward(
onnx_model: ModelProto,
check_model: bool = True
) → Callable[, Tuple[ndarray, ]]