AST#

Main functions#

mlprodict.onnx_tools.onnx_grammar.translate_fct2onnx (fct, context = None, cpl = False, context_cpl = None, output_names = None, dtype = <class ‘numpy.float32’>, verbose = 0, fLOG = None)

Translates a function into ONNX. The code it produces is using classes OnnxAbs, OnnxAdd, …

Additional functions#

mlprodict.onnx_tools.onnx_grammar.onnx_translation.get_default_context ()

Returns a default context useful for most of the conversion from a function using numpy into ONNX.

mlprodict.onnx_tools.onnx_grammar.onnx_translation.get_default_context_cpl ()

Returns a default useful context to compile the converter returned by translate_fct2onnx.

mlprodict.onnx_tools.onnx_grammar.onnx_translation.py_make_float_array (cst, op_version = None)

Creates an array with a single element from a constant.

mlprodict.onnx_tools.onnx_grammar.onnx_translation.py_opp (x, op_version = None)

Function for python unary operator -.

mlprodict.onnx_tools.onnx_grammar.onnx_translation.py_mul (x, op_version = None)

Function for python operator *.

mlprodict.onnx_tools.onnx_grammar.onnx_translation.py_pow (x, p, op_version = None)

Function for python operator **.

mlprodict.onnx_tools.onnx_grammar.onnx_translation.squareform_pdist (X, metric = ‘sqeuclidean’, op_version = None)

Replacements for squareform and pdist.

Grammar Objects#

mlprodict.onnx_tools.onnx_grammar.CodeNodeVisitor (self, translator = None)

Defines a visitor which walks though the syntax tree of the code.

mlprodict.onnx_tools.onnx_grammar.onnx_translator.CodeTranslator (self, visitor)

Class which converts a Python function into something else. It must implements methods visit and depart.

mlprodict.onnx_tools.onnx_grammar.onnx_translator.OnnxTranslator (self, visitor)

Class which converts a Python function into an ONNX function. It must implements methods visit and depart.