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

Commit33b8850

Browse files
committed
add graph_builder
1 parentbd1a441 commit33b8850

File tree

4 files changed

+879
-0
lines changed

4 files changed

+879
-0
lines changed

‎_doc/sg_execution_times.rst‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
:orphan:
3+
4+
.. _sphx_glr_sg_execution_times:
5+
6+
7+
Computation times
8+
=================
9+
**00:00.000** total execution time for 6 files **from all galleries**:
10+
11+
..container::
12+
13+
..raw::html
14+
15+
<stylescoped>
16+
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" />
17+
<link href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
18+
</style>
19+
<scriptsrc="https://code.jquery.com/jquery-3.7.0.js"></script>
20+
<scriptsrc="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
21+
<scriptsrc="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
22+
<scripttype="text/javascript"class="init">
23+
$(document).ready(function () {
24+
$('table.sg-datatable').DataTable({order: [[1,'desc']]});
25+
} );
26+
</script>
27+
28+
..list-table::
29+
:header-rows: 1
30+
:class: table table-striped sg-datatable
31+
32+
* - Example
33+
- Time
34+
- Mem (MB)
35+
* -:ref:`sphx_glr_auto_examples_plot_benchmark_rf.py` (``examples/plot_benchmark_rf.py``)
36+
- 00:00.000
37+
- 0.0
38+
* -:ref:`sphx_glr_auto_examples_plot_f8.py` (``examples/plot_f8.py``)
39+
- 00:00.000
40+
- 0.0
41+
* -:ref:`sphx_glr_auto_examples_plot_first_example.py` (``examples/plot_first_example.py``)
42+
- 00:00.000
43+
- 0.0
44+
* -:ref:`sphx_glr_auto_examples_plot_onnxruntime.py` (``examples/plot_onnxruntime.py``)
45+
- 00:00.000
46+
- 0.0
47+
* -:ref:`sphx_glr_auto_examples_plot_optimization.py` (``examples/plot_optimization.py``)
48+
- 00:00.000
49+
- 0.0
50+
* -:ref:`sphx_glr_auto_examples_plot_profiling.py` (``examples/plot_profiling.py``)
51+
- 00:00.000
52+
- 0.0
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
importunittest
2+
importonnx
3+
fromonnx_array_api.ext_test_caseimportExtTestCase
4+
fromonnx_array_api.graph_api.graph_builderimportGraphBuilder
5+
6+
7+
classTestGraphSimplification(ExtTestCase):
8+
defcall_optimizer(self,onx):
9+
gr=GraphBuilder(onx)
10+
gr.remove_unused()
11+
returngr.to_onnx()
12+
13+
deftest_remove_unused_nodes(self):
14+
model=onnx.parser.parse_model(
15+
"""
16+
<ir_version: 8, opset_import: [ "": 18]>
17+
agraph (float[N] x) => (float[N] z) {
18+
two = Constant <value_float=2.0> ()
19+
four = Add(two, two)
20+
z = Mul(x, x)
21+
}"""
22+
)
23+
onx=self.call_optimizer(model)
24+
self.assertEqual(len(onx.graph.node),1)
25+
self.assertEqual(onx.graph.node[0].op_type,"Mul")
26+
27+
deftest_initializers(self):
28+
model=onnx.parser.parse_model(
29+
"""
30+
<ir_version: 8, opset_import: [ "": 18]>
31+
agraph (float[N] x) => (float[N] z)
32+
<float two = {2.0}> {
33+
four = Add(two, two)
34+
z = Mul(x, x)
35+
}"""
36+
)
37+
self.assertEqual(len(model.graph.initializer),1)
38+
onx=self.call_optimizer(model)
39+
self.assertEqual(len(onx.graph.node),1)
40+
self.assertEqual(onx.graph.node[0].op_type,"Mul")
41+
self.assertEqual(len(onx.graph.initializer),0)
42+
43+
deftest_keep_unused_outputs(self):
44+
model=onnx.parser.parse_model(
45+
"""
46+
<ir_version: 8, opset_import: [ "": 18]>
47+
agraph (float[N] x) => (float[M] z) {
48+
w1, w2, w3 = Split (x)
49+
z = Mul(w3, w3)
50+
}"""
51+
)
52+
onx=self.call_optimizer(model)
53+
self.assertEqual(len(onx.graph.node),2)
54+
self.assertEqual(onx.graph.node[0].op_type,"Split")
55+
56+
57+
if__name__=="__main__":
58+
unittest.main(verbosity=2)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp