File tree Expand file tree Collapse file tree 6 files changed +80
-4
lines changed Expand file tree Collapse file tree 6 files changed +80
-4
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,9 @@ figures:
17
17
@$(PYCMD ) source/scripts/build_activation_images.py
18
18
@$(PYCMD ) source/scripts/build_quantization_configs.py
19
19
20
- onnx_supported_aten_ops :
20
+ onnx :
21
21
@$(PYCMD ) source/scripts/onnx/build_onnx_supported_aten_op_csv_table.py
22
+ @$(PYCMD ) source/scripts/onnx/build_onnx_diagnostics_rules_md.py $(SOURCEDIR ) /generated/onnx_diagnostics_rules
22
23
23
24
docset : html
24
25
doc2dash --name $(SPHINXPROJ ) --icon $(SOURCEDIR ) /_static/img/pytorch-logo-flame.png --enable-js --online-redirect-url https://pytorch.org/docs/ --force $(BUILDDIR ) /html/
@@ -34,11 +35,11 @@ html-stable:
34
35
# See conf.py for more details.
35
36
RELEASE=1 make html
36
37
37
- .PHONY : help Makefile docset onnx_supported_aten_ops
38
+ .PHONY : help Makefile docset onnx
38
39
39
40
# Catch-all target: route all unknown targets to Sphinx using the new
40
41
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
41
- % : Makefile figures onnx_supported_aten_ops
42
+ % : Makefile figures onnx
42
43
@$(SPHINXBUILD ) -M $@ " $( SOURCEDIR) " " $( BUILDDIR) " $(SPHINXOPTS ) $(O )
43
44
44
45
clean :
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ tensorboard==2.10.0
10
10
python-etcd == 0.4.5
11
11
sphinx-copybutton == 0.5.0
12
12
sphinx-panels == 0.4.1
13
+ myst-parser == 0.18.1
Original file line number Diff line number Diff line change 58
58
'sphinxcontrib.katex' ,
59
59
'sphinx.ext.autosectionlabel' ,
60
60
'sphinx_copybutton' ,
61
- 'sphinx_panels'
61
+ 'sphinx_panels' ,
62
+ 'myst_parser' ,
62
63
]
63
64
64
65
# build the templated autosummary files
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ Features described in this documentation are classified by release status:
85
85
profiler
86
86
nn.init
87
87
onnx
88
+ onnx_diagnostics
88
89
optim
89
90
complex_numbers
90
91
ddp_comm_hooks
Original file line number Diff line number Diff line change
1
+ torch.onnx diagnostics
2
+ ======================
3
+
4
+ .. contents :: :local:
5
+ .. automodule :: torch.onnx._internal.diagnostics
6
+ .. currentmodule :: torch.onnx._internal.diagnostics
7
+
8
+ Overview
9
+ --------
10
+
11
+ NOTE: This feature is underdevelopment and is subject to change.
12
+
13
+ The goal is to improve the diagnostics to help users debug and improve their model export to ONNX.
14
+
15
+ - The diagnostics are emitted in machine parsable `Static Analysis Results Interchange Format (SARIF) <https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html >`__.
16
+ - A new clearer, structured way to add new and keep track of diagnostic rules.
17
+ - Serve as foundation for more future improvements consuming the diagnostics.
18
+
19
+
20
+ Diagnostic Rules
21
+ ----------------
22
+
23
+ .. toctree ::
24
+ :glob:
25
+
26
+ generated/onnx_diagnostics_rules/*
27
+
28
+ API Reference
29
+ -------------
30
+
31
+ .. autoclass :: torch.onnx._internal.diagnostics.ExportDiagnostic
32
+ :members:
33
+
34
+ .. autoclass :: torch.onnx._internal.diagnostics.infra.DiagnosticEngine
35
+ :members:
Original file line number Diff line number Diff line change
1
+ import argparse
2
+ import os
3
+ from dataclasses import fields
4
+
5
+ from torch .onnx ._internal import diagnostics
6
+ from torch .onnx ._internal .diagnostics import infra
7
+
8
+
9
+ def gen_docs (out_dir : str ):
10
+ os .makedirs (out_dir , exist_ok = True )
11
+ for field in fields (diagnostics .rules ):
12
+ rule = getattr (diagnostics .rules , field .name )
13
+ if not isinstance (rule , infra .Rule ):
14
+ continue
15
+ title = f"{ rule .id } :{ rule .name } "
16
+ full_description_markdown = rule .full_description_markdown
17
+ assert (
18
+ full_description_markdown is not None
19
+ ), f"Expected { title } to have a full description in markdown"
20
+ with open (f"{ out_dir } /{ title } .md" , "w" ) as f :
21
+ f .write (f"# { title } \n " )
22
+ f .write (full_description_markdown )
23
+
24
+
25
+ def main () -> None :
26
+ parser = argparse .ArgumentParser (
27
+ description = "Generate ONNX diagnostics rules doc in markdown."
28
+ )
29
+ parser .add_argument (
30
+ "out_dir" , metavar = "OUT_DIR" , help = "path to output directory for docs"
31
+ )
32
+ args = parser .parse_args ()
33
+ gen_docs (args .out_dir )
34
+
35
+
36
+ if __name__ == "__main__" :
37
+ main ()
You can’t perform that action at this time.
0 commit comments