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

Fix documentation#81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sdpython merged 18 commits intomainfromfix2
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
18 commits
Select commitHold shift + click to select a range
6eb6adf
update requirements
xadupreFeb 2, 2024
4f0a994
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 2, 2024
c7bb055
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 2, 2024
a3d4ccf
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 6, 2024
7ed1385
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 6, 2024
bab2a6b
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 7, 2024
014404b
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 7, 2024
00e2a1c
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 14, 2024
d1aff97
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 15, 2024
4c12efd
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 22, 2024
032aff5
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 28, 2024
3770528
Merge branch 'main' of https://github.com/sdpython/onnx-array-api
xadupreFeb 28, 2024
1feac72
fix names in to_dot
xadupreMar 1, 2024
31304b1
doc
xadupreMar 1, 2024
64cdc47
fix doc
xadupreMar 1, 2024
3d35f3f
doc
xadupreMar 1, 2024
05bb8e4
fix doc
xadupreMar 1, 2024
972ce33
doc
xadupreMar 1, 2024
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
2 changes: 2 additions & 0 deletions_doc/api/plotting.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ Dot

.. autofunction:: onnx_array_api.plotting.dot_plot.to_dot

.. autofunction:: onnx_array_api.plotting.graphviz_helper.plot_dot

Statistics
++++++++++

Expand Down
1 change: 1 addition & 0 deletions_doc/conf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,6 +117,7 @@
"ast": "https://docs.python.org/3/library/ast.html",
"cProfile.Profile": "https://docs.python.org/3/library/profile.html#profile.Profile",
"DOT": "https://graphviz.org/doc/info/lang.html",
"Graphviz": "https://graphviz.org/",
"inner API": "https://onnx.ai/onnx/intro/python.html",
"JIT": "https://en.wikipedia.org/wiki/Just-in-time_compilation",
"onnx": "https://onnx.ai/onnx/",
Expand Down
6 changes: 5 additions & 1 deletion_doc/tutorial/onnx_api.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -71,7 +71,11 @@ the true implementation would be the following.
n2 = oh.make_node("Pow", ["dxy", "two"], ["dxy2"])
n3 = oh.make_node("ReduceSum", ["dxy2"], [output_name])
graph = oh.make_graph([n1, n2, n3], "euclidian", [X, Y], [Z], [two])
model = oh.make_model(graph, opset_imports=[oh.make_opsetid("", opset)])
model = oh.make_model(
graph,
opset_imports=[oh.make_opsetid("", opset)],
ir_version=9,
)
return model


Expand Down
7 changes: 6 additions & 1 deletiononnx_array_api/plotting/dot_plot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,7 +116,12 @@ def myloss(x, y):
clean_label_reg2 = re.compile("\\\\p\\{[0-9P]{1,6}\\}")

def dot_name(text):
return text.replace("/", "_").replace(":", "__").replace(".", "_")
return (
text.replace("/", "_")
.replace(":", "__")
.replace(".", "_")
.replace("-", "_")
)

def dot_label(text):
if text is None:
Expand Down
40 changes: 24 additions & 16 deletionsonnx_array_api/plotting/graphviz_helper.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,7 +73,7 @@ def _run_subprocess(
shell=False,
env=os.environ,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stderr=subprocess.PIPE,
)
raise_exception = False
output = ""
Expand All@@ -91,12 +91,14 @@ def _run_subprocess(
):
raise_exception = True
p.poll()
error = p.stderr.readline().decode(errors="ignore")
p.stdout.close()
if raise_exception:
iferror andraise_exception:
raise RuntimeError(
"An error was found in the output. The build is stopped.\n{output}"
f"An error was found in the output. The build is stopped."
f"\n{output}\n---\n{error}"
)
return output
return output + "\n" + error


def _run_graphviz(filename: str, image: str, engine: str = "dot") -> str:
Expand DownExpand Up@@ -134,8 +136,12 @@ def _run_graphviz(filename: str, image: str, engine: str = "dot") -> str:
exe = engine
if os.path.exists(image):
os.remove(image)
output = _run_subprocess([exe, f"-T{ext[1:]}", filename, "-o", image])
assert os.path.exists(image), f"Graphviz failed due to {output}"
cmd = [exe, f"-T{ext[1:]}", filename, "-o", image]
output = _run_subprocess(cmd)
assert os.path.exists(image), (
f"Unable to find {image!r}, command line is "
f"{' '.join(cmd)!r}, Graphviz failed due to\n{output}"
)
return output


Expand DownExpand Up@@ -190,23 +196,25 @@ def plot_dot(
:param image: output image, None, just returns the output
:param engine: *dot* or *neato*
:param figsize: figsize of ax is None
:return: :epkg:`Graphviz` output or
the dot text if *image* is None
:return: :epkg:`Graphviz` output or, the dot text if *image* is None

.. plot::

import matplotlib.pyplot as plt
import onnx.parser
from onnx_array_api.plotting.graphviz_helper import plot_dot

model = onnx.parser.parse_model(
'''
<ir_version: 8, opset_import: [ "": 18]>
agraph (float[N] x) => (float[N] z) {
two = Constant <value_float=2.0> ()
four = Add(two, two)
z = Mul(four, four)
}''')
ax = plot_dot(dot)
'''
<ir_version: 8, opset_import: [ "": 18]>
agraph (float[N] x) => (float[N] z) {
two = Constant <value_float=2.0> ()
four = Add(two, two)
z = Mul(four, four)
}
''')

ax = plot_dot(model)
ax.set_title("Dummy graph")
plt.show()
"""
Expand Down
7 changes: 3 additions & 4 deletionsonnx_array_api/reference/evaluator_yield.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -237,10 +237,9 @@ def enumerate_summarized(
Executes the onnx model and enumerate intermediate results without their names.

:param output_names: requested outputs by names, None for all
:param feed_inputs: dictionary `{ input name: input value }`
:param raise_exc: raises an exception if the execution fails or stop
where it is
:param keep_tensor:keep the tensor in order to compute precise distances
:param feed_inputs: dictionary ``{ input name: input value }``
:param raise_exc: raises an exception if the execution fails or stop where it is
:param keep_tensor: keep the tensor in order to compute precise distances
:return: iterator on ResultExecution
"""
for kind, name, value, op_type in self.enumerate_results(
Expand Down
4 changes: 3 additions & 1 deletiononnx_array_api/validation/docs.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,9 @@ def make_euclidean(
n2 = oh.make_node("Pow", ["dxy", "two"], ["dxy2"])
n3 = oh.make_node("ReduceSum", ["dxy2"], [output_name])
graph = oh.make_graph([n1, n2, n3], "euclidian", [X, Y], [Z], [two])
model = oh.make_model(graph, opset_imports=[oh.make_opsetid("", opset)])
model = oh.make_model(
graph, opset_imports=[oh.make_opsetid("", opset)], ir_version=9
)
return model


Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp