Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit00844cc

Browse files
committed
fix documentation
1 parent8899900 commit00844cc

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

‎_doc/tutorial/light_api.rst‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,20 @@ Graph methods
4242
Any graph must start with function:func:`start <onnx_array_api.light_api.start>`.
4343
It is usually following by `vin` to add an input.
4444

45-
* bring (:meth:`cst <onnx_array_api.light_api.Var.bring>`,:meth:`cst <onnx_array_api.light_api.Vars.bring>`):
45+
* bring (:meth:`Var.bring <onnx_array_api.light_api.Var.bring>`,
46+
:meth:`Vars.bring <onnx_array_api.light_api.Vars.bring>`):
4647
assembles multiple results into a set before calling an operator taking mulitple inputs,
47-
* cst (:meth:`cst <onnx_array_api.light_api.Var.cst>`,:meth:`cst <onnx_array_api.light_api.Vars.cst>`):
48+
* cst (:meth:`Var.cst <onnx_array_api.light_api.Var.cst>`,
49+
:meth:`Vars.cst <onnx_array_api.light_api.Vars.cst>`):
4850
adds a constant tensor to the graph,
49-
* rename (:meth:`cst <onnx_array_api.light_api.Var.rename>`,:meth:`cst <onnx_array_api.light_api.Vars.rename>`):
51+
* rename (:meth:`Var.rename <onnx_array_api.light_api.Var.rename>`,
52+
:meth:`Vars.rename <onnx_array_api.light_api.Vars.rename>`):
5053
renames or give a name to a variable in order to call it later.
51-
* vin (:meth:`cst <onnx_array_api.light_api.Var.vin>`,:meth:`cst <onnx_array_api.light_api.Vars.vin>`):
54+
* vin (:meth:`Var.vin <onnx_array_api.light_api.Var.vin>`,
55+
:meth:`Vars.vin <onnx_array_api.light_api.Vars.vin>`):
5256
adds an input to the graph,
53-
* vout (:meth:`cst <onnx_array_api.light_api.Var.vout>`,:meth:`cst <onnx_array_api.light_api.Vars.vout>`):
57+
* vout (:meth:`Var.vout <onnx_array_api.light_api.Var.vout>`,
58+
:meth:`Vars.vout <onnx_array_api.light_api.Vars.vout>`):
5459
declares an existing result as an output.
5560

5661
These methods are implemented in class:class:`onnx_array_api.light_api.var.BaseVar`

‎_doc/tutorial/onnx_api.rst‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ For example, the well known Euclidian distance
2929
defeuclidan(X: np.array,Y: np.array) ->float:
3030
return ((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
3333
primitives. It is usually easy because the primitives are very close to what
3434
numpy 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

8181
Since it is a second implementation of an existing function, it is necessary to
8282
check the output is the same.
@@ -222,7 +222,7 @@ Many existing options are available to write custom onnx graphs.
222222
The development is usually driven by what they are used for. Each of them
223223
may not fully support all your needs and it is not always easy to understand
224224
the 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.
226226
Here 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
246246
It 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.
248248
It 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

251251
Example 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`.
323323
Therefore, `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

326328
Example 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 reimplementingthescikit-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 asdescribed 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

395399
onnxblocks
396400
++++++++++
397401

398402
`onnxblocks<https://onnxruntime.ai/docs/api/python/on_device_training/training_artifacts.html#prepare-for-training>`_
399403
was 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
450454
by using numpy API. If a function is defined only with numpy,
451455
it should be possible to use the exact same code to create the
452456
corresponding onnx graph. That's what this API tries to achieve.

‎_unittests/ut_validation/test_docs.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_ort_make_euclidean(self):
8282
Y=np.random.rand(3,4).astype(np.float32)
8383
expected= ((X-Y)**2).sum(keepdims=1)
8484
got=ref.run(None, {"X":X,"Y":Y})[0]
85-
self.assertEqualArray(expected,got)
85+
self.assertEqualArray(expected,got,atol=1e-6)
8686

8787

8888
if__name__=="__main__":

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp