sima_utils.onnx.model_builder ============================= .. py:module:: sima_utils.onnx.model_builder Attributes ---------- .. autoapisummary:: sima_utils.onnx.model_builder.OnnxNode Classes ------- .. autoapisummary:: sima_utils.onnx.model_builder.OnnxModelBuilder Functions --------- .. autoapisummary:: sima_utils.onnx.model_builder.get_onnx_node_output_name Module Contents --------------- .. py:data:: OnnxNode .. py:function:: get_onnx_node_output_name(node: OnnxNode) -> str Gets the output name of the given node with only one output. Args: node: A node in ONNX model. :returns: A string corresponding to the node's single output. .. py:class:: OnnxModelBuilder Helper class to build onnx model. Usage: # Initialization builder = OnnxModelBuilder() # Create arbitrary number of model inputs input_node = builder.create_input_node("input", input_shape, input_dtype) # Create nodes; use helper functions provided for each operation type. conv_node = builder.make_conv_node(input_node, np_weights, np_bias, **conv_attrs) ... # Create model outputs; use get_onnx_node_output_name to get the names from output nodes builder.create_output_node(get_onnx_node_output_name(conv_node), output_shape, output_dtype) # Finalize model and save to a file builder.create_and_save_model(Path(onnx_file_path)) .. attribute:: IR_VERSION IR version of the onnx model. .. attribute:: OPSET_ID Operator set id of the onnx model. .. attribute:: _input_nodes Input nodes of the onnx model. .. attribute:: _output_nodes Output nodes of the onnx model. .. attribute:: _initializer_list List of initializers (constants) used in the model. .. attribute:: _node_list List of nodes created for a model. .. attribute:: _op_count Dictionary keeping track of quantity of created nodes per op_type. .. py:attribute:: IR_VERSION :type: ClassVar[int] :value: 8 .. py:attribute:: OPSET_ID :type: ClassVar[int] :value: 17 .. py:method:: create_model(model_name: str) -> onnx.ModelProto Creates the model. :param model_name: The name of the model. :returns: An ONNX ModelProto object defining the ONNX model. .. py:method:: create_and_save_model(onnx_file_name: pathlib.Path) Creates and saves the model, performing also shape inference in the process. :param onnx_file_name: A path to the file in which the ONNX model will be saved. .. py:method:: create_input_node(name: str, shape: collections.abc.Sequence[int], dtype: type = np.float32) -> OnnxNode Creates an input node with the provided name, shape and data type. :param name: Input's name. :param shape: Input's shape. :param dtype: Input's data type. :returns: The OnnxNode object (onnx.ValueInfoProto) for the created input node. .. py:method:: create_output_node(name: str, shape: collections.abc.Sequence[int], dtype: type = np.float32) Creates an output node with the provided name, shape and data type. :param name: Output's name. :param shape: Output's shape. :param dtype: Output's data type. .. py:method:: create_initializer(name: str | None, value: int | float | numpy.ndarray) -> OnnxNode Creates an initializer with the name. :param name: Name of the initializer. If name is None, use "Constant_{idx}". :param value: Value of the initializer. :returns: An OnnxNode object (onnx.TensorProto) created for the initializer. .. py:method:: build_op(input_nodes: collections.abc.Sequence[OnnxNode], op_type: str, **kwargs) -> OnnxNode Builds an ONNX node. :param input_nodes: A list of input nodes. :param op_type: Name of the operator type. :param \*\*kwargs: Operator attributes. :returns: Created OnnxNode (onnx.NodeProto) object. .. py:method:: make_conv_node(input_node: OnnxNode, weight: numpy.ndarray, bias: numpy.ndarray | None = None, auto_pad: str | None = None, dilations: collections.abc.Sequence[int] | None = None, strides: collections.abc.Sequence[int] | None = None, group: int | None = None, kernel_shape: collections.abc.Sequence[int] | None = None, pads: collections.abc.Sequence[int] | None = None) -> OnnxNode Create an ONNX Conv operator node. https://onnx.ai/onnx/operators/onnx__Conv.html#conv-11 :param input_node: Input node to Conv operator node. :param weight: Weight tensor numpy array. :param bias: Optional 1D bias tensor numpy array. :param auto_pad: Optional string value for Conv 'auto_pad' attribute. Valid values are NOTSET, SAME_UPPER, SAME_LOWER and VALID. If None, the 'auto_pad' attribute will take the default (NOTSET) value. :param dilations: Optional sequence of integers for Conv 'dilations' attribute. If None, the 'dilations' attribute will be set to 1 along each spatial axis. :param strides: Stride along each spatial axis. If not present, the stride defaults is 1 along each spatial axis. :param group: Optional integer value for Conv 'groups' attribute. If None, the 'groups' attribute will be set to 1. :param kernel_shape: Optional sequence of integers for Conv 'kernel_shape' attribute. If None, the 'kernel_shape' attribute will be inferred from weight shape. :param pads: Optional sequence of integers for Conv 'pads' attribute. If None, the 'pads' attribute will be set to 0 along start and end of each spatial axis. :returns: Onnx NodeProto instance containing the Conv operation. .. py:method:: make_conv_transpose_node(input_node: OnnxNode, weight: numpy.ndarray, bias: numpy.ndarray | None = None, auto_pad: str | None = None, dilations: collections.abc.Sequence[int] | None = None, strides: collections.abc.Sequence[int] | None = None, group: int | None = None, kernel_shape: collections.abc.Sequence[int] | None = None, pads: collections.abc.Sequence[int] | None = None, output_padding: collections.abc.Sequence[int] | None = None, output_shape: collections.abc.Sequence[int] | None = None) -> OnnxNode Create an ONNX ConvTranspose operator node. https://onnx.ai/onnx/operators/onnx__ConvTranspose.html#convtranspose-11 :param input_node: Input node to ConvTranspose operator node. :param weight: Weight tensor numpy array. :param bias: Optional 1D bias tensor numpy array. :param auto_pad: Optional string value for Conv 'auto_pad' attribute. Valid values are NOTSET, SAME_UPPER, SAME_LOWER and VALID. If None, the 'auto_pad' attribute will take the default (NOTSET) value. :param dilations: Optional sequence of integers for Conv 'dilations' attribute. If None, the 'dilations' attribute will be set to 1 along each spatial axis. :param strides: Stride along each spatial axis. If not present, the stride defaults is 1 along each spatial axis. :param group: Optional integer value for Conv 'groups' attribute. If None, the 'groups' attribute will be set to 1. :param kernel_shape: Optional sequence of integers for Conv 'kernel_shape' attribute. If None, the 'kernel_shape' attribute will be inferred from weight shape. :param pads: Optional sequence of integers for Conv 'pads' attribute. If None, the 'pads' attribute will be set to 0 along start and end of each spatial axis. :param output_padding: Optional sequence of ints to add output shape padding (per spatial axis). Defaults to 0 per spatial axis if None. Typically not used together with output_shape. :param output_shape: Optional sequence of ints to explicitly set the output spatial shape. :returns: Onnx NodeProto instance containing the ConvTranspose operation. .. py:method:: make_avg_pool_node(input_node: OnnxNode, kernel_shape: collections.abc.Sequence[int], strides: collections.abc.Sequence[int] | None = None, pads: collections.abc.Sequence[int] | None = None, ceil_mode: bool = False, count_include_pad: bool = False, auto_pad: str = 'NOTSET') -> OnnxNode Create an ONNX AveragePool operator node. https://onnx.ai/onnx/operators/onnx__AveragePool.html#averagepool-11 :param input_node: Input node to the AveragePool operator node. :param kernel_shape: The size of the kernel along each axis. :param strides: Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis. :param pads: Padding for the beginning and ending along each spatial axis. If None, pads default to 0 along start and end of each spatial axis. :param ceil_mode: Whether to use ceil or floor (default) to compute the output shape. :param count_include_pad: Whether include pad pixels when calculating values for the edges. Default is 0, doesn’t count include pad. :param auto_pad: Valid values are NOTSET, SAME_UPPER, SAME_LOWER, and VALID. Default is 'NOTSET'. :returns: Onnx NodeProto instance containing the AveragePool operation. .. py:method:: make_global_avg_pool_node(input_node: OnnxNode) -> OnnxNode Create an ONNX GlobalAveragePool operator node. https://onnx.ai/onnx/operators/onnx__GlobalAveragePool.html#globalaveragepool-1 :param input_node: Input node to the GlobalAveragePool operator node. :returns: Onnx NodeProto instance containing the GlobalAveragePool operation. .. py:method:: make_global_max_pool_node(input_node: OnnxNode) -> OnnxNode Create an ONNX GlobalMaxPool operator node. https://onnx.ai/onnx/operators/onnx__GlobalMaxPool.html#globalmaxpool-1 :param input_node: Input node to the GlobalMaxPool operator node. :returns: Onnx NodeProto instance containing the GlobalMaxPool operation. .. py:method:: make_max_pool_node(input_node: OnnxNode, kernel_shape: collections.abc.Sequence[int], dilations: collections.abc.Sequence[int] | None = None, strides: collections.abc.Sequence[int] | None = None, pads: collections.abc.Sequence[int] | None = None, ceil_mode: bool = False, storage_order: int = 0, auto_pad: str = 'NOTSET') -> OnnxNode Create an ONNX MaxPool operator node. https://onnx.ai/onnx/operators/onnx__MaxPool.html#maxpool-12 :param input_node: Input node to the MaxPool operator node. :param kernel_shape: The size of the kernel along each axis. :param dilations: Dilation value along each spatial axis of filter. If not present, the dilation defaults to 1 along each spatial axis. :param strides: Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis. :param pads: Padding for the beginning and ending along each spatial axis. If None, pads default to 0 along start and end of each spatial axis. :param ceil_mode: Whether to use ceil or floor (default) to compute the output shape. :param storage_order: The storage order of the tensor. 0 is row major, and 1 is column major. :param auto_pad: Valid values are NOTSET, SAME_UPPER, SAME_LOWER, and VALID. Default is 'NOTSET'. :returns: Onnx NodeProto instance containing the MaxPool operation. .. py:method:: make_batch_normalization_node(input_node: OnnxNode, scale: OnnxNode | numpy.ndarray, bias: OnnxNode | numpy.ndarray, input_mean: OnnxNode | numpy.ndarray, input_var: OnnxNode | numpy.ndarray, epsilon: float = 1e-05, momentum: float = 0.9) -> OnnxNode Create an ONNX BatchNormalization operator node. https://onnx.ai/onnx/operators/onnx__BatchNormalization.html#batchnormalization-15 :param input_node: Input node to the BatchNormalization operator node. :param scale: Scale tensor of shape C. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param bias: Bias tensor of shape C. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param input_mean: Mean tensor of shape C. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param input_var: Variance tensor of shape C. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param epsilon: The epsilon value to use to avoid division by zero. Default is 1e-05. :param momentum: Float value for the momentum used in running mean and variance computation. :returns: Onnx NodeProto instance containing the BatchNormalization operation. .. py:method:: make_clip_node(input_node: OnnxNode, min: numpy.ndarray | None = None, max: numpy.ndarray | None = None) -> OnnxNode Create an ONNX Clip operator node. https://onnx.ai/onnx/operators/onnx__Clip.html#clip-13 :param input_node: Input node to the Clip operator node. :param min: Minimum value for clipping. If None, no lower bound is applied. :param max: Maximum value for clipping. If None, no upper bound is applied. :returns: Onnx NodeProto instance containing the Clip operation. .. py:method:: make_concat_node(input_nodes: list[OnnxNode], axis: int) -> OnnxNode Create an ONNX Concat operator node. https://onnx.ai/onnx/operators/onnx__Concat.html#concat-13 :param input_nodes: List of input nodes to be concatenated. :param axis: Which axis to concat on. :returns: Onnx NodeProto instance containing the Concat operation. .. py:method:: make_einsum_node(input_nodes: list[OnnxNode], equation: str) -> OnnxNode Create an ONNX Einsum operator node. https://onnx.ai/onnx/operators/onnx__Einsum.html#einsum-12 :param input_nodes: List of input nodes for the Einsum operation. :param equation: Einsum expression string. :returns: Onnx NodeProto instance containing the Einsum operation. .. py:method:: make_erf_node(input_node: OnnxNode) -> OnnxNode Create an ONNX Erf operator node. https://onnx.ai/onnx/operators/onnx__Erf.html#erf-13 :param input_node: Input node to the Erf operator node. :returns: Onnx NodeProto instance containing the Erf operation. .. py:method:: make_flatten_node(input_node: OnnxNode, axis: int = 1) -> OnnxNode Create an ONNX Flatten operator node. https://onnx.ai/onnx/operators/onnx__Flatten.html#flatten-13 :param input_node: Input node to the Flatten operator node. :param axis: Integer specifying the axis from which to flatten the input tensor. All dimensions up to (but not including) this axis are preserved, and all following dimensions are flattened into one. Default is 1. :returns: Onnx NodeProto instance containing the Flatten operation. .. py:method:: make_gemm_node(input_a: OnnxNode, input_b: OnnxNode, input_c: OnnxNode | None = None, alpha: float = 1.0, beta: float = 1.0, transA: int = 0, transB: int = 0) -> OnnxNode Create an ONNX Gemm (General Matrix Multiplication) operator node. https://onnx.ai/onnx/operators/onnx__Gemm.html#gemm-13 :param input_a: First input matrix (A). :param input_b: Second input matrix (B). :param input_c: Optional bias matrix (C). If None, no bias is added. :param alpha: Scalar multiplier for A * B. Default is 1.0. :param beta: Scalar multiplier for C. Default is 1.0. :param transA: Whether A should be transposed. :param transB: Whether B should be transposed. :returns: Onnx NodeProto instance containing the Gemm operation. .. py:method:: make_reduce_mean_node(input_node: OnnxNode, axes: collections.abc.Sequence[int] | None = None, keepdims: int = 1) -> OnnxNode Create an ONNX ReduceMean operator node. https://onnx.ai/onnx/operators/onnx__ReduceMean.html#reducemean-13 :param input_node: Input node to the ReduceMean operator node. :param axes: A list of integers, along which to reduce. If None, reduction is performed over all dimensions. :param keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. :returns: Onnx NodeProto instance containing the ReduceMean operation. .. py:method:: make_reduce_sum_node(input_node: OnnxNode, axes: numpy.ndarray | None = None, keepdims: int = 1, noop_with_empty_axes: int = 0) -> OnnxNode Create an ONNX ReduceSum operator node. https://onnx.ai/onnx/operators/onnx__ReduceSum.html#reducesum-13 :param input_node: Input node to the ReduceSum operator node. :param axes: Optional numpy array specifying the axes along which to reduce. If None, reduction is performed over all dimensions. :param keepdims: Keep the reduced dimension or not, default 1 means keep reduced dimension. :param noop_with_empty_axes: Defines behavior when axes is not provided or is empty. Integer flag (0 or 1). If 1 and axes is empty, input is unchanged and reduce sum behaves like no-op. If 0, reduction happens over all dimensions. :returns: Onnx NodeProto instance containing the ReduceSum operation. .. py:method:: make_reshape_node(input_node: OnnxNode, shape: numpy.ndarray, allowzero: int = 0) -> OnnxNode Create an ONNX Reshape operator node. https://onnx.ai/onnx/operators/onnx__Reshape.html#reshape-14 :param input_node: Input node to the Reshape operator node. :param shape: 1D numpy array specifying the new shape for the input tensor. :param allowzero: By default, when any value in the ‘shape’ input is equal to zero the corresponding dimension value is copied from the input tensor dynamically. allowzero=1 indicates that if any value in the ‘shape’ input is set to zero, the zero value is honored, similar to NumPy. :returns: Onnx NodeProto instance containing the Reshape operation. .. py:method:: make_resize_node(input_node: OnnxNode, roi: numpy.ndarray | None = None, scales: numpy.ndarray | None = None, sizes: numpy.ndarray | None = None, coordinate_transformation_mode: str = 'half_pixel', cubic_coeff_a: float = -0.75, exclude_outside: int = 0, extrapolation_value: float = 0.0, mode: str = 'nearest', nearest_mode: str = 'round_prefer_floor') -> OnnxNode Create an ONNX Resize operator node. https://onnx.ai/onnx/operators/onnx__Resize.html#resize-13 :param input_node: Input node to the Resize operator node. :param roi: Optional numpy array specifying the region of interest for resizing. :param scales: Optional numpy array specifying scale factors for each dimension. :param sizes: Optional numpy array specifying the target size for each dimension. :param coordinate_transformation_mode: Specifies how to transform coordinates. Common values: 'half_pixel', 'align_corners', 'asymmetric'. Default is 'half_pixel'. :param cubic_coeff_a: Coefficient for cubic interpolation. Default is -0.75. :param exclude_outside: Integer flag (0 or 1). If 1, exclude values outside the input boundaries. Default is 0. :param extrapolation_value: Value used for extrapolation when sampling outside input boundaries. Default is 0.0. :param mode: Interpolation mode. Valid values: 'nearest', 'linear', 'cubic'. Default is 'nearest'. :param nearest_mode: Specifies rounding mode for nearest interpolation. Default is 'round_prefer_floor'. :returns: Onnx NodeProto instance containing the Resize operation. .. py:method:: make_matmul_node(lhs: OnnxNode | numpy.ndarray, rhs: OnnxNode | numpy.ndarray) -> OnnxNode Create an ONNX MatMul operator node. https://onnx.ai/onnx/operators/onnx__MatMul.html#matmul-13 At least one of the inputs (lhs, rhs) must be a variable (onnx.NodeProto object). :param lhs: Input lhs node or numpy array to MatMul operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param rhs: Input rhs node or numpy array to MatMul operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :returns: Onnx NodeProto instance containing the MatMul operation. .. py:method:: make_pad_node(input_node: OnnxNode, pads: numpy.ndarray, constant_value: int | str | bool = 0, mode: str = 'constant') -> OnnxNode Create an ONNX Pad operator node. https://onnx.ai/onnx/operators/onnx__Pad.html#pad-13 :param input_node: The input tensor node to pad. :param pads: Tensor of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. :param constant_value: A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False). :param mode: Padding mode. Can be 'constant' (default), 'reflect', or 'edge'. :returns: Onnx NodeProto instance containing the Pad operation. .. py:method:: make_slice_node(data_node: OnnxNode, starts: numpy.ndarray, ends: numpy.ndarray, axes: numpy.ndarray | None = None, steps: numpy.ndarray | None = None) -> OnnxNode Create an ONNX Slice operator node. https://onnx.ai/onnx/operators/onnx__Slice.html#slice-13 :param data_node: The input tensor node to slice. :param starts: 1D numpy array of int64 specifying start indices. :param ends: 1D numpy array of int64 specifying end indices. :param axes: (Optional) 1D numpy array of int64 specifying axes. :param steps: (Optional) 1D numpy array of int64 specifying steps. :returns: Onnx NodeProto instance containing the Slice operation. .. py:method:: make_split_node(input_node: OnnxNode, output_names: list[str], axis: int = 0, split: numpy.ndarray | None = None) -> OnnxNode Create an ONNX Split operator node. https://onnx.ai/onnx/operators/onnx__Split.html#split-13 :param input_node: The input tensor node to split. :param output_names: List of output names. :param axis: Axis along which to split. Default is 0. :param split: (Optional) 1D numpy array of int64 specifying sizes for each output. Values should be >= 0. Sum of the values must be equal to the dim value at ‘axis’ specified. :returns: Onnx NodeProto instance containing the Split operation. .. py:method:: make_sqrt_node(input_node: OnnxNode) -> OnnxNode Create an ONNX Sqrt operator node. https://onnx.ai/onnx/operators/onnx__Sqrt.html#sqrt-13 :param input_node: The input tensor node. :returns: Onnx NodeProto instance containing the Sqrt operation. .. py:method:: make_tanh_node(input_node: OnnxNode) -> OnnxNode Create an ONNX Tanh operator node. https://onnx.ai/onnx/operators/onnx__Tanh.html#tanh-13 :param input_node: The input tensor node. :returns: Onnx NodeProto instance containing the Sqrt operation. .. py:method:: make_add_node(lhs: OnnxNode | numpy.ndarray, rhs: OnnxNode | numpy.ndarray) -> OnnxNode Create an ONNX Add operator node. https://onnx.ai/onnx/operators/onnx__Add.html#add-14 At least one of the inputs (lhs, rhs) must be a variable (onnx.NodeProto object). :param lhs: Input lhs node or numpy array to Add operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param rhs: Input rhs node or numpy array to Add operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :returns: Onnx NodeProto instance containing the Add operation. .. py:method:: make_sub_node(lhs: OnnxNode | numpy.ndarray, rhs: OnnxNode | numpy.ndarray) -> OnnxNode Create an ONNX Sub operator node. https://onnx.ai/onnx/operators/onnx__Sub.html#sub-14 At least one of the inputs (lhs, rhs) must be a variable (onnx.NodeProto object). :param lhs: Input lhs node or numpy array to Sub operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param rhs: Input rhs node or numpy array to Sub operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :returns: Onnx NodeProto instance containing the Sub operation. .. py:method:: make_mul_node(lhs: OnnxNode | numpy.ndarray, rhs: OnnxNode | numpy.ndarray) -> OnnxNode Create an ONNX Mul operator node. https://onnx.ai/onnx/operators/onnx__Mul.html#mul-14 At least one of the inputs (lhs, rhs) must be a variable (onnx.NodeProto object). :param lhs: Input lhs node or numpy array to Mul operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param rhs: Input rhs node or numpy array to Mul operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :returns: Onnx NodeProto instance containing the Mul operation. .. py:method:: make_div_node(lhs: OnnxNode | numpy.ndarray, rhs: OnnxNode | numpy.ndarray) -> OnnxNode Create an ONNX Div operator node. https://onnx.ai/onnx/operators/onnx__Div.html#div-14 At least one of the inputs (lhs, rhs) must be a variable (onnx.NodeProto object). :param lhs: Input lhs node or numpy array to Div operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param rhs: Input rhs node or numpy array to Div operator node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :returns: Onnx NodeProto instance containing the Div operation. .. py:method:: make_elu_node(input_node: OnnxNode, alpha: float = 1.0) -> OnnxNode Create an ONNX Elu operator node. https://onnx.ai/onnx/operators/onnx__Elu.html :param input_node: Input node of Elu operator. :param alpha: Coefficient of ELU. :returns: Onnx NodeProto instance containing the Elu operation. .. py:method:: make_hardsigmoid_node(input_node: OnnxNode, alpha: float = 0.2, beta: float = 0.5) -> OnnxNode Create an ONNX HardSigmoid operator node. https://onnx.ai/onnx/operators/onnx__HardSigmoid.html :param input_node: Input node of HardSigmoid operator. :param alpha: Value of alpha inside hardsigmoid equation. :param beta: Value of beta inside hardsigmoid equation. :returns: Onnx NodeProto instance containing the HardSigmoid operation. .. py:method:: make_hardswish_node(input_node: OnnxNode) -> OnnxNode Create an ONNX HardSwish operator node. https://onnx.ai/onnx/operators/onnx__HardSwish.html :param input_node: Input node of hardswish operator. :returns: Onnx NodeProto instance containing the HardSwish operation. .. py:method:: make_leakyrelu_node(input_node: OnnxNode, alpha: float = 0.01) -> OnnxNode Create an ONNX LeakyRelu operator node. https://onnx.ai/onnx/operators/onnx__LeakyRelu.html :param input_node: Input node of leakyrelu operator. :param alpha: Defines the coefficient of leakage. :returns: Onnx NodeProto instance containing the LeakyRelu operation. .. py:method:: make_relu_node(input_node: OnnxNode) -> OnnxNode Create an ONNX Relu operator node. https://onnx.ai/onnx/operators/onnx__Relu.html :param input_node: Input node of relu operator. :returns: Onnx NodeProto instance containing the Relu operation. .. py:method:: make_prelu_node(input_node: OnnxNode, slope: OnnxNode | numpy.ndarray) -> OnnxNode Create an ONNX PRelu operator node. https://onnx.ai/onnx/operators/onnx__PRelu.html Slope parameter must be unidirectionally broadcastable to input_node. :param input_node: Input node of prelu operator. :param slope: Input slope node or numpy array to PRelu operator node. In the case of a numpy :param array: :param the onnx.TensorProto object would be created and added to initializer list.: :returns: Onnx NodeProto instance containing the PRelu operation. .. py:method:: make_sigmoid_node(input_node: OnnxNode) -> OnnxNode Create an ONNX Sigmoid operator node. https://onnx.ai/onnx/operators/onnx__Sigmoid.html :param input_node: Input node of sigmoid operator. :returns: Onnx NodeProto instance containing the Sigmoid operation. .. py:method:: make_softmax_node(input_node: OnnxNode, axis: int = -1) -> OnnxNode Create an ONNX Softmax operator node. https://onnx.ai/onnx/operators/onnx__Softmax.html :param input_node: Input node of softmax operator. :param axis: Defines the dimension operator will be applied on. :returns: Onnx NodeProto instance containing the Softmax operation. .. py:method:: make_instance_normalization_node(input_node: OnnxNode, scale: OnnxNode | numpy.ndarray, bias: OnnxNode | numpy.ndarray, epsilon: float = 1e-05) -> OnnxNode Create an ONNX InstanceNormalization operator node. https://onnx.ai/onnx/operators/onnx__InstanceNormalization.html :param input_node: Input node of InstanceNormalization operator. :param scale: The 1D input scale tensor of the same size as the channel dim of the input_node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param bias: The 1D input bias tensor of the same size as the channel dim of the input_node. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param epsilon: The epsilon value to use to avoid division by zero. :returns: Onnx NodeProto instance containing the InstanceNormalization operation. .. py:method:: make_layer_normalization_node(input_node: OnnxNode, scale: OnnxNode | numpy.ndarray, bias: OnnxNode | numpy.ndarray | None = None, axis: int = -1, epsilon: float = 1e-05, stash_type: int = 1) -> OnnxNode Create an ONNX LayerNormalization operator node. https://onnx.ai/onnx/operators/onnx__LayerNormalization.html Scale and bias (if present) parameters must be unidirectionally broadcastable to input_node. :param input_node: Input node of LayerNormalization operator. :param scale: Input scale tensor. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. :param bias: Optional input bias tensor. In the case of a numpy array, the onnx.TensorProto object would be created and added to initializer list. If None, bias would not be used in the layer_norm equation. :param axis: The first normalization dimension. If rank(input_node) is r, axis’ allowed range is [-r, r). Negative value means counting dimensions from the back. :param epsilon: The epsilon value to use to avoid division by zero. :param stash_type: Type of Mean and InvStdDev. This also specifies stage one’s computation precision. :returns: Onnx NodeProto instance containing the LayerNormalization operation. .. py:method:: make_squeeze_node(input_node: OnnxNode, axes: collections.abc.Sequence[int] | None = None) -> OnnxNode Create an ONNX Squeeze operator node. https://onnx.ai/onnx/operators/onnx__Squeeze.html :param input_node: Input node of Squeeze operator. :param axes: List of integers indicating the dimensions to squeeze. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(input_node). :returns: Onnx NodeProto instance containing the Squeeze operation. .. py:method:: make_transpose_node(input_node: OnnxNode, perm: collections.abc.Sequence[int] | None = None) -> OnnxNode Create an ONNX Transpose operator node. https://onnx.ai/onnx/operators/onnx__Transpose.html :param input_node: Input node of Transpose operator. :param perm: A list of integers. By default, reverse the dimensions, otherwise permute the axes :param according to the values given.: :returns: Onnx NodeProto instance containing the Transpose operation. .. py:method:: make_unsqueeze_node(input_node: OnnxNode, axes: collections.abc.Sequence[int]) -> OnnxNode Create an ONNX Unsqueeze operator node. https://onnx.ai/onnx/operators/onnx__Unsqueeze.html :param input_node: Input node of Unsqueeze operator. :param axes: List of integers indicating the dimensions to be inserted. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(expanded_node). :returns: Onnx NodeProto instance containing the Unsqueeze operation.