concrete.ml.onnx.ops_impl.md
Last updated
Last updated
concrete.ml.onnx.ops_impl
ONNX ops implementation in python + numpy.
cast_to_float
Cast values to floating points.
Args:
inputs
(Tuple[numpy.ndarray]): The values to consider.
Returns:
Tuple[numpy.ndarray]
: The float values.
onnx_func_raw_args
Decorate a numpy onnx function to flag the raw/non quantized inputs.
Args:
*args (tuple[Any])
: function argument names
Returns:
result
(ONNXMixedFunction): wrapped numpy function with a list of mixed arguments
numpy_where_body
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)
numpy_where
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)
numpy_add
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
numpy_constant
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.
numpy_matmul
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
numpy_relu
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
numpy_sigmoid
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
numpy_softmax
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
numpy_cos
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
numpy_cosh
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
numpy_sin
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
numpy_sinh
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
numpy_tan
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
numpy_tanh
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
numpy_acos
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
numpy_acosh
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
numpy_asin
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
numpy_asinh
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
numpy_atan
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
numpy_atanh
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
numpy_elu
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
numpy_selu
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
numpy_celu
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
numpy_leakyrelu
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
numpy_thresholdedrelu
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
numpy_hardsigmoid
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
numpy_softplus
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
numpy_abs
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
numpy_div
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
numpy_mul
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
numpy_sub
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
numpy_log
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
numpy_erf
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
numpy_hardswish
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
numpy_exp