# concrete.ml.onnx.ops\_impl.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/ops_impl.py#L0)

## module `concrete.ml.onnx.ops_impl`

ONNX ops implementation in Python + NumPy.

***

[![](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/ops_impl.py#L30)

### function `cast_to_float`

```python
cast_to_float(inputs)
```

Cast values to floating points.

**Args:**

* `inputs` (Tuple\[numpy.ndarray]): The values to consider.

**Returns:**

* `Tuple[numpy.ndarray]`: The float values.

***

[![](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/ops_impl.py#L98)

### function `onnx_func_raw_args`

```python
onnx_func_raw_args(*args, output_is_raw: bool = False)
```

Decorate a numpy onnx function to flag the raw/non quantized inputs.

**Args:**

* `*args (tuple[Any])`: function argument names
* `output_is_raw` (bool): marks the function as returning raw values that should not be quantized

**Returns:**

* `result` (ONNXMixedFunction): wrapped numpy function with a list of mixed arguments

***

[![](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/ops_impl.py#L124)

### function `numpy_where_body`

```python
numpy_where_body(c: ndarray, t: ndarray, f: Union[ndarray, int]) → ndarray
```

Compute the equivalent of numpy.where.

This function is not mapped to any ONNX operator (as opposed to numpy\_where). It is usable by functions which are mapped to ONNX operators, e.g., numpy\_div or numpy\_where.

**Args:**

* `c` (numpy.ndarray): Condition operand.
* `t` (numpy.ndarray): True operand.
* `f` (numpy.ndarray): False operand.

**Returns:**

* `numpy.ndarray`: numpy.where(c, t, f)

***

[![](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/ops_impl.py#L149)

### function `numpy_where`

```python
numpy_where(c: ndarray, t: ndarray, f: ndarray) → Tuple[ndarray]
```

Compute the equivalent of numpy.where.

**Args:**

* `c` (numpy.ndarray): Condition operand.
* `t` (numpy.ndarray): True operand.
* `f` (numpy.ndarray): False operand.

**Returns:**

* `numpy.ndarray`: numpy.where(c, t, f)

***

[![](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/ops_impl.py#L168)

### function `numpy_add`

```python
numpy_add(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute add in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Add-13>

**Args:**

* `a` (numpy.ndarray): First operand.
* `b` (numpy.ndarray): Second operand.

**Returns:**

* `Tuple[numpy.ndarray]`: Result, has same element type as two inputs

***

[![](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/ops_impl.py#L219)

### function `numpy_constant`

```python
numpy_constant(**kwargs)
```

Return the constant passed as a kwarg.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Constant-13>

**Args:**

* `**kwargs`: keyword arguments

**Returns:**

* `Any`: The stored constant.

***

[![](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/ops_impl.py#L310)

### function `numpy_matmul`

```python
numpy_matmul(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute matmul in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#MatMul-13>

**Args:**

* `a` (numpy.ndarray): N-dimensional matrix A
* `b` (numpy.ndarray): N-dimensional matrix B

**Returns:**

* `Tuple[numpy.ndarray]`: Matrix multiply results from A \* B

***

[![](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/ops_impl.py#L328)

### function `numpy_relu`

```python
numpy_relu(x: ndarray) → Tuple[ndarray]
```

Compute relu in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Relu-14>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L344)

### function `numpy_sigmoid`

```python
numpy_sigmoid(x: ndarray) → Tuple[ndarray]
```

Compute sigmoid in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Sigmoid-13>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L360)

### function `numpy_softmax`

```python
numpy_softmax(x, axis=1, keepdims=True)
```

Compute softmax in numpy according to ONNX spec.

Softmax is currently not supported in FHE.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#softmax-13>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `axis` (None, int, tuple of int): Axis or axes along which a softmax's sum is performed. If None, it will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis. Default to 1.
* `keepdims` (bool): If True, the axes which are reduced along the sum are left in the result as dimensions with size one. Default to True.

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L383)

### function `numpy_cos`

```python
numpy_cos(x: ndarray) → Tuple[ndarray]
```

Compute cos in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Cos-7>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L399)

### function `numpy_cosh`

```python
numpy_cosh(x: ndarray) → Tuple[ndarray]
```

Compute cosh in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Cosh-9>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L415)

### function `numpy_sin`

```python
numpy_sin(x: ndarray) → Tuple[ndarray]
```

Compute sin in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Sin-7>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L431)

### function `numpy_sinh`

```python
numpy_sinh(x: ndarray) → Tuple[ndarray]
```

Compute sinh in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Sinh-9>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L447)

### function `numpy_tan`

```python
numpy_tan(x: ndarray) → Tuple[ndarray]
```

Compute tan in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Tan-7>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L463)

### function `numpy_tanh`

```python
numpy_tanh(x: ndarray) → Tuple[ndarray]
```

Compute tanh in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Tanh-13>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L479)

### function `numpy_acos`

```python
numpy_acos(x: ndarray) → Tuple[ndarray]
```

Compute acos in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Acos-7>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L495)

### function `numpy_acosh`

```python
numpy_acosh(x: ndarray) → Tuple[ndarray]
```

Compute acosh in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Acosh-9>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L511)

### function `numpy_asin`

```python
numpy_asin(x: ndarray) → Tuple[ndarray]
```

Compute asin in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Asin-7>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L527)

### function `numpy_asinh`

```python
numpy_asinh(x: ndarray) → Tuple[ndarray]
```

Compute sinh in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Asinh-9>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L543)

### function `numpy_atan`

```python
numpy_atan(x: ndarray) → Tuple[ndarray]
```

Compute atan in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Atan-7>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L559)

### function `numpy_atanh`

```python
numpy_atanh(x: ndarray) → Tuple[ndarray]
```

Compute atanh in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Atanh-9>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L575)

### function `numpy_elu`

```python
numpy_elu(x: ndarray, alpha: float = 1) → Tuple[ndarray]
```

Compute elu in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Elu-6>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `alpha` (float): Coefficient

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L591)

### function `numpy_selu`

```python
numpy_selu(
    x: ndarray,
    alpha: float = 1.6732632423543772,
    gamma: float = 1.0507009873554805
) → Tuple[ndarray]
```

Compute selu in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Selu-6>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `alpha` (float): Coefficient
* `gamma` (float): Coefficient

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L613)

### function `numpy_celu`

```python
numpy_celu(x: ndarray, alpha: float = 1) → Tuple[ndarray]
```

Compute celu in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Celu-12>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `alpha` (float): Coefficient

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L629)

### function `numpy_leakyrelu`

```python
numpy_leakyrelu(x: ndarray, alpha: float = 0.01) → Tuple[ndarray]
```

Compute leakyrelu in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#LeakyRelu-6>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `alpha` (float): Coefficient

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L645)

### function `numpy_thresholdedrelu`

```python
numpy_thresholdedrelu(x: ndarray, alpha: float = 1) → Tuple[ndarray]
```

Compute thresholdedrelu in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#ThresholdedRelu-10>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `alpha` (float): Coefficient

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L664)

### function `numpy_hardsigmoid`

```python
numpy_hardsigmoid(
    x: ndarray,
    alpha: float = 0.2,
    beta: float = 0.5
) → Tuple[ndarray]
```

Compute hardsigmoid in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#HardSigmoid-6>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `alpha` (float): Coefficient
* `beta` (float): Coefficient

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L683)

### function `numpy_softplus`

```python
numpy_softplus(x: ndarray) → Tuple[ndarray]
```

Compute softplus in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Softplus-1>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L700)

### function `numpy_abs`

```python
numpy_abs(x: ndarray) → Tuple[ndarray]
```

Compute abs in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Abs-13>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L717)

### function `numpy_div`

```python
numpy_div(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute div in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Div-14>

**Args:**

* `a` (numpy.ndarray): Input tensor
* `b` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L749)

### function `numpy_mul`

```python
numpy_mul(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute mul in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Mul-14>

**Args:**

* `a` (numpy.ndarray): Input tensor
* `b` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L768)

### function `numpy_sub`

```python
numpy_sub(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute sub in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Sub-14>

**Args:**

* `a` (numpy.ndarray): Input tensor
* `b` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L787)

### function `numpy_log`

```python
numpy_log(x: ndarray) → Tuple[ndarray]
```

Compute log in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Log-13>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L830)

### function `numpy_erf`

```python
numpy_erf(x: ndarray) → Tuple[ndarray]
```

Compute erf in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Erf-13>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L847)

### function `numpy_hardswish`

```python
numpy_hardswish(x: ndarray) → Tuple[ndarray]
```

Compute hardswish in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#hardswish-14>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L868)

### function `numpy_exp`

```python
numpy_exp(x: ndarray) → Tuple[ndarray]
```

Compute exponential in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Exp-13>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: The exponential of the input tensor computed element-wise

***

[![](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/ops_impl.py#L885)

### function `numpy_equal`

```python
numpy_equal(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute equal in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Equal-11>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L904)

### function `numpy_not`

```python
numpy_not(x: ndarray) → Tuple[ndarray]
```

Compute not in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Not-1>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L921)

### function `numpy_not_float`

```python
numpy_not_float(x: ndarray) → Tuple[ndarray]
```

Compute not in numpy according to ONNX spec and cast outputs to floats.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Not-1>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L938)

### function `numpy_greater`

```python
numpy_greater(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute greater in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Greater-13>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L957)

### function `numpy_greater_float`

```python
numpy_greater_float(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute greater in numpy according to ONNX spec and cast outputs to floats.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Greater-13>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L976)

### function `numpy_greater_or_equal`

```python
numpy_greater_or_equal(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute greater or equal in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#GreaterOrEqual-12>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L995)

### function `numpy_greater_or_equal_float`

```python
numpy_greater_or_equal_float(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute greater or equal in numpy according to ONNX specs and cast outputs to floats.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#GreaterOrEqual-12>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1014)

### function `numpy_less`

```python
numpy_less(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute less in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Less-13>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1033)

### function `numpy_less_float`

```python
numpy_less_float(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute less in numpy according to ONNX spec and cast outputs to floats.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Less-13>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1052)

### function `numpy_less_or_equal`

```python
numpy_less_or_equal(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute less or equal in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#LessOrEqual-12>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1071)

### function `numpy_less_or_equal_float`

```python
numpy_less_or_equal_float(x: ndarray, y: ndarray) → Tuple[ndarray]
```

Compute less or equal in numpy according to ONNX spec and cast outputs to floats.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#LessOrEqual-12>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `y` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1090)

### function `numpy_identity`

```python
numpy_identity(x: ndarray) → Tuple[ndarray]
```

Compute identity in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Identity-14>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1128)

### function `numpy_transpose`

```python
numpy_transpose(x: ndarray, perm=None) → Tuple[ndarray]
```

Transpose in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Transpose-13>

**Args:**

* `x` (numpy.ndarray): Input tensor
* `perm` (numpy.ndarray): Permutation of the axes

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1206)

### function `numpy_avgpool`

```python
numpy_avgpool(
    x: ndarray,
    ceil_mode: int,
    kernel_shape: Tuple[int, ],
    pads: Tuple[int, ] = None,
    strides: Tuple[int, ] = None
) → Tuple[ndarray]
```

Compute Average Pooling using Torch.

Currently supports 2d average pooling with torch semantics. This function is ONNX compatible.

See: <https://github.com/onnx/onnx/blob/main/docs/Operators.md#AveragePool>

**Args:**

* `x` (numpy.ndarray): input data (many dtypes are supported). Shape is N x C x H x W for 2d
* `ceil_mode` (int): ONNX rounding parameter, expected 0 (torch style dimension computation)
* `kernel_shape` (Tuple\[int, ...]): shape of the kernel. Should have 2 elements for 2d conv
* `pads` (Tuple\[int, ...]): padding in ONNX format (begin, end) on each axis
* `strides` (Tuple\[int, ...]): stride of the convolution on each axis

**Returns:**

* `res` (numpy.ndarray): a tensor of size (N x InChannels x OutHeight x OutWidth).
* `See https`: //pytorch.org/docs/stable/generated/torch.nn.AvgPool2d.html

**Raises:**

* `AssertionError`: if the pooling arguments are wrong

***

[![](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/ops_impl.py#L1273)

### function `numpy_maxpool`

```python
numpy_maxpool(
    x: ndarray,
    kernel_shape: Tuple[int, ],
    strides: Tuple[int, ] = None,
    auto_pad: str = 'NOTSET',
    pads: Tuple[int, ] = None,
    dilations: Optional[Tuple[int, ], List[int]] = None,
    ceil_mode: int = 0,
    storage_order: int = 0
) → Tuple[ndarray]
```

Compute Max Pooling using Torch.

Currently supports 2d max pooling with torch semantics. This function is ONNX compatible.

See: <https://github.com/onnx/onnx/blob/main/docs/Operators.md#MaxPool>

**Args:**

* `x` (numpy.ndarray): the input
* `kernel_shape` (Union\[Tuple\[int, ...], List\[int]]): shape of the kernel
* `strides` (Optional\[Union\[Tuple\[int, ...], List\[int]]]): stride along each spatial axis set to 1 along each spatial axis if not set
* `auto_pad` (str): padding strategy, default = "NOTSET"
* `pads` (Optional\[Union\[Tuple\[int, ...], List\[int]]]): padding for the beginning and ending along each spatial axis (D1\_begin, D2\_begin, ..., D1\_end, D2\_end, ...) set to 0 along each spatial axis if not set
* `dilations` (Optional\[Union\[Tuple\[int, ...], List\[int]]]): dilation along each spatial axis set to 1 along each spatial axis if not set
* `ceil_mode` (int): ceiling mode, default = 1
* `storage_order` (int): storage order, 0 for row major, 1 for column major, default = 0

**Returns:**

* `res` (numpy.ndarray): a tensor of size (N x InChannels x OutHeight x OutWidth).
* `See https`: //pytorch.org/docs/stable/generated/torch.nn.AvgPool2d.html

***

[![](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/ops_impl.py#L1376)

### function `numpy_cast`

```python
numpy_cast(data: ndarray, to: int) → Tuple[ndarray]
```

Execute ONNX cast in Numpy.

For traced values during compilation, it supports only booleans, which are converted to float. For raw values (used in constant folding or shape computations), any cast is allowed.

See: <https://github.com/onnx/onnx/blob/main/docs/Operators.md#Cast>

**Args:**

* `data` (numpy.ndarray): Input encrypted tensor
* `to` (int): integer value of the onnx.TensorProto DataType enum

**Returns:**

* `result` (numpy.ndarray): a tensor with the required data type

***

[![](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/ops_impl.py#L1401)

### function `numpy_batchnorm`

```python
numpy_batchnorm(
    x: ndarray,
    scale: ndarray,
    bias: ndarray,
    input_mean: ndarray,
    input_var: ndarray,
    epsilon=1e-05,
    momentum=0.9,
    training_mode=0
) → Tuple[ndarray]
```

Compute the batch normalization of the input tensor.

This can be expressed as:

Y = (X - input\_mean) / sqrt(input\_var + epsilon) \* scale + B

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#BatchNormalization-14>

**Args:**

* `x` (numpy.ndarray): tensor to normalize, dimensions are in the form of (N,C,D1,D2,...,Dn), where N is the batch size, C is the number of channels.
* `scale` (numpy.ndarray): scale tensor of shape (C,)
* `bias` (numpy.ndarray): bias tensor of shape (C,)
* `input_mean` (numpy.ndarray): mean values to use for each input channel, shape (C,)
* `input_var` (numpy.ndarray): variance values to use for each input channel, shape (C,)
* `epsilon` (float): avoids division by zero
* `momentum` (float): momentum used during training of the mean/variance, not used in inference
* `training_mode` (int): if the model was exported in training mode this is set to 1, else 0

**Returns:**

* `numpy.ndarray`: Normalized tensor

***

[![](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/ops_impl.py#L1472)

### function `numpy_flatten`

```python
numpy_flatten(x: ndarray, axis: int = 1) → Tuple[ndarray]
```

Flatten a tensor into a 2d array.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Flatten-13>.

**Args:**

* `x` (numpy.ndarray): tensor to flatten
* `axis` (int): axis after which all dimensions will be flattened (axis=0 gives a 1D output)

**Returns:**

* `result`: flattened tensor

***

[![](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/ops_impl.py#L1490)

### function `numpy_or`

```python
numpy_or(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute or in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Or-7>

**Args:**

* `a` (numpy.ndarray): Input tensor
* `b` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1508)

### function `numpy_or_float`

```python
numpy_or_float(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute or in numpy according to ONNX spec and cast outputs to floats.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Or-7>

**Args:**

* `a` (numpy.ndarray): Input tensor
* `b` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1526)

### function `numpy_round`

```python
numpy_round(a: ndarray) → Tuple[ndarray]
```

Compute round in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Round-11> Remark that ONNX Round operator is actually a rint, since the number of decimals is forced to be 0

**Args:**

* `a` (numpy.ndarray): Input tensor whose elements to be rounded.

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor with rounded input elements.

***

[![](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/ops_impl.py#L1543)

### function `numpy_pow`

```python
numpy_pow(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute pow in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Pow-13>

**Args:**

* `a` (numpy.ndarray): Input tensor whose elements to be raised.
* `b` (numpy.ndarray): The power to which we want to raise.

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor.

***

[![](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/ops_impl.py#L1666)

### function `numpy_floor`

```python
numpy_floor(x: ndarray) → Tuple[ndarray]
```

Compute Floor in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Floor-1>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1680)

### function `numpy_max`

```python
numpy_max(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute Max in numpy according to ONNX spec.

Computes the max between the first input and a float constant.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Max-1>

**Args:**

* `a` (numpy.ndarray): Input tensor
* `b` (numpy.ndarray): Constant tensor to compare to the first input

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1697)

### function `numpy_min`

```python
numpy_min(a: ndarray, b: ndarray) → Tuple[ndarray]
```

Compute Min in numpy according to ONNX spec.

Computes the minimum between the first input and a float constant.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Max-1>

**Args:**

* `a` (numpy.ndarray): Input tensor
* `b` (numpy.ndarray): Constant tensor to compare to the first input

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1714)

### function `numpy_sign`

```python
numpy_sign(x: ndarray) → Tuple[ndarray]
```

Compute Sign in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Sign-9>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1728)

### function `numpy_neg`

```python
numpy_neg(x: ndarray) → Tuple[ndarray]
```

Compute Negative in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Sign-9>

**Args:**

* `x` (numpy.ndarray): Input tensor

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor

***

[![](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/ops_impl.py#L1742)

### function `numpy_concatenate`

```python
numpy_concatenate(*x: ndarray, axis: int) → Tuple[ndarray]
```

Apply concatenate in numpy according to ONNX spec.

See <https://github.com/onnx/onnx/blob/main/docs/Changelog.md#concat-13>

**Args:**

* `*x (numpy.ndarray)`: Input tensors to be concatenated.
* `axis` (int): Which axis to concat on.

**Returns:**

* `Tuple[numpy.ndarray]`: Output tensor.

***

[![](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/ops_impl.py#L25)

### class `RawOpOutput`

Type construct that marks an ndarray as a raw output of a quantized op.

***

[![](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/ops_impl.py#L42)

### class `ONNXMixedFunction`

A mixed quantized-raw valued onnx function.

ONNX functions will take inputs which can be either quantized or float. Some functions only take quantized inputs, but some functions take both types. For mixed functions we need to tag the parameters that do not need quantization. Thus quantized ops can know which inputs are not QuantizedArray and we avoid unnecessary wrapping of float values as QuantizedArrays.

[![](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/ops_impl.py#L52)

#### method `__init__`

```python
__init__(function, non_quant_params: Set[str], output_is_raw: bool = False)
```

Create the mixed function and raw parameter list.

**Args:**

* `function` (Any): function to be decorated
* `non_quant_params`: Set\[str]: set of parameters that will not be quantized (stored as numpy.ndarray)
* `output_is_raw` (bool): indicates whether the op outputs a value that should not be quantized


---

# 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.onnx.ops_impl.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.
