# concrete.ml.torch.numpy\_module.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/torch/numpy_module.py#L0)

## module `concrete.ml.torch.numpy_module`

A torch to numpy module.

### **Global Variables**

* **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/torch/numpy_module.py#L19)

### class `NumpyModule`

General interface to transform a torch.nn.Module to numpy module.

**Args:**

* `torch_model` (Union\[nn.Module, onnx.ModelProto]): A fully trained, torch model along with its parameters or the onnx graph of the model.
* `dummy_input` (Union\[torch.Tensor, Tuple\[torch.Tensor, ...]]): Sample tensors for all the module inputs, used in the ONNX export to get a simple to manipulate nn representation.
* `debug_onnx_output_file_path`: (Optional\[Union\[Path, str]], optional): An optional path to indicate where to save the ONNX file exported by torch for debug. Defaults to None.

[![](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/torch/numpy_module.py#L32)

#### method `__init__`

```python
__init__(
    model: Union[Module, ModelProto],
    dummy_input: Optional[Tensor, Tuple[Tensor, ]] = None,
    debug_onnx_output_file_path: Optional[Path, str] = None
)
```

***

**property onnx\_model**

Get the ONNX model.

.. # noqa: DAR201

**Returns:**

* `_onnx_model` (onnx.ModelProto): the 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/torch/numpy_module.py#L79)

#### method `forward`

```python
forward(*args: ndarray) → Union[ndarray, Tuple[ndarray, ]]
```

Apply a forward pass on args with the equivalent numpy function only.

**Args:**

* `*args`: the inputs of the forward function

**Returns:**

* `Union[numpy.ndarray, Tuple[numpy.ndarray, ...]]`: result of the forward on the given inputs


---

# Agent Instructions: 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:

```
GET https://docs.zama.org/concrete-ml/1.1/developer-guide/api/concrete.ml.torch.numpy_module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
