Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions _doc/sphinxdoc/source/_exts/generate_onnx_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SupportedOnnxOpsDirective(Directive):
has_content = False

def run(self):
cls = _dynamic_class_creation()
cls = _dynamic_class_creation(include_past=True)
cls_name = [(c.__name__, c) for c in cls]
rows = []
sorted_cls_name = list(sorted(cls_name))
Expand All @@ -32,8 +32,8 @@ def make_ref(cl):
return ":ref:`l-xop-onnx-{}`".format(cl.__name__)

table = []
cut = len(sorted_cls_name) // 3 + \
(1 if len(sorted_cls_name) % 3 else 0)
cut = (len(sorted_cls_name) // 3 +
(1 if len(sorted_cls_name) % 3 else 0))
for i in range(cut):
row = []
row.append(make_ref(sorted_cls_name[i][1]))
Expand All @@ -56,9 +56,9 @@ def make_ref(cl):
nested_parse_with_titles(self.state, st, node)
main += node

rows.append('')
for name, cl in sorted_cls_name:
rows = []
rows.append('')
rows.append('.. _l-xop-onnx-{}:'.format(cl.__name__))
rows.append('')
rows.append(cl.__name__)
Expand Down
38 changes: 38 additions & 0 deletions _doc/sphinxdoc/source/api/ast.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

===
AST
===

.. contents::
:local:

Main functions
==============

.. autosignature:: mlprodict.onnx_tools.onnx_translation.translate_fct2onnx

Additional functions
====================

.. autosignature:: mlprodict.onnx_tools.onnx_translation.get_default_context

.. autosignature:: mlprodict.onnx_tools.onnx_translation.get_default_context_cpl

.. autosignature:: mlprodict.onnx_tools.onnx_translation.py_make_float_array

.. autosignature:: mlprodict.onnx_tools.onnx_translation.py_opp

.. autosignature:: mlprodict.onnx_tools.onnx_translation.py_mul

.. autosignature:: mlprodict.onnx_tools.onnx_translation.py_pow

.. autosignature:: mlprodict.onnx_tools.onnx_translation.squareform_pdist

Grammar Objects
===============

.. autosignature:: mlprodict.onnx_tools.onnx_grammar.node_visitor_translator.CodeNodeVisitor

.. autosignature:: mlprodict.onnx_tools.onnx_grammar.onnx_translator.CodeTranslator

.. autosignature:: mlprodict.onnx_tools.onnx_grammar.onnx_translator.OnnxTranslator
7 changes: 7 additions & 0 deletions _doc/sphinxdoc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ This is a summary of functions this modules provides.

onnx_conv
sklapi

**Write ONNX graphs**

.. toctree::
:maxdepth: 1

npy
xop
ast

**ONNX runtime**

Expand Down
36 changes: 22 additions & 14 deletions _doc/sphinxdoc/source/api/xop.rst
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@

.. _l-xop-onnxpy:

Create ONNX graphs
==================
=======
Xop API
=======

.. contents::
:local:

Example
+++++++

Converters
++++++++++

API
+++
===

Automated gathering of operators
++++++++++++++++++++++++++++++++

.. autosignature:: mlprodict.npy.xop.ClassFactory

.. autosignature:: mlprodict.npy.xop.dynamic_class_creation

.. autosignature:: mlprodict.npy.xops_variable.Variable
.. autosignature:: mlprodict.npy.xop._GraphBuilder

Main classes
++++++++++++

.. autosignature:: mlprodict.npy.xop_variable.Variable

.. autosignature:: mlprodict.npy.xop.OnnxOperator

.. autosignature:: mlprodict.npy.xop.OnnxOperatorItem

.. autosignature:: mlprodict.npy.xop_ops._GraphBuilder
.. autosignature:: mlprodict.npy.xop_convert.OnnxSubOnnx

.. autosignature:: mlprodict.npy.xop_ops.OnnxOperator
.. autosignature:: mlprodict.npy.xop_convert.OnnxSubEstimator

.. autosignature:: mlprodict.npy.xop_ops.OnnxOperatorItem
Helpers to handle API changing with opsets
++++++++++++++++++++++++++++++++++++++++++

.. autosignature:: mlprodict.npy.xop_opset.OnnxReduceSumApi11

Expand All @@ -41,7 +49,7 @@ API
.. autosignature:: mlprodict.npy.xop_opset.OnnxReshapeApi13

Available ONNX operators
++++++++++++++++++++++++
========================

.. toctree::

Expand Down
21 changes: 18 additions & 3 deletions _doc/sphinxdoc/source/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@ Tutorial
The only tutorial is about :epkg:`ONNX` and only
one piece this module can do. More should follow.

.. contents::
:local:

Run inference
+++++++++++++

.. toctree::
:maxdepth: 1

onnx
onnx_numpy
numpy_api_onnx
skl
onnx_runtime
optim
benchmark

Write custom ONNX graph
+++++++++++++++++++++++

.. toctree::
:maxdepth: 1

onnx_numpy
numpy_api_onnx
xop_api
28 changes: 14 additions & 14 deletions _doc/sphinxdoc/source/tutorial/numpy_api_onnx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Following example shows how to replace *numpy* by *ONNX*.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -187,7 +187,7 @@ One instance is added in a pipeline trained on the Iris dataset.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -342,7 +342,7 @@ is used. Let's see how to do it.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning

import numpy
from pandas import DataFrame
Expand Down Expand Up @@ -455,7 +455,7 @@ the class is a transformer and automatically adds method

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning

import numpy
from pandas import DataFrame
Expand Down Expand Up @@ -517,7 +517,7 @@ with arguments :class:`onnxnumpy_np

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -565,7 +565,7 @@ as an argument of `to_onnx`.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -621,7 +621,7 @@ another operator.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

import numpy as np
Expand Down Expand Up @@ -713,7 +713,7 @@ the conversion to ONNX :meth:`to_algebra

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -763,7 +763,7 @@ types. If types are different, one must be cast into the other one.
.. runpython::
:showcode:
:exception:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand All @@ -790,7 +790,7 @@ except one.
.. runpython::
:showcode:
:exception:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -841,7 +841,7 @@ a new one supporting custom functions implemented this API.
.. runpython::
:showcode:
:exception:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -893,7 +893,7 @@ does. However it produces the following error.
.. runpython::
:showcode:
:exception:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

import numpy
Expand Down Expand Up @@ -947,7 +947,7 @@ in class @see cl OnnxVar.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down Expand Up @@ -995,7 +995,7 @@ is called.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:

from typing import Any
Expand Down
16 changes: 8 additions & 8 deletions _doc/sphinxdoc/source/tutorial/onnx_numpy.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

.. _l-numpy2onnx-tutorial:

From numpy to ONNX
==================
Create custom ONNX graphs
=========================

Converting a :epkg:`scikit-learn` pipeline is easy when
the pipeline contains only pieces implemented in :epkg:`scikit-learn`
Expand All @@ -25,7 +25,7 @@ the first examples of `sklearn-onnx tutorial`.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning

import numpy
from sklearn.pipeline import make_pipeline
Expand Down Expand Up @@ -55,8 +55,8 @@ into *ONNX*. Even if function :epkg:`numpy:log` does exist in ONNX specification
this problem is equivalent to a translation from a language, Python,
to another one, ONNX.

Translating numpy to ONNX
+++++++++++++++++++++++++
Translating numpy to ONNX with AST
++++++++++++++++++++++++++++++++++

.. index:: algebric function

Expand All @@ -81,7 +81,7 @@ produces the :epkg:`ONNX` graph.

.. runpython::
:showcode:
:warningout: DeprecationWarning
:warningout: DeprecationWarning, FutureWarning
:process:
:store_in_file: fct2onnx_expsine.py

Expand All @@ -95,7 +95,7 @@ produces the :epkg:`ONNX` graph.

# The function to convert into ONNX.
def kernel_call_ynone(X, length_scale=1.2, periodicity=1.1,
pi=3.141592653589793):
pi=3.141592653589793, op_version=15):

# squareform(pdist(X, ...)) in one function.
dists = squareform_pdist(X, metric='euclidean')
Expand Down Expand Up @@ -140,7 +140,7 @@ produces the :epkg:`ONNX` graph.

# Calls the ONNX algebric function to produce the ONNX graph.
inputs = {'X': x.astype(numpy.float32)}
onnx_g = onnx_model.to_onnx(inputs, target_opset=12)
onnx_g = onnx_model.to_onnx(inputs, target_opset=15)

# Creates a python runtime associated to the ONNX function.
oinf = OnnxInference(onnx_g)
Expand Down
Loading