@@ -29,7 +29,7 @@ For example, the well known Euclidian distance
2929def euclidan (X : np.array,Y : np.array) ->float :
3030return ((X- Y)** 2 ).sum()
3131
32- The mathematical function must first betranslate with:epkg: `ONNX Operators ` or
32+ The mathematical function must first betranslated with:epkg: `ONNX Operators ` or
3333primitives. It is usually easy because the primitives are very close to what
3434numpy defines. It can be expressed as (the syntax is just for illustration).
3535
@@ -75,8 +75,8 @@ the true implementation would be the following.
7575 return model
7676
7777
78- model = make_euclidean()
79- print(model)
78+ model = make_euclidean()
79+ print(model)
8080
8181Since it is a second implementation of an existing function, it is necessary to
8282check the output is the same.
@@ -222,7 +222,7 @@ Many existing options are available to write custom onnx graphs.
222222The development is usually driven by what they are used for. Each of them
223223may not fully support all your needs and it is not always easy to understand
224224the error messages they provide when something goes wrong.
225- It is better to understand its own needfefore choosing one.
225+ It is better to understand its own needbefore choosing one.
226226Here are some of the questions which may need to be answered.
227227
228228* ability to easily write loops and tests (control flow)
@@ -246,7 +246,7 @@ onnxscript
246246It converts python code to onnx code by analyzing the python code
247247(through:epkg: `ast `). The package makes it very easy to use loops and tests in onnx.
248248It is very close to onnx syntax. It is not easy to support multiple
249- implementing depending on the opset version required by the user.
249+ implementation depending on the opset version required by the user.
250250
251251Example taken from the documentation :
252252
@@ -319,9 +319,11 @@ An Eager mode is available to debug what the code does.
319319 spox
320320++++
321321
322- The syntax of epkg:`spox ` is similar but it does not use:epkg: `ast `.
322+ The syntax of: epkg: `spox ` is similar but it does not use:epkg: `ast `.
323323Therefore, `loops and tests <https://spox.readthedocs.io/en/latest/guides/advanced.html#Control-flow >`_
324- are expressed in a very different way.
324+ are expressed in a very different way. The tricky part with it is to handle
325+ the local context. A variable created in the main graph is known by any
326+ of its subgraphs.
325327
326328Example taken from the documentation :
327329
@@ -355,18 +357,19 @@ sklearn-onnx
355357++++++++++++
356358
357359:epkg: `sklearn-onnx ` also implements its own API to add custom graphs.
358- It was designed to shorten the timespend in reimplementingthe scikit-learn
359- code into onnx code. It can be used to implement a newconverted as
360- described in this example:
360+ It was designed to shorten the timespent in reimplementing:epkg: ` scikit-learn `
361+ code into:epkg: ` onnx ` code. It can be used to implement a newconverter
362+ mapped a custom model as described in this example:
361363`Implement a new converter
362364<https://onnx.ai/sklearn-onnx/auto_tutorial/plot_icustom_converter.html> `_.
363- But it can also be used to build standaloneexample:
365+ But it can also be used to build standalonemodels.
364366
365367..runpython ::
366368:showcode:
367369
368370 import numpy as np
369371 import onnx
372+ import onnx.helper as oh
370373 from onnx_array_api.plotting.text_plot import onnx_simple_text_plot
371374
372375
@@ -389,15 +392,16 @@ But it can also be used to build standalone example:
389392 dummy = np.empty([1], np_type)
390393 return final.to_onnx({"X": dummy, "Y": dummy})
391394
392- model = make_euclidean()
393- print(onnx_simple_text_plot(model))
395+
396+ model = make_euclidean_skl2onnx()
397+ print(onnx_simple_text_plot(model))
394398
395399onnxblocks
396400++++++++++
397401
398402`onnxblocks <https://onnxruntime.ai/docs/api/python/on_device_training/training_artifacts.html#prepare-for-training >`_
399403was introduced in onnxruntime to define custom losses in order to train
400- a model with:epkg: `onnxruntime-training `.
404+ a model with:epkg: `onnxruntime-training `. It is mostly used for this usage.
401405
402406..code-block ::python
403407
@@ -446,7 +450,7 @@ a model with :epkg:`onnxruntime-training`.
446450 numpy API for onnx
447451++++++++++++++++++
448452
449- See:ref: `l-numpy-api-onnx `. This API was introduced to creategraph
453+ See:ref: `l-numpy-api-onnx `. This API was introduced to creategraphs
450454by using numpy API. If a function is defined only with numpy,
451455it should be possible to use the exact same code to create the
452456corresponding onnx graph. That's what this API tries to achieve.