.. _l-functions: Functions ========= .. contents:: :local: :depth: 1 Summary +++++++ +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | function | class parent | truncated documentation | +======================================================================================================================+==============+================================================================================================================================================================+ | :func:`_default_inputs ` | | Guesses default inputs (float ones) if not specified. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_demangle ` | | Demangle a C++ identifier using c++filt | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_existing_names ` | | Makes the list of existing names. Returns a set of unique names including intermediate results. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_finalize_new_onnx ` | | | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_loss_elastic ` | | Implements mixture of losses l1 and l2. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_loss_l1 ` | | Implements loss l1. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_loss_l2 ` | | Implements loss l2. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_loss_log ` | | This only works for a binary classification. The log loss is `'log(yt, yp) = (1-yt)\log(1-yp) - yt\log(yp)`, this ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_munge_time ` | | Take a time from nvprof and convert it into a chrome://tracing time. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_axpy ` | | Returns the ONNX graph for function :math:`Y = f(X1, X2, \alpha) = \alpha X1 + X2`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_axpyw ` | | Returns the ONNX graph for function :math:`Y, Z = f(X1, X2, G, \alpha, \beta) = (Y, Z)` where :math:`Z = \beta G + \alpha X1` ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_axpyw2 ` | | Returns the ONNX graph for function :math:`Y, Z = f(X1, X2, G, \alpha, \beta) = (Y, Z)` where :math:`Z = \beta G + \alpha X1` ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_copy ` | | Returns the ONNX graph for function :math:`Y = X`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_derivative_fw ` | | Implements a gradient based on class `OrtModuleGraphBuilder`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_derivative_loss ` | | Implements a gradient based on class `PyGradientGraphBuilder`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_grad_loss_absolute_error ` | | Returns the ONNX graph for function :math:`Y = f(X1, X2) = \lVert X1 - X2 \rVert` or :math:`Y = f(X1, X2) = \lVert (X1 - X2)w \rVert` ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_grad_loss_elastic_error ` | | Returns the ONNX graph for function :math:`Y = f(X1, X2) = \beta \lVert X1 - X2 \rVert + \alpha \lVert X1 - X2 \rVert^2` ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_grad_loss_square_error ` | | Returns the ONNX graph for function :math:`Y = f(X1, X2) = \lVert (X1 - X2) \rVert ^2` or :math:`Y = f(X1, X2) = \lVert (\sqrt{w}(X1 - X2) \rVert ^2 w` ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_grad_penalty_elastic_error ` | | Returns the ONNX graph for function :math:`Y = f(W) = \beta \lVert W \rVert + \alpha \lVert W \rVert^2` *l1_weight* ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_grad_sigmoid_neg_log_loss_error ` | | The function the raw scores from a classifier, uses the sigmoid function to compute probabilities, then the log function ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_grad_square_error ` | | Returns the ONNX graph for the gradient of function :math:`Y = f(X1, X2) = \lVert X1 - X2 \rVert ^2` or :math:`Y = f(X1, X2) = \lVert X1 - X2 \rVert ^2 w` ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_linear_regression ` | | Returns the ONNX graph for function :math:`Y = f(X, A, B) = A X + B`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_n_penalty_elastic_error ` | | Returns the ONNX graph for function :math:`Y = f(W) = \beta \lVert W \rVert + \alpha \lVert W \rVert^2` *l1_weight* ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_rewrite_operator_node ` | | Replaces a node by a subgraph. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_square_error ` | | Returns the ONNX graph for function :math:`Y = f(X1, X2) = \lVert X1 - X2 \rVert ^2` or :math:`Y = f(X1, X2) = \lVert X1 - X2 \rVert ^2 w` ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_update_penalty_elastic_error ` | | Returns the ONNX graph for function :math:`Y = f(W) = W - 2 \beta W - \alpha sign(W)` *l1* is :math:`\beta` and ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_onnx_zero ` | | Returns the ONNX graph for function :math:`Y = X * 0`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_rewrite_op_no_grad ` | | Rewrites operators with no gradient. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_sizeof_fmt ` | | Format size with metric units (like nvvp) | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_unique_name ` | | Returns a name different from any name in *existing_names*. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_unique_name ` | | Returns a name different from any name in *existing_names*. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`add_initializer ` | | Adds an initializer to graph. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`add_loss_output ` | | Modifies an ONNX graph to add operators to score and allow training. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`check ` | | Runs a couple of functions to check the module is working. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`convert_trace_to_json ` | | Converts traces produced by :epkg:`nvprof` and saved with format *sqlite3* (extension `.sql`). The output format ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`device_to_providers ` | | Returns the corresponding providers for a specific device. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`dtype_to_var_type ` | | Converts a numpy dtype into a var type. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`fix_link_operator_md ` | | The redering of file `Operator.md `_ breaks links. This ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`function_onnx_graph ` | | Returns the ONNX graph corresponding to a function. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_class_names ` | | Returns the class names for the :epkg:`ImageNet` competition as a dictionary. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_max_opset ` | | Returns the highest available onnx opset version. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_onnx_opset ` | | Returns the opset associated to an opset. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_ort_device ` | | Converts device into :epkg:`C_OrtDevice`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_ort_device_from_session ` | | Retrieves the device from an object :epkg:`InferenceSession`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_ort_device_type ` | | Converts device into device type. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_supported_functions ` | | Returns the list of supported function by :func:`function_onnx_graph`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`get_train_initializer ` | | Returns the list of initializers to train. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`json_to_dataframe ` | | Converts a json dump obtained with function :func:`convert_trace_to_json` to a dataframe. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`json_to_dataframe_streaming ` | | Converts a big json dump (from :func:`convert_trace_to_json`) to a dataframe. The function processes the data by streaming ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`main ` | | Implements ``python -m onnxcustom ``. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`measure_time ` | | Measures a statement and returns the results as a dictionary. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`numpy_to_ort_value ` | | Converts a numpy array to :epkg:`C_OrtValue`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`nvprof2json ` | | Converts traces produced by :epkg:`nvprof` and saved with format :epkg:`sqlite3` (extension `.sql`). | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`onnx_derivative ` | | Builds the gradient for an onnx graph. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`onnx_rename_weights ` | | Renames ONNX initializers to make sure their name follows the alphabetical order. The model is modified inplace. ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`onnx_rewrite_operator ` | | Replaces one operator by an onnx graph. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`ort_device_to_string ` | | Returns a string representing the device. Opposite of function :func:`get_ort_device`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`penalty_loss_onnx ` | | Returns onnx nodes to compute :math:`|w| \alpha + w^2 \beta` where :math:`\alpha=l1` and :math:`\beta=l2`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`plot_onnxs ` | | Plots one or several ONNX graph into a :epkg:`matplotlib` graph. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`proto_type_to_dtype ` | | Converts a ONNX TensorProto type into numpy type. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`provider_to_device ` | | Converts provider into a device. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`replace_initializers_into_onnx ` | | Replaces initializers by other initializers, usually trained ones. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`split_onnx ` | | Splits an ONNX model into *n_parts* consecutive subgraphs. Chained altogether, they are equivalent to the given model. ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`str_ortvalue ` | | Displays the content of an :epkg:`C_OrtValue`. | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`unreduced_onnx_loss ` | | Every loss function reduces the results to compute a loss. The score function needs to get the loss for every observation, ... | +----------------------------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+