> For the complete documentation index, see [llms.txt](https://docs.zama.org/concrete-ml/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/concrete-ml/1.1/developer-guide/api/concrete.ml.onnx.convert.md).

# concrete.ml.onnx.convert.md

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/blob/release/1.1.x/src/concrete/ml/onnx/convert.py#L0)

## module `concrete.ml.onnx.convert`

ONNX conversion related code.

### **Global Variables**

* **IMPLEMENTED\_ONNX\_OPS**
* **OPSET\_VERSION\_FOR\_ONNX\_EXPORT**

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/blob/release/1.1.x/src/concrete/ml/onnx/convert.py#L17)

### function `get_equivalent_numpy_forward_and_onnx_model`

```python
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 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.

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/blob/release/1.1.x/src/concrete/ml/onnx/convert.py#L67)

### function `get_equivalent_numpy_forward`

```python
get_equivalent_numpy_forward(
    onnx_model: ModelProto,
    check_model: bool = True
) → Callable[, Tuple[ndarray, ]]
```

Get 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.zama.org/concrete-ml/1.1/developer-guide/api/concrete.ml.onnx.convert.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
