Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ckpts/universal/global_step120/zero/13.attention.query_key_value.weight/exp_avg_sq.pt +3 -0
- ckpts/universal/global_step120/zero/13.attention.query_key_value.weight/fp32.pt +3 -0
- ckpts/universal/global_step120/zero/17.attention.dense.weight/fp32.pt +3 -0
- venv/lib/python3.10/site-packages/torch/onnx/__pycache__/_type_utils.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/__init__.py +0 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/_beartype.py +131 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/__init__.py +21 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/_diagnostic.py +212 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/_rules.py +634 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/__init__.py +33 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/_infra.py +284 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/context.py +415 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/decorator.py +158 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/formatter.py +114 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/__init__.py +100 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/__pycache__/_fix.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/__pycache__/_physical_location.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_address.py +48 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact.py +88 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_change.py +31 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_content.py +33 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_location.py +33 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_attachment.py +39 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_code_flow.py +31 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_configuration_override.py +31 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_conversion.py +35 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_edge.py +31 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_edge_traversal.py +31 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_exception.py +37 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_external_properties.py +98 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_external_property_file_reference.py +33 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_external_property_file_references.py +86 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_fix.py +31 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_graph.py +35 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_graph_traversal.py +43 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_invocation.py +117 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_location.py +50 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_location_relationship.py +28 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_logical_location.py +39 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_message.py +33 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_multiformat_message_string.py +25 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_node.py +36 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_notification.py +53 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_physical_location.py +40 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_property_bag.py +19 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_rectangle.py +36 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_region.py +58 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_replacement.py +31 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_configuration.py +33 -0
- venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_descriptor.py +71 -0
ckpts/universal/global_step120/zero/13.attention.query_key_value.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ab559fe2e421839be6562b68ddd5448fffc38334078112e1ee655fea06d4bab1
|
3 |
+
size 50332843
|
ckpts/universal/global_step120/zero/13.attention.query_key_value.weight/fp32.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff3433a9244dc6e0e3c85a85270a490863b81102c8c0ba6e471e42af102523ad
|
3 |
+
size 50332749
|
ckpts/universal/global_step120/zero/17.attention.dense.weight/fp32.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:263382d018932e3161eff18b2b308c104205392506b06e9c14013d7a307edab1
|
3 |
+
size 16778317
|
venv/lib/python3.10/site-packages/torch/onnx/__pycache__/_type_utils.cpython-310.pyc
ADDED
Binary file (9.78 kB). View file
|
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/__init__.py
ADDED
File without changes
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/_beartype.py
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""An internal wrapper for the beartype library.
|
2 |
+
|
3 |
+
The module returns a no-op decorator when the beartype library is not installed.
|
4 |
+
"""
|
5 |
+
import enum
|
6 |
+
import functools
|
7 |
+
import os
|
8 |
+
import traceback
|
9 |
+
import typing
|
10 |
+
import warnings
|
11 |
+
from types import ModuleType
|
12 |
+
|
13 |
+
try:
|
14 |
+
import beartype as _beartype_lib # type: ignore[import]
|
15 |
+
from beartype import roar as _roar # type: ignore[import]
|
16 |
+
|
17 |
+
# Beartype warns when we import from typing because the types are deprecated
|
18 |
+
# in Python 3.9. But there will be a long time until we can move to using
|
19 |
+
# the native container types for type annotations (when 3.9 is the lowest
|
20 |
+
# supported version). So we silence the warning.
|
21 |
+
warnings.filterwarnings(
|
22 |
+
"ignore",
|
23 |
+
category=_roar.BeartypeDecorHintPep585DeprecationWarning,
|
24 |
+
)
|
25 |
+
|
26 |
+
if _beartype_lib.__version__ == "0.16.0":
|
27 |
+
# beartype 0.16.0 has a bug that causes it to crash when used with
|
28 |
+
# PyTorch. See https://github.com/beartype/beartype/issues/282
|
29 |
+
warnings.warn("beartype 0.16.0 is not supported. Please upgrade to 0.16.1+.")
|
30 |
+
_beartype_lib = None # type: ignore[assignment]
|
31 |
+
except ImportError:
|
32 |
+
_beartype_lib = None # type: ignore[assignment]
|
33 |
+
except Exception as e:
|
34 |
+
# Warn errors that are not import errors (unexpected).
|
35 |
+
warnings.warn(f"{e}")
|
36 |
+
_beartype_lib = None # type: ignore[assignment]
|
37 |
+
|
38 |
+
|
39 |
+
@enum.unique
|
40 |
+
class RuntimeTypeCheckState(enum.Enum):
|
41 |
+
"""Runtime type check state."""
|
42 |
+
|
43 |
+
# Runtime type checking is disabled.
|
44 |
+
DISABLED = enum.auto()
|
45 |
+
# Runtime type checking is enabled but warnings are shown only.
|
46 |
+
WARNINGS = enum.auto()
|
47 |
+
# Runtime type checking is enabled.
|
48 |
+
ERRORS = enum.auto()
|
49 |
+
|
50 |
+
|
51 |
+
class CallHintViolationWarning(UserWarning):
|
52 |
+
"""Warning raised when a type hint is violated during a function call."""
|
53 |
+
|
54 |
+
pass
|
55 |
+
|
56 |
+
|
57 |
+
def _no_op_decorator(func):
|
58 |
+
return func
|
59 |
+
|
60 |
+
|
61 |
+
def _create_beartype_decorator(
|
62 |
+
runtime_check_state: RuntimeTypeCheckState,
|
63 |
+
):
|
64 |
+
# beartype needs to be imported outside of the function and aliased because
|
65 |
+
# this module overwrites the name "beartype".
|
66 |
+
|
67 |
+
if runtime_check_state == RuntimeTypeCheckState.DISABLED:
|
68 |
+
return _no_op_decorator
|
69 |
+
if _beartype_lib is None:
|
70 |
+
# If the beartype library is not installed, return a no-op decorator
|
71 |
+
return _no_op_decorator
|
72 |
+
|
73 |
+
assert isinstance(_beartype_lib, ModuleType)
|
74 |
+
|
75 |
+
if runtime_check_state == RuntimeTypeCheckState.ERRORS:
|
76 |
+
# Enable runtime type checking which errors on any type hint violation.
|
77 |
+
return _beartype_lib.beartype
|
78 |
+
|
79 |
+
# Warnings only
|
80 |
+
def beartype(func):
|
81 |
+
"""Warn on type hint violation."""
|
82 |
+
|
83 |
+
if "return" in func.__annotations__:
|
84 |
+
# Remove the return type from the func function's
|
85 |
+
# annotations so that the beartype decorator does not complain
|
86 |
+
# about the return type.
|
87 |
+
return_type = func.__annotations__["return"]
|
88 |
+
del func.__annotations__["return"]
|
89 |
+
beartyped = _beartype_lib.beartype(func)
|
90 |
+
# Restore the return type to the func function's annotations
|
91 |
+
func.__annotations__["return"] = return_type
|
92 |
+
else:
|
93 |
+
beartyped = _beartype_lib.beartype(func)
|
94 |
+
|
95 |
+
@functools.wraps(func)
|
96 |
+
def _coerce_beartype_exceptions_to_warnings(*args, **kwargs):
|
97 |
+
try:
|
98 |
+
return beartyped(*args, **kwargs)
|
99 |
+
except _roar.BeartypeCallHintParamViolation:
|
100 |
+
# Fall back to the original function if the beartype hint is violated.
|
101 |
+
warnings.warn(
|
102 |
+
traceback.format_exc(),
|
103 |
+
category=CallHintViolationWarning,
|
104 |
+
stacklevel=2,
|
105 |
+
)
|
106 |
+
|
107 |
+
return func(*args, **kwargs) # noqa: B012
|
108 |
+
|
109 |
+
return _coerce_beartype_exceptions_to_warnings
|
110 |
+
|
111 |
+
return beartype
|
112 |
+
|
113 |
+
|
114 |
+
if typing.TYPE_CHECKING:
|
115 |
+
# This is a hack to make mypy play nicely with the beartype decorator.
|
116 |
+
def beartype(func):
|
117 |
+
return func
|
118 |
+
|
119 |
+
else:
|
120 |
+
_TORCH_ONNX_EXPERIMENTAL_RUNTIME_TYPE_CHECK = os.getenv(
|
121 |
+
"TORCH_ONNX_EXPERIMENTAL_RUNTIME_TYPE_CHECK"
|
122 |
+
)
|
123 |
+
if _TORCH_ONNX_EXPERIMENTAL_RUNTIME_TYPE_CHECK == "ERRORS":
|
124 |
+
_runtime_type_check_state = RuntimeTypeCheckState.ERRORS
|
125 |
+
elif _TORCH_ONNX_EXPERIMENTAL_RUNTIME_TYPE_CHECK == "DISABLED":
|
126 |
+
_runtime_type_check_state = RuntimeTypeCheckState.DISABLED
|
127 |
+
else:
|
128 |
+
_runtime_type_check_state = RuntimeTypeCheckState.WARNINGS
|
129 |
+
beartype = _create_beartype_decorator(_runtime_type_check_state)
|
130 |
+
# Make sure that the beartype decorator is enabled whichever path we took.
|
131 |
+
assert beartype is not None
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/__init__.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ._diagnostic import (
|
2 |
+
create_export_diagnostic_context,
|
3 |
+
diagnose,
|
4 |
+
engine,
|
5 |
+
export_context,
|
6 |
+
ExportDiagnosticEngine,
|
7 |
+
TorchScriptOnnxExportDiagnostic,
|
8 |
+
)
|
9 |
+
from ._rules import rules
|
10 |
+
from .infra import levels
|
11 |
+
|
12 |
+
__all__ = [
|
13 |
+
"TorchScriptOnnxExportDiagnostic",
|
14 |
+
"ExportDiagnosticEngine",
|
15 |
+
"rules",
|
16 |
+
"levels",
|
17 |
+
"engine",
|
18 |
+
"export_context",
|
19 |
+
"create_export_diagnostic_context",
|
20 |
+
"diagnose",
|
21 |
+
]
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/_diagnostic.py
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Diagnostic components for TorchScript based ONNX export, i.e. `torch.onnx.export`."""
|
2 |
+
from __future__ import annotations
|
3 |
+
|
4 |
+
import contextlib
|
5 |
+
import gzip
|
6 |
+
from collections.abc import Generator
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
import torch
|
10 |
+
|
11 |
+
from torch.onnx._internal.diagnostics import infra
|
12 |
+
from torch.onnx._internal.diagnostics.infra import formatter, sarif
|
13 |
+
from torch.onnx._internal.diagnostics.infra.sarif import version as sarif_version
|
14 |
+
from torch.utils import cpp_backtrace
|
15 |
+
|
16 |
+
|
17 |
+
def _cpp_call_stack(frames_to_skip: int = 0, frames_to_log: int = 32) -> infra.Stack:
|
18 |
+
"""Returns the current C++ call stack.
|
19 |
+
|
20 |
+
This function utilizes `torch.utils.cpp_backtrace` to get the current C++ call stack.
|
21 |
+
The returned C++ call stack is a concatenated string of the C++ call stack frames.
|
22 |
+
Each frame is separated by a newline character, in the same format of
|
23 |
+
r"frame #[0-9]+: (?P<frame_info>.*)". More info at `c10/util/Backtrace.cpp`.
|
24 |
+
|
25 |
+
"""
|
26 |
+
# NOTE: Cannot use `@_beartype.beartype`. It somehow erases the cpp stack frame info.
|
27 |
+
frames = cpp_backtrace.get_cpp_backtrace(frames_to_skip, frames_to_log).split("\n")
|
28 |
+
frame_messages = []
|
29 |
+
for frame in frames:
|
30 |
+
segments = frame.split(":", 1)
|
31 |
+
if len(segments) == 2:
|
32 |
+
frame_messages.append(segments[1].strip())
|
33 |
+
else:
|
34 |
+
frame_messages.append("<unknown frame>")
|
35 |
+
return infra.Stack(
|
36 |
+
frames=[
|
37 |
+
infra.StackFrame(location=infra.Location(message=message))
|
38 |
+
for message in frame_messages
|
39 |
+
]
|
40 |
+
)
|
41 |
+
|
42 |
+
|
43 |
+
class TorchScriptOnnxExportDiagnostic(infra.Diagnostic):
|
44 |
+
"""Base class for all export diagnostics.
|
45 |
+
|
46 |
+
This class is used to represent all export diagnostics. It is a subclass of
|
47 |
+
infra.Diagnostic, and adds additional methods to add more information to the
|
48 |
+
diagnostic.
|
49 |
+
"""
|
50 |
+
|
51 |
+
python_call_stack: Optional[infra.Stack] = None
|
52 |
+
cpp_call_stack: Optional[infra.Stack] = None
|
53 |
+
|
54 |
+
def __init__(
|
55 |
+
self,
|
56 |
+
*args,
|
57 |
+
frames_to_skip: int = 1,
|
58 |
+
cpp_stack: bool = False,
|
59 |
+
**kwargs,
|
60 |
+
) -> None:
|
61 |
+
super().__init__(*args, **kwargs)
|
62 |
+
self.python_call_stack = self.record_python_call_stack(
|
63 |
+
frames_to_skip=frames_to_skip
|
64 |
+
)
|
65 |
+
if cpp_stack:
|
66 |
+
self.cpp_call_stack = self.record_cpp_call_stack(
|
67 |
+
frames_to_skip=frames_to_skip
|
68 |
+
)
|
69 |
+
|
70 |
+
def record_cpp_call_stack(self, frames_to_skip: int) -> infra.Stack:
|
71 |
+
"""Records the current C++ call stack in the diagnostic."""
|
72 |
+
# NOTE: Cannot use `@_beartype.beartype`. It somehow erases the cpp stack frame info.
|
73 |
+
# No need to skip this function because python frame is not recorded
|
74 |
+
# in cpp call stack.
|
75 |
+
stack = _cpp_call_stack(frames_to_skip=frames_to_skip)
|
76 |
+
stack.message = "C++ call stack"
|
77 |
+
self.with_stack(stack)
|
78 |
+
return stack
|
79 |
+
|
80 |
+
|
81 |
+
class ExportDiagnosticEngine:
|
82 |
+
"""PyTorch ONNX Export diagnostic engine.
|
83 |
+
|
84 |
+
The only purpose of creating this class instead of using `DiagnosticContext` directly
|
85 |
+
is to provide a background context for `diagnose` calls inside exporter.
|
86 |
+
|
87 |
+
By design, one `torch.onnx.export` call should initialize one diagnostic context.
|
88 |
+
All `diagnose` calls inside exporter should be made in the context of that export.
|
89 |
+
However, since diagnostic context is currently being accessed via a global variable,
|
90 |
+
there is no guarantee that the context is properly initialized. Therefore, we need
|
91 |
+
to provide a default background context to fallback to, otherwise any invocation of
|
92 |
+
exporter internals, e.g. unit tests, will fail due to missing diagnostic context.
|
93 |
+
This can be removed once the pipeline for context to flow through the exporter is
|
94 |
+
established.
|
95 |
+
"""
|
96 |
+
|
97 |
+
contexts: List[infra.DiagnosticContext]
|
98 |
+
_background_context: infra.DiagnosticContext
|
99 |
+
|
100 |
+
def __init__(self) -> None:
|
101 |
+
self.contexts = []
|
102 |
+
self._background_context = infra.DiagnosticContext(
|
103 |
+
name="torch.onnx",
|
104 |
+
version=torch.__version__,
|
105 |
+
)
|
106 |
+
|
107 |
+
@property
|
108 |
+
def background_context(self) -> infra.DiagnosticContext:
|
109 |
+
return self._background_context
|
110 |
+
|
111 |
+
def create_diagnostic_context(
|
112 |
+
self,
|
113 |
+
name: str,
|
114 |
+
version: str,
|
115 |
+
options: Optional[infra.DiagnosticOptions] = None,
|
116 |
+
) -> infra.DiagnosticContext:
|
117 |
+
"""Creates a new diagnostic context.
|
118 |
+
|
119 |
+
Args:
|
120 |
+
name: The subject name for the diagnostic context.
|
121 |
+
version: The subject version for the diagnostic context.
|
122 |
+
options: The options for the diagnostic context.
|
123 |
+
|
124 |
+
Returns:
|
125 |
+
A new diagnostic context.
|
126 |
+
"""
|
127 |
+
if options is None:
|
128 |
+
options = infra.DiagnosticOptions()
|
129 |
+
context: infra.DiagnosticContext[infra.Diagnostic] = infra.DiagnosticContext(
|
130 |
+
name, version, options
|
131 |
+
)
|
132 |
+
self.contexts.append(context)
|
133 |
+
return context
|
134 |
+
|
135 |
+
def clear(self):
|
136 |
+
"""Clears all diagnostic contexts."""
|
137 |
+
self.contexts.clear()
|
138 |
+
self._background_context.diagnostics.clear()
|
139 |
+
|
140 |
+
def to_json(self) -> str:
|
141 |
+
return formatter.sarif_to_json(self.sarif_log())
|
142 |
+
|
143 |
+
def dump(self, file_path: str, compress: bool = False) -> None:
|
144 |
+
"""Dumps the SARIF log to a file."""
|
145 |
+
if compress:
|
146 |
+
with gzip.open(file_path, "wt") as f:
|
147 |
+
f.write(self.to_json())
|
148 |
+
else:
|
149 |
+
with open(file_path, "w") as f:
|
150 |
+
f.write(self.to_json())
|
151 |
+
|
152 |
+
def sarif_log(self):
|
153 |
+
log = sarif.SarifLog(
|
154 |
+
version=sarif_version.SARIF_VERSION,
|
155 |
+
schema_uri=sarif_version.SARIF_SCHEMA_LINK,
|
156 |
+
runs=[context.sarif() for context in self.contexts],
|
157 |
+
)
|
158 |
+
|
159 |
+
log.runs.append(self._background_context.sarif())
|
160 |
+
return log
|
161 |
+
|
162 |
+
|
163 |
+
engine = ExportDiagnosticEngine()
|
164 |
+
_context = engine.background_context
|
165 |
+
|
166 |
+
|
167 |
+
@contextlib.contextmanager
|
168 |
+
def create_export_diagnostic_context() -> (
|
169 |
+
Generator[infra.DiagnosticContext, None, None]
|
170 |
+
):
|
171 |
+
"""Create a diagnostic context for export.
|
172 |
+
|
173 |
+
This is a workaround for code robustness since diagnostic context is accessed by
|
174 |
+
export internals via global variable. See `ExportDiagnosticEngine` for more details.
|
175 |
+
"""
|
176 |
+
global _context
|
177 |
+
assert (
|
178 |
+
_context == engine.background_context
|
179 |
+
), "Export context is already set. Nested export is not supported."
|
180 |
+
_context = engine.create_diagnostic_context(
|
181 |
+
"torch.onnx.export",
|
182 |
+
torch.__version__,
|
183 |
+
)
|
184 |
+
try:
|
185 |
+
yield _context
|
186 |
+
finally:
|
187 |
+
_context = engine.background_context
|
188 |
+
|
189 |
+
|
190 |
+
def diagnose(
|
191 |
+
rule: infra.Rule,
|
192 |
+
level: infra.Level,
|
193 |
+
message: Optional[str] = None,
|
194 |
+
frames_to_skip: int = 2,
|
195 |
+
**kwargs,
|
196 |
+
) -> TorchScriptOnnxExportDiagnostic:
|
197 |
+
"""Creates a diagnostic and record it in the global diagnostic context.
|
198 |
+
|
199 |
+
This is a wrapper around `context.log` that uses the global diagnostic
|
200 |
+
context.
|
201 |
+
"""
|
202 |
+
# NOTE: Cannot use `@_beartype.beartype`. It somehow erases the cpp stack frame info.
|
203 |
+
diagnostic = TorchScriptOnnxExportDiagnostic(
|
204 |
+
rule, level, message, frames_to_skip=frames_to_skip, **kwargs
|
205 |
+
)
|
206 |
+
export_context().log(diagnostic)
|
207 |
+
return diagnostic
|
208 |
+
|
209 |
+
|
210 |
+
def export_context() -> infra.DiagnosticContext:
|
211 |
+
global _context
|
212 |
+
return _context
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/_rules.py
ADDED
@@ -0,0 +1,634 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
GENERATED CODE - DO NOT EDIT DIRECTLY
|
3 |
+
This file is generated by gen_diagnostics.py.
|
4 |
+
See tools/onnx/gen_diagnostics.py for more information.
|
5 |
+
|
6 |
+
Diagnostic rules for PyTorch ONNX export.
|
7 |
+
"""
|
8 |
+
|
9 |
+
import dataclasses
|
10 |
+
from typing import Tuple
|
11 |
+
|
12 |
+
# flake8: noqa
|
13 |
+
from torch.onnx._internal.diagnostics import infra
|
14 |
+
|
15 |
+
"""
|
16 |
+
GENERATED CODE - DO NOT EDIT DIRECTLY
|
17 |
+
The purpose of generating a class for each rule is to override the `format_message`
|
18 |
+
method to provide more details in the signature about the format arguments.
|
19 |
+
"""
|
20 |
+
|
21 |
+
|
22 |
+
class _NodeMissingOnnxShapeInference(infra.Rule):
|
23 |
+
"""Node is missing ONNX shape inference."""
|
24 |
+
|
25 |
+
def format_message(self, op_name) -> str: # type: ignore[override]
|
26 |
+
"""Returns the formatted default message of this Rule.
|
27 |
+
|
28 |
+
Message template: 'The shape inference of {op_name} type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.'
|
29 |
+
"""
|
30 |
+
return self.message_default_template.format(op_name=op_name)
|
31 |
+
|
32 |
+
def format( # type: ignore[override]
|
33 |
+
self, level: infra.Level, op_name
|
34 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
35 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
36 |
+
|
37 |
+
Message template: 'The shape inference of {op_name} type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.'
|
38 |
+
"""
|
39 |
+
return self, level, self.format_message(op_name=op_name)
|
40 |
+
|
41 |
+
|
42 |
+
class _MissingCustomSymbolicFunction(infra.Rule):
|
43 |
+
"""Missing symbolic function for custom PyTorch operator, cannot translate node to ONNX."""
|
44 |
+
|
45 |
+
def format_message(self, op_name) -> str: # type: ignore[override]
|
46 |
+
"""Returns the formatted default message of this Rule.
|
47 |
+
|
48 |
+
Message template: 'ONNX export failed on an operator with unrecognized namespace {op_name}. If you are trying to export a custom operator, make sure you registered it with the right domain and version.'
|
49 |
+
"""
|
50 |
+
return self.message_default_template.format(op_name=op_name)
|
51 |
+
|
52 |
+
def format( # type: ignore[override]
|
53 |
+
self, level: infra.Level, op_name
|
54 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
55 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
56 |
+
|
57 |
+
Message template: 'ONNX export failed on an operator with unrecognized namespace {op_name}. If you are trying to export a custom operator, make sure you registered it with the right domain and version.'
|
58 |
+
"""
|
59 |
+
return self, level, self.format_message(op_name=op_name)
|
60 |
+
|
61 |
+
|
62 |
+
class _MissingStandardSymbolicFunction(infra.Rule):
|
63 |
+
"""Missing symbolic function for standard PyTorch operator, cannot translate node to ONNX."""
|
64 |
+
|
65 |
+
def format_message( # type: ignore[override]
|
66 |
+
self, op_name, opset_version, issue_url
|
67 |
+
) -> str:
|
68 |
+
"""Returns the formatted default message of this Rule.
|
69 |
+
|
70 |
+
Message template: "Exporting the operator '{op_name}' to ONNX opset version {opset_version} is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub: {issue_url}."
|
71 |
+
"""
|
72 |
+
return self.message_default_template.format(
|
73 |
+
op_name=op_name, opset_version=opset_version, issue_url=issue_url
|
74 |
+
)
|
75 |
+
|
76 |
+
def format( # type: ignore[override]
|
77 |
+
self, level: infra.Level, op_name, opset_version, issue_url
|
78 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
79 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
80 |
+
|
81 |
+
Message template: "Exporting the operator '{op_name}' to ONNX opset version {opset_version} is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub: {issue_url}."
|
82 |
+
"""
|
83 |
+
return (
|
84 |
+
self,
|
85 |
+
level,
|
86 |
+
self.format_message(
|
87 |
+
op_name=op_name, opset_version=opset_version, issue_url=issue_url
|
88 |
+
),
|
89 |
+
)
|
90 |
+
|
91 |
+
|
92 |
+
class _OperatorSupportedInNewerOpsetVersion(infra.Rule):
|
93 |
+
"""Operator is supported in newer opset version."""
|
94 |
+
|
95 |
+
def format_message( # type: ignore[override]
|
96 |
+
self, op_name, opset_version, supported_opset_version
|
97 |
+
) -> str:
|
98 |
+
"""Returns the formatted default message of this Rule.
|
99 |
+
|
100 |
+
Message template: "Exporting the operator '{op_name}' to ONNX opset version {opset_version} is not supported. Support for this operator was added in version {supported_opset_version}, try exporting with this version."
|
101 |
+
"""
|
102 |
+
return self.message_default_template.format(
|
103 |
+
op_name=op_name,
|
104 |
+
opset_version=opset_version,
|
105 |
+
supported_opset_version=supported_opset_version,
|
106 |
+
)
|
107 |
+
|
108 |
+
def format( # type: ignore[override]
|
109 |
+
self, level: infra.Level, op_name, opset_version, supported_opset_version
|
110 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
111 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
112 |
+
|
113 |
+
Message template: "Exporting the operator '{op_name}' to ONNX opset version {opset_version} is not supported. Support for this operator was added in version {supported_opset_version}, try exporting with this version."
|
114 |
+
"""
|
115 |
+
return (
|
116 |
+
self,
|
117 |
+
level,
|
118 |
+
self.format_message(
|
119 |
+
op_name=op_name,
|
120 |
+
opset_version=opset_version,
|
121 |
+
supported_opset_version=supported_opset_version,
|
122 |
+
),
|
123 |
+
)
|
124 |
+
|
125 |
+
|
126 |
+
class _FxGraphToOnnx(infra.Rule):
|
127 |
+
"""Transforms graph from FX IR to ONNX IR."""
|
128 |
+
|
129 |
+
def format_message(self, graph_name) -> str: # type: ignore[override]
|
130 |
+
"""Returns the formatted default message of this Rule.
|
131 |
+
|
132 |
+
Message template: 'Transforming FX graph {graph_name} to ONNX graph.'
|
133 |
+
"""
|
134 |
+
return self.message_default_template.format(graph_name=graph_name)
|
135 |
+
|
136 |
+
def format( # type: ignore[override]
|
137 |
+
self, level: infra.Level, graph_name
|
138 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
139 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
140 |
+
|
141 |
+
Message template: 'Transforming FX graph {graph_name} to ONNX graph.'
|
142 |
+
"""
|
143 |
+
return self, level, self.format_message(graph_name=graph_name)
|
144 |
+
|
145 |
+
|
146 |
+
class _FxNodeToOnnx(infra.Rule):
|
147 |
+
"""Transforms an FX node to an ONNX node."""
|
148 |
+
|
149 |
+
def format_message(self, node_repr) -> str: # type: ignore[override]
|
150 |
+
"""Returns the formatted default message of this Rule.
|
151 |
+
|
152 |
+
Message template: 'Transforming FX node {node_repr} to ONNX node.'
|
153 |
+
"""
|
154 |
+
return self.message_default_template.format(node_repr=node_repr)
|
155 |
+
|
156 |
+
def format( # type: ignore[override]
|
157 |
+
self, level: infra.Level, node_repr
|
158 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
159 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
160 |
+
|
161 |
+
Message template: 'Transforming FX node {node_repr} to ONNX node.'
|
162 |
+
"""
|
163 |
+
return self, level, self.format_message(node_repr=node_repr)
|
164 |
+
|
165 |
+
|
166 |
+
class _FxPass(infra.Rule):
|
167 |
+
"""FX graph transformation during ONNX export before converting from FX IR to ONNX IR."""
|
168 |
+
|
169 |
+
def format_message(self, pass_name) -> str: # type: ignore[override]
|
170 |
+
"""Returns the formatted default message of this Rule.
|
171 |
+
|
172 |
+
Message template: 'Running {pass_name} pass.'
|
173 |
+
"""
|
174 |
+
return self.message_default_template.format(pass_name=pass_name)
|
175 |
+
|
176 |
+
def format( # type: ignore[override]
|
177 |
+
self, level: infra.Level, pass_name
|
178 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
179 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
180 |
+
|
181 |
+
Message template: 'Running {pass_name} pass.'
|
182 |
+
"""
|
183 |
+
return self, level, self.format_message(pass_name=pass_name)
|
184 |
+
|
185 |
+
|
186 |
+
class _NoSymbolicFunctionForCallFunction(infra.Rule):
|
187 |
+
"""Cannot find symbolic function to convert the "call_function" FX node to ONNX."""
|
188 |
+
|
189 |
+
def format_message(self, target) -> str: # type: ignore[override]
|
190 |
+
"""Returns the formatted default message of this Rule.
|
191 |
+
|
192 |
+
Message template: 'No symbolic function to convert the "call_function" node {target} to ONNX. '
|
193 |
+
"""
|
194 |
+
return self.message_default_template.format(target=target)
|
195 |
+
|
196 |
+
def format( # type: ignore[override]
|
197 |
+
self, level: infra.Level, target
|
198 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
199 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
200 |
+
|
201 |
+
Message template: 'No symbolic function to convert the "call_function" node {target} to ONNX. '
|
202 |
+
"""
|
203 |
+
return self, level, self.format_message(target=target)
|
204 |
+
|
205 |
+
|
206 |
+
class _UnsupportedFxNodeAnalysis(infra.Rule):
|
207 |
+
"""Result from FX graph analysis to reveal unsupported FX nodes."""
|
208 |
+
|
209 |
+
def format_message( # type: ignore[override]
|
210 |
+
self, node_op_to_target_mapping
|
211 |
+
) -> str:
|
212 |
+
"""Returns the formatted default message of this Rule.
|
213 |
+
|
214 |
+
Message template: 'Unsupported FX nodes: {node_op_to_target_mapping}. '
|
215 |
+
"""
|
216 |
+
return self.message_default_template.format(
|
217 |
+
node_op_to_target_mapping=node_op_to_target_mapping
|
218 |
+
)
|
219 |
+
|
220 |
+
def format( # type: ignore[override]
|
221 |
+
self, level: infra.Level, node_op_to_target_mapping
|
222 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
223 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
224 |
+
|
225 |
+
Message template: 'Unsupported FX nodes: {node_op_to_target_mapping}. '
|
226 |
+
"""
|
227 |
+
return (
|
228 |
+
self,
|
229 |
+
level,
|
230 |
+
self.format_message(node_op_to_target_mapping=node_op_to_target_mapping),
|
231 |
+
)
|
232 |
+
|
233 |
+
|
234 |
+
class _OpLevelDebugging(infra.Rule):
|
235 |
+
"""Report any op level validation failure in warnings."""
|
236 |
+
|
237 |
+
def format_message(self, node, symbolic_fn) -> str: # type: ignore[override]
|
238 |
+
"""Returns the formatted default message of this Rule.
|
239 |
+
|
240 |
+
Message template: 'FX node: {node} and its onnx function: {symbolic_fn} fails on op level validation.'
|
241 |
+
"""
|
242 |
+
return self.message_default_template.format(node=node, symbolic_fn=symbolic_fn)
|
243 |
+
|
244 |
+
def format( # type: ignore[override]
|
245 |
+
self, level: infra.Level, node, symbolic_fn
|
246 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
247 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
248 |
+
|
249 |
+
Message template: 'FX node: {node} and its onnx function: {symbolic_fn} fails on op level validation.'
|
250 |
+
"""
|
251 |
+
return self, level, self.format_message(node=node, symbolic_fn=symbolic_fn)
|
252 |
+
|
253 |
+
|
254 |
+
class _FindOpschemaMatchedSymbolicFunction(infra.Rule):
|
255 |
+
"""Find the OnnxFunction that matches the input/attribute dtypes by comparing them with their opschemas."""
|
256 |
+
|
257 |
+
def format_message(self, symbolic_fn, node) -> str: # type: ignore[override]
|
258 |
+
"""Returns the formatted default message of this Rule.
|
259 |
+
|
260 |
+
Message template: 'The OnnxFunction: {symbolic_fn} is the nearest match of the node {node}.'
|
261 |
+
"""
|
262 |
+
return self.message_default_template.format(symbolic_fn=symbolic_fn, node=node)
|
263 |
+
|
264 |
+
def format( # type: ignore[override]
|
265 |
+
self, level: infra.Level, symbolic_fn, node
|
266 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
267 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
268 |
+
|
269 |
+
Message template: 'The OnnxFunction: {symbolic_fn} is the nearest match of the node {node}.'
|
270 |
+
"""
|
271 |
+
return self, level, self.format_message(symbolic_fn=symbolic_fn, node=node)
|
272 |
+
|
273 |
+
|
274 |
+
class _FxNodeInsertTypePromotion(infra.Rule):
|
275 |
+
"""Determine if type promotion is required for the FX node. Insert cast nodes if needed."""
|
276 |
+
|
277 |
+
def format_message(self, target) -> str: # type: ignore[override]
|
278 |
+
"""Returns the formatted default message of this Rule.
|
279 |
+
|
280 |
+
Message template: 'Performing explicit type promotion for node {target}. '
|
281 |
+
"""
|
282 |
+
return self.message_default_template.format(target=target)
|
283 |
+
|
284 |
+
def format( # type: ignore[override]
|
285 |
+
self, level: infra.Level, target
|
286 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
287 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
288 |
+
|
289 |
+
Message template: 'Performing explicit type promotion for node {target}. '
|
290 |
+
"""
|
291 |
+
return self, level, self.format_message(target=target)
|
292 |
+
|
293 |
+
|
294 |
+
class _FindOperatorOverloadsInOnnxRegistry(infra.Rule):
|
295 |
+
"""Find the list of OnnxFunction of the PyTorch operator in onnx registry."""
|
296 |
+
|
297 |
+
def format_message(self, node) -> str: # type: ignore[override]
|
298 |
+
"""Returns the formatted default message of this Rule.
|
299 |
+
|
300 |
+
Message template: 'Checking if the FX node: {node} is supported in onnx registry.'
|
301 |
+
"""
|
302 |
+
return self.message_default_template.format(node=node)
|
303 |
+
|
304 |
+
def format( # type: ignore[override]
|
305 |
+
self, level: infra.Level, node
|
306 |
+
) -> Tuple[infra.Rule, infra.Level, str]:
|
307 |
+
"""Returns a tuple of (Rule, Level, message) for this Rule.
|
308 |
+
|
309 |
+
Message template: 'Checking if the FX node: {node} is supported in onnx registry.'
|
310 |
+
"""
|
311 |
+
return self, level, self.format_message(node=node)
|
312 |
+
|
313 |
+
|
314 |
+
@dataclasses.dataclass
|
315 |
+
class _POERules(infra.RuleCollection):
|
316 |
+
node_missing_onnx_shape_inference: _NodeMissingOnnxShapeInference = dataclasses.field(
|
317 |
+
default=_NodeMissingOnnxShapeInference.from_sarif(
|
318 |
+
**{
|
319 |
+
"id": "POE0001",
|
320 |
+
"name": "node-missing-onnx-shape-inference",
|
321 |
+
"short_description": {"text": "Node is missing ONNX shape inference."},
|
322 |
+
"full_description": {
|
323 |
+
"text": "Node is missing ONNX shape inference. This usually happens when the node is not valid under standard ONNX operator spec.",
|
324 |
+
"markdown": "Node is missing ONNX shape inference.\nThis usually happens when the node is not valid under standard ONNX operator spec.\n",
|
325 |
+
},
|
326 |
+
"message_strings": {
|
327 |
+
"default": {
|
328 |
+
"text": "The shape inference of {op_name} type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function."
|
329 |
+
}
|
330 |
+
},
|
331 |
+
"help_uri": None,
|
332 |
+
"properties": {"deprecated": False, "tags": []},
|
333 |
+
}
|
334 |
+
),
|
335 |
+
init=False,
|
336 |
+
)
|
337 |
+
"""Node is missing ONNX shape inference."""
|
338 |
+
|
339 |
+
missing_custom_symbolic_function: _MissingCustomSymbolicFunction = dataclasses.field(
|
340 |
+
default=_MissingCustomSymbolicFunction.from_sarif(
|
341 |
+
**{
|
342 |
+
"id": "POE0002",
|
343 |
+
"name": "missing-custom-symbolic-function",
|
344 |
+
"short_description": {
|
345 |
+
"text": "Missing symbolic function for custom PyTorch operator, cannot translate node to ONNX."
|
346 |
+
},
|
347 |
+
"full_description": {
|
348 |
+
"text": "Missing symbolic function for custom PyTorch operator, cannot translate node to ONNX.",
|
349 |
+
"markdown": "Missing symbolic function for custom PyTorch operator, cannot translate node to ONNX.\n",
|
350 |
+
},
|
351 |
+
"message_strings": {
|
352 |
+
"default": {
|
353 |
+
"text": "ONNX export failed on an operator with unrecognized namespace {op_name}. If you are trying to export a custom operator, make sure you registered it with the right domain and version."
|
354 |
+
}
|
355 |
+
},
|
356 |
+
"help_uri": None,
|
357 |
+
"properties": {"deprecated": False, "tags": []},
|
358 |
+
}
|
359 |
+
),
|
360 |
+
init=False,
|
361 |
+
)
|
362 |
+
"""Missing symbolic function for custom PyTorch operator, cannot translate node to ONNX."""
|
363 |
+
|
364 |
+
missing_standard_symbolic_function: _MissingStandardSymbolicFunction = dataclasses.field(
|
365 |
+
default=_MissingStandardSymbolicFunction.from_sarif(
|
366 |
+
**{
|
367 |
+
"id": "POE0003",
|
368 |
+
"name": "missing-standard-symbolic-function",
|
369 |
+
"short_description": {
|
370 |
+
"text": "Missing symbolic function for standard PyTorch operator, cannot translate node to ONNX."
|
371 |
+
},
|
372 |
+
"full_description": {
|
373 |
+
"text": "Missing symbolic function for standard PyTorch operator, cannot translate node to ONNX.",
|
374 |
+
"markdown": "Missing symbolic function for standard PyTorch operator, cannot translate node to ONNX.\n",
|
375 |
+
},
|
376 |
+
"message_strings": {
|
377 |
+
"default": {
|
378 |
+
"text": "Exporting the operator '{op_name}' to ONNX opset version {opset_version} is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub: {issue_url}."
|
379 |
+
}
|
380 |
+
},
|
381 |
+
"help_uri": None,
|
382 |
+
"properties": {"deprecated": False, "tags": []},
|
383 |
+
}
|
384 |
+
),
|
385 |
+
init=False,
|
386 |
+
)
|
387 |
+
"""Missing symbolic function for standard PyTorch operator, cannot translate node to ONNX."""
|
388 |
+
|
389 |
+
operator_supported_in_newer_opset_version: _OperatorSupportedInNewerOpsetVersion = dataclasses.field(
|
390 |
+
default=_OperatorSupportedInNewerOpsetVersion.from_sarif(
|
391 |
+
**{
|
392 |
+
"id": "POE0004",
|
393 |
+
"name": "operator-supported-in-newer-opset-version",
|
394 |
+
"short_description": {
|
395 |
+
"text": "Operator is supported in newer opset version."
|
396 |
+
},
|
397 |
+
"full_description": {
|
398 |
+
"text": "Operator is supported in newer opset version.",
|
399 |
+
"markdown": "Operator is supported in newer opset version.\n\nExample:\n```python\ntorch.onnx.export(model, args, ..., opset_version=9)\n```\n",
|
400 |
+
},
|
401 |
+
"message_strings": {
|
402 |
+
"default": {
|
403 |
+
"text": "Exporting the operator '{op_name}' to ONNX opset version {opset_version} is not supported. Support for this operator was added in version {supported_opset_version}, try exporting with this version."
|
404 |
+
}
|
405 |
+
},
|
406 |
+
"help_uri": None,
|
407 |
+
"properties": {"deprecated": False, "tags": []},
|
408 |
+
}
|
409 |
+
),
|
410 |
+
init=False,
|
411 |
+
)
|
412 |
+
"""Operator is supported in newer opset version."""
|
413 |
+
|
414 |
+
fx_graph_to_onnx: _FxGraphToOnnx = dataclasses.field(
|
415 |
+
default=_FxGraphToOnnx.from_sarif(
|
416 |
+
**{
|
417 |
+
"id": "FXE0007",
|
418 |
+
"name": "fx-graph-to-onnx",
|
419 |
+
"short_description": {
|
420 |
+
"text": "Transforms graph from FX IR to ONNX IR."
|
421 |
+
},
|
422 |
+
"full_description": {
|
423 |
+
"text": "Transforms graph from FX IR to ONNX IR.",
|
424 |
+
"markdown": "This diagnostic tracks the transformation process from an FX Graph (in FX IR) to an ONNX Graph (in ONNX IR).\n\n## Key Representations:\n\n- **FX Graph**: The graph in FX IR produced by dynamo or symbolic tracing.\n- **ONNX Graph**: The graph in ONNX IR and [operators](https://onnx.ai/onnx/operators/).\n\n## Additional Notes:\n\n- Prior to this transformation step, the FX graph undergoes preprocessing through multiple FX passes.\n To gain insight into these transformations, refer to diagnostic `FXE0010`.\n- To enable a detailed view of the graph transformation in progress within this diagnostic, switch to the DEBUG mode.\n\n - Set DiagnosticOptions.verbosity_level to logging.DEBUG.\n - Activate the environment variable TORCH_LOGS='onnx_diagnostics'.\n\n- For specific information related to node-level FX to ONNX transformations, explore the diagnostic `FXE0008`.\n",
|
425 |
+
},
|
426 |
+
"message_strings": {
|
427 |
+
"default": {
|
428 |
+
"text": "Transforming FX graph {graph_name} to ONNX graph."
|
429 |
+
}
|
430 |
+
},
|
431 |
+
"help_uri": None,
|
432 |
+
"properties": {"deprecated": False, "tags": []},
|
433 |
+
}
|
434 |
+
),
|
435 |
+
init=False,
|
436 |
+
)
|
437 |
+
"""Transforms graph from FX IR to ONNX IR."""
|
438 |
+
|
439 |
+
fx_node_to_onnx: _FxNodeToOnnx = dataclasses.field(
|
440 |
+
default=_FxNodeToOnnx.from_sarif(
|
441 |
+
**{
|
442 |
+
"id": "FXE0008",
|
443 |
+
"name": "fx-node-to-onnx",
|
444 |
+
"short_description": {"text": "Transforms an FX node to an ONNX node."},
|
445 |
+
"full_description": {
|
446 |
+
"text": "Transforms an FX node to an ONNX node.",
|
447 |
+
"markdown": "This diagnostic tracks the transformation process from an FX Node to ONNX [Operators](https://onnx.ai/onnx/operators/).\n\nThe process of converting FX Node to ONNX Node involves dealing with six distinct node types:\n 1. `placeholder`: Represents a module input, maps to an ONNX graph input.\n 2. `call_module`: Symbolizes a call to a submodule, maps to an ONNX\n 3. `call_method`: Symbolizes a method call. Not yet implemented.\n 4. `call_function`: Symbolizes a function call. [Core ATen](https://pytorch.org/docs/stable/ir.html#core-aten-ir) is expected\n as the function call target. The mapping from ATen to ONNX is implemented by [ONNXScript torchlib](https://github.com/microsoft/onnxscript/tree/main/onnxscript/function_libs/torch_lib/ops).\n This [guide](https://pytorch.org/docs/stable/onnx.html#onnx-script-functions) shows how to write and register a custom symbolic function for call_function FX node.\n 5. `get_attr`: Indicates an attribute access within the current module. Maps to an ONNX graph initializer.\n 6. `output`: Represents the module's output. Maps to an ONNX graph output.\n\nFor a granular understanding of how each node type is transformed, refer to the implementation details in `FxOnnxInterpreter`.\n",
|
448 |
+
},
|
449 |
+
"message_strings": {
|
450 |
+
"default": {
|
451 |
+
"text": "Transforming FX node {node_repr} to ONNX node."
|
452 |
+
}
|
453 |
+
},
|
454 |
+
"help_uri": None,
|
455 |
+
"properties": {"deprecated": False, "tags": []},
|
456 |
+
}
|
457 |
+
),
|
458 |
+
init=False,
|
459 |
+
)
|
460 |
+
"""Transforms an FX node to an ONNX node."""
|
461 |
+
|
462 |
+
fx_pass: _FxPass = dataclasses.field(
|
463 |
+
default=_FxPass.from_sarif(
|
464 |
+
**{
|
465 |
+
"id": "FXE0010",
|
466 |
+
"name": "fx-pass",
|
467 |
+
"short_description": {
|
468 |
+
"text": "FX graph transformation during ONNX export before converting from FX IR to ONNX IR."
|
469 |
+
},
|
470 |
+
"full_description": {
|
471 |
+
"text": "FX graph transformation during ONNX export before converting from FX IR to ONNX IR.",
|
472 |
+
"markdown": "This diagnostic tracks the FX passes executed during the ONNX export process prior\nto converting from FX IR (Intermediate Representation) to ONNX IR.\n\nUnder the scope of ONNX export, an FX pass refers to a specific transformation applied to the FX GraphModule.\nThe primary aim of these passes is to streamline the graph into a format that aligns more with the ONNX IR.\nMoreover, these passes work to substitute unsupported FX IR features with those recognized and endorsed by\nONNX IR. Common transformations include, but aren't limited to, decomposition, functionalization and\ntype promotion.\n\nFor those who are interested in a comprehensive log detailing the modifications made during these passes,\nthere are a couple of options:\n\n- Set DiagnosticOptions.verbosity_level to logging.DEBUG.\n- Activate the environment variable TORCH_LOGS='onnx_diagnostics'.\n\nHowever, it's noteworthy that by default, such detailed logging is turned off. The primary reason being\nits considerable impact on performance.\n\nFor an in-depth understanding of each specific pass, please refer to the directory: torch/onnx/_internal/fx/passes.\n",
|
473 |
+
},
|
474 |
+
"message_strings": {"default": {"text": "Running {pass_name} pass."}},
|
475 |
+
"help_uri": None,
|
476 |
+
"properties": {"deprecated": False, "tags": []},
|
477 |
+
}
|
478 |
+
),
|
479 |
+
init=False,
|
480 |
+
)
|
481 |
+
"""FX graph transformation during ONNX export before converting from FX IR to ONNX IR."""
|
482 |
+
|
483 |
+
no_symbolic_function_for_call_function: _NoSymbolicFunctionForCallFunction = dataclasses.field(
|
484 |
+
default=_NoSymbolicFunctionForCallFunction.from_sarif(
|
485 |
+
**{
|
486 |
+
"id": "FXE0011",
|
487 |
+
"name": "no-symbolic-function-for-call-function",
|
488 |
+
"short_description": {
|
489 |
+
"text": 'Cannot find symbolic function to convert the "call_function" FX node to ONNX.'
|
490 |
+
},
|
491 |
+
"full_description": {
|
492 |
+
"text": 'Cannot find symbolic function to convert the "call_function" FX node to ONNX. ',
|
493 |
+
"markdown": 'This error occurs when the ONNX converter is unable to find a corresponding symbolic function\nto convert a "call_function" node in the input graph to its equivalence in ONNX. The "call_function"\nnode represents a normalized function call in PyTorch, such as "torch.aten.ops.add".\n\nTo resolve this error, you can try one of the following:\n\n- If exists, apply the auto-fix suggested by the diagnostic. TODO: this part is not available yet.\n- Rewrite the model using only supported PyTorch operators or functions.\n- Follow this [guide](https://pytorch.org/tutorials/beginner/onnx/onnx_registry_tutorial.html#overview) to write and\n register a custom symbolic function for the unsupported call_function FX node.\n',
|
494 |
+
},
|
495 |
+
"message_strings": {
|
496 |
+
"default": {
|
497 |
+
"text": 'No symbolic function to convert the "call_function" node {target} to ONNX. '
|
498 |
+
}
|
499 |
+
},
|
500 |
+
"help_uri": None,
|
501 |
+
"properties": {"deprecated": False, "tags": []},
|
502 |
+
}
|
503 |
+
),
|
504 |
+
init=False,
|
505 |
+
)
|
506 |
+
"""Cannot find symbolic function to convert the "call_function" FX node to ONNX."""
|
507 |
+
|
508 |
+
unsupported_fx_node_analysis: _UnsupportedFxNodeAnalysis = dataclasses.field(
|
509 |
+
default=_UnsupportedFxNodeAnalysis.from_sarif(
|
510 |
+
**{
|
511 |
+
"id": "FXE0012",
|
512 |
+
"name": "unsupported-fx-node-analysis",
|
513 |
+
"short_description": {
|
514 |
+
"text": "Result from FX graph analysis to reveal unsupported FX nodes."
|
515 |
+
},
|
516 |
+
"full_description": {
|
517 |
+
"text": "Result from FX graph analysis to reveal unsupported FX nodes.",
|
518 |
+
"markdown": "This error indicates that an FX graph contains one or more unsupported nodes. The error message\nis typically accompanied by a list of the unsupported nodes found during analysis.\n\nTo resolve this error, you can try resolving each individual unsupported node error by following\nthe suggestions by its diagnostic. Typically, options include:\n\n- If exists, apply the auto-fix suggested by the diagnostic. TODO: this part is not available yet.\n- Rewrite the model using only supported PyTorch operators or functions.\n- Follow this [guide](https://pytorch.org/docs/stable/onnx.html#onnx-script-functions) to write and\n register a custom symbolic function for the unsupported call_function FX node.\n",
|
519 |
+
},
|
520 |
+
"message_strings": {
|
521 |
+
"default": {
|
522 |
+
"text": "Unsupported FX nodes: {node_op_to_target_mapping}. "
|
523 |
+
}
|
524 |
+
},
|
525 |
+
"help_uri": None,
|
526 |
+
"properties": {"deprecated": False, "tags": []},
|
527 |
+
}
|
528 |
+
),
|
529 |
+
init=False,
|
530 |
+
)
|
531 |
+
"""Result from FX graph analysis to reveal unsupported FX nodes."""
|
532 |
+
|
533 |
+
op_level_debugging: _OpLevelDebugging = dataclasses.field(
|
534 |
+
default=_OpLevelDebugging.from_sarif(
|
535 |
+
**{
|
536 |
+
"id": "FXE0013",
|
537 |
+
"name": "op-level-debugging",
|
538 |
+
"short_description": {
|
539 |
+
"text": "Report any op level validation failure in warnings."
|
540 |
+
},
|
541 |
+
"full_description": {
|
542 |
+
"text": "Report any op level validation failure in warnings.",
|
543 |
+
"markdown": "This warning message indicates that during op level debugging, certain symbolic functions\nhave failed to match the results of torch ops when using real tensors generated from fake\ntensors. It is important to note that the symbolic functions may not necessarily be\nincorrect, as the validation process is non-deterministic and should only be used as a\nreference.\n\nThere are two categories of warnings that can be triggered:\n\n1. Non-validated operators:\n If the warnings are caused by the following errors, they can be disregarded by users,\n as these errors occur due to the non-deterministic nature of the validation. However,\n it is important to be aware that the operators have not been validated.\n\n - IndexError: Unsupported input arguments of randomized dimensions/indices(INT64).\n - RuntimeError: Unsupported input arguments for torch ops are generated.\n - ValueError: Arguments/keyword arguments do not match the signature of the symbolic function.\n\n2. Potentially wrong torchlib operators:\n If the warnings are triggered by the following error, users should be aware that the symbolic functions\n may be incorrect in dispatching or implementation. In such cases, it is recommended to report\n the issue to the PyTorch-ONNX team, or create/register a custom symbolic function to replace the default one.\n\n - AssertionError: The symbolic function is potentially wrong as the results do not match the results of torch ops.\n - TypeError: The symbolic function is potentially wrong as the opschema doesn't match inputs.\n",
|
544 |
+
},
|
545 |
+
"message_strings": {
|
546 |
+
"default": {
|
547 |
+
"text": "FX node: {node} and its onnx function: {symbolic_fn} fails on op level validation."
|
548 |
+
}
|
549 |
+
},
|
550 |
+
"help_uri": None,
|
551 |
+
"properties": {"deprecated": False, "tags": []},
|
552 |
+
}
|
553 |
+
),
|
554 |
+
init=False,
|
555 |
+
)
|
556 |
+
"""Report any op level validation failure in warnings."""
|
557 |
+
|
558 |
+
find_opschema_matched_symbolic_function: _FindOpschemaMatchedSymbolicFunction = dataclasses.field(
|
559 |
+
default=_FindOpschemaMatchedSymbolicFunction.from_sarif(
|
560 |
+
**{
|
561 |
+
"id": "FXE0014",
|
562 |
+
"name": "find-opschema-matched-symbolic-function",
|
563 |
+
"short_description": {
|
564 |
+
"text": "Find the OnnxFunction that matches the input/attribute dtypes by comparing them with their opschemas."
|
565 |
+
},
|
566 |
+
"full_description": {
|
567 |
+
"text": "Find the OnnxFunction that matches the input dtypes by comparing them with their opschemas. A warning will be issued if the matched OnnxFunction is not an exact match.",
|
568 |
+
"markdown": "When an ATen/Custom operator is registered and needs to be dispatched to an OnnxFunction, the input/attribute\ndtypes of the ATen/Custom operator are compared with the input/attribute dtypes of the OnnxFunction opschemas\nto find a match. However, if a perfect/exact match is not found, the dispatcher will attempt to find\nthe nearest match with the highest number of input/attribute dtypes matching the OnnxFunction opschemas, while\nissuing a warning.\n\nThere are two types of level that can be triggered in this rule:\n\n1. NOTE: A perfect match is found, and no warning is issued.\n2. WARNING: The matched OnnxFunction is not a perfect/exact match.\n\nHere are some suggestions based on the WARNING situation:\n\n1. If there are NO errors or mismatches in the results, it is safe to disregard this warning,\n as the definition of OnnxFunction schema is usually more stringent.\n2. If there are errors or mismatches in the results, it is recommended to:\n (a) Enable op_level_debugging to determine if the OnnxFunction might be incorrect.\n (b) Report the issue to the PyTorch-ONNX team.\n (c) Create/register a custom symbolic function to replace the default one.\n",
|
569 |
+
},
|
570 |
+
"message_strings": {
|
571 |
+
"default": {
|
572 |
+
"text": "The OnnxFunction: {symbolic_fn} is the nearest match of the node {node}."
|
573 |
+
}
|
574 |
+
},
|
575 |
+
"help_uri": None,
|
576 |
+
"properties": {"deprecated": False, "tags": []},
|
577 |
+
}
|
578 |
+
),
|
579 |
+
init=False,
|
580 |
+
)
|
581 |
+
"""Find the OnnxFunction that matches the input/attribute dtypes by comparing them with their opschemas."""
|
582 |
+
|
583 |
+
fx_node_insert_type_promotion: _FxNodeInsertTypePromotion = dataclasses.field(
|
584 |
+
default=_FxNodeInsertTypePromotion.from_sarif(
|
585 |
+
**{
|
586 |
+
"id": "FXE0015",
|
587 |
+
"name": "fx-node-insert-type-promotion",
|
588 |
+
"short_description": {
|
589 |
+
"text": "Determine if type promotion is required for the FX node. Insert cast nodes if needed."
|
590 |
+
},
|
591 |
+
"full_description": {
|
592 |
+
"text": "Determine if type promotion is required for the FX node. Insert cast nodes if needed.",
|
593 |
+
"markdown": "This diagnostic monitors the node-level type promotion insertion process. In PyTorch, there is an automatic process called implicit type promotion,\nwhere the input types of an operator are promoted to a common type. The determination of the common type is based on the type promotion rule specific to each operator.\nTo learn more about PyTorch's type promotion rules, refer to the [elementwise_dtypes doc](https://github.com/pytorch/pytorch/blob/f044613f78df713fb57f70c608483c9f10ad332e/torch/_prims_common/__init__.py#L1252-L1335)\nand [torch._refs ops](https://github.com/pytorch/pytorch/blob/a475ea4542dfe961c9d097e33ab5041f61c8c17f/torch/_refs/__init__.py#L484).\n\nHowever, implicit type promotion is not supported in ONNX. Therefore, to replicate the PyTorch behavior, we need to explicitly insert cast nodes.\nThis diagnostic tracks the process of node-level type promotion insertion.\n\nThe type promotion rules used by this process can be found in `torch/onnx/_internal/fx/passes/type_promotion.py.`\nTo update or add new type promotion rules, please refer to the [Note: Update type promotion rule] section.\n",
|
594 |
+
},
|
595 |
+
"message_strings": {
|
596 |
+
"default": {
|
597 |
+
"text": "Performing explicit type promotion for node {target}. "
|
598 |
+
}
|
599 |
+
},
|
600 |
+
"help_uri": None,
|
601 |
+
"properties": {"deprecated": False, "tags": []},
|
602 |
+
}
|
603 |
+
),
|
604 |
+
init=False,
|
605 |
+
)
|
606 |
+
"""Determine if type promotion is required for the FX node. Insert cast nodes if needed."""
|
607 |
+
|
608 |
+
find_operator_overloads_in_onnx_registry: _FindOperatorOverloadsInOnnxRegistry = dataclasses.field(
|
609 |
+
default=_FindOperatorOverloadsInOnnxRegistry.from_sarif(
|
610 |
+
**{
|
611 |
+
"id": "FXE0016",
|
612 |
+
"name": "find-operator-overloads-in-onnx-registry",
|
613 |
+
"short_description": {
|
614 |
+
"text": "Find the list of OnnxFunction of the PyTorch operator in onnx registry."
|
615 |
+
},
|
616 |
+
"full_description": {
|
617 |
+
"text": "This rule involves finding the list of OnnxFunction for the PyTorch operator overload in the ONNX registry. If the operator overload is not supported but its default overload is, a warning will be issued. If both the operator overload and its default overload are not supported, an error will be issued.",
|
618 |
+
"markdown": "The operator overload name serves the purpose of verifying whether a PyTorch operator is registered in the ONNX registry.\nIf it's not found, the dispatcher takes a fallback approach and tries to locate the default overload of the PyTorch\noperator in the registry. If even the default overload is absent, it signifies that the operator is officially unsupported.\n\nThere are three types of level that can be triggered in this rule:\n\n1. NOTE: The op overload is supported.\n2. WARNING: The op overload is not supported, but it's default overload is supported.\n3. ERROR: The op overload is not supported, and it's default overload is also not supported.\n\nHere are some suggestions based on the WARNING situation:\n\n1. If there are NO errors or mismatches in the results, it is safe to disregard this warning.\n2. If there are errors or mismatches in the results, it is recommended to:\n (a) Enable op_level_debugging to determine if the OnnxFunction might be incorrect.\n (b) Report the unsupported overload to the PyTorch-ONNX team.\n (c) Create/register a custom symbolic function to replace the default one.\n\nHere are some suggestions based on the ERROR situation:\n\n1. Report the unsupported operator to the PyTorch-ONNX team.\n2. Create/register a custom symbolic function to replace the default one.\n",
|
619 |
+
},
|
620 |
+
"message_strings": {
|
621 |
+
"default": {
|
622 |
+
"text": "Checking if the FX node: {node} is supported in onnx registry."
|
623 |
+
}
|
624 |
+
},
|
625 |
+
"help_uri": None,
|
626 |
+
"properties": {"deprecated": False, "tags": []},
|
627 |
+
}
|
628 |
+
),
|
629 |
+
init=False,
|
630 |
+
)
|
631 |
+
"""Find the list of OnnxFunction of the PyTorch operator in onnx registry."""
|
632 |
+
|
633 |
+
|
634 |
+
rules = _POERules()
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/__init__.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ._infra import (
|
2 |
+
DiagnosticOptions,
|
3 |
+
Graph,
|
4 |
+
Invocation,
|
5 |
+
Level,
|
6 |
+
levels,
|
7 |
+
Location,
|
8 |
+
Rule,
|
9 |
+
RuleCollection,
|
10 |
+
Stack,
|
11 |
+
StackFrame,
|
12 |
+
Tag,
|
13 |
+
ThreadFlowLocation,
|
14 |
+
)
|
15 |
+
from .context import Diagnostic, DiagnosticContext, RuntimeErrorWithDiagnostic
|
16 |
+
|
17 |
+
__all__ = [
|
18 |
+
"Diagnostic",
|
19 |
+
"DiagnosticContext",
|
20 |
+
"DiagnosticOptions",
|
21 |
+
"Graph",
|
22 |
+
"Invocation",
|
23 |
+
"Level",
|
24 |
+
"levels",
|
25 |
+
"Location",
|
26 |
+
"Rule",
|
27 |
+
"RuleCollection",
|
28 |
+
"RuntimeErrorWithDiagnostic",
|
29 |
+
"Stack",
|
30 |
+
"StackFrame",
|
31 |
+
"Tag",
|
32 |
+
"ThreadFlowLocation",
|
33 |
+
]
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/_infra.py
ADDED
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""This file defines an additional layer of abstraction on top of the SARIF OM."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
import dataclasses
|
6 |
+
import enum
|
7 |
+
import logging
|
8 |
+
from typing import FrozenSet, List, Mapping, Optional, Sequence, Tuple
|
9 |
+
|
10 |
+
from torch.onnx._internal.diagnostics.infra import formatter, sarif
|
11 |
+
|
12 |
+
|
13 |
+
class Level(enum.IntEnum):
|
14 |
+
"""The level of a diagnostic.
|
15 |
+
|
16 |
+
This class is used to represent the level of a diagnostic. The levels are defined
|
17 |
+
by the SARIF specification, and are not modifiable. For alternative categories,
|
18 |
+
please use infra.Tag instead. When selecting a level, please consider the following
|
19 |
+
guidelines:
|
20 |
+
|
21 |
+
- NONE: Informational result that does not indicate the presence of a problem.
|
22 |
+
- NOTE: An opportunity for improvement was found.
|
23 |
+
- WARNING: A potential problem was found.
|
24 |
+
- ERROR: A serious problem was found.
|
25 |
+
|
26 |
+
This level is a subclass of enum.IntEnum, and can be used as an integer. Its integer
|
27 |
+
value maps to the logging levels in Python's logging module. The mapping is as
|
28 |
+
follows:
|
29 |
+
|
30 |
+
Level.NONE = logging.DEBUG = 10
|
31 |
+
Level.NOTE = logging.INFO = 20
|
32 |
+
Level.WARNING = logging.WARNING = 30
|
33 |
+
Level.ERROR = logging.ERROR = 40
|
34 |
+
"""
|
35 |
+
|
36 |
+
NONE = 10
|
37 |
+
NOTE = 20
|
38 |
+
WARNING = 30
|
39 |
+
ERROR = 40
|
40 |
+
|
41 |
+
|
42 |
+
levels = Level
|
43 |
+
|
44 |
+
|
45 |
+
class Tag(enum.Enum):
|
46 |
+
"""The tag of a diagnostic. This class can be inherited to define custom tags."""
|
47 |
+
|
48 |
+
|
49 |
+
class PatchedPropertyBag(sarif.PropertyBag):
|
50 |
+
"""Key/value pairs that provide additional information about the object.
|
51 |
+
|
52 |
+
The definition of PropertyBag via SARIF spec is "A property bag is an object (§3.6)
|
53 |
+
containing an unordered set of properties with arbitrary names." However it is not
|
54 |
+
reflected in the json file, and therefore not captured by the python representation.
|
55 |
+
This patch adds additional **kwargs to the `__init__` method to allow recording
|
56 |
+
arbitrary key/value pairs.
|
57 |
+
"""
|
58 |
+
|
59 |
+
def __init__(self, tags: Optional[List[str]] = None, **kwargs):
|
60 |
+
super().__init__(tags=tags)
|
61 |
+
self.__dict__.update(kwargs)
|
62 |
+
|
63 |
+
|
64 |
+
@dataclasses.dataclass(frozen=True)
|
65 |
+
class Rule:
|
66 |
+
id: str
|
67 |
+
name: str
|
68 |
+
message_default_template: str
|
69 |
+
short_description: Optional[str] = None
|
70 |
+
full_description: Optional[str] = None
|
71 |
+
full_description_markdown: Optional[str] = None
|
72 |
+
help_uri: Optional[str] = None
|
73 |
+
|
74 |
+
@classmethod
|
75 |
+
def from_sarif(cls, **kwargs):
|
76 |
+
"""Returns a rule from the SARIF reporting descriptor."""
|
77 |
+
short_description = kwargs.get("short_description", {}).get("text")
|
78 |
+
full_description = kwargs.get("full_description", {}).get("text")
|
79 |
+
full_description_markdown = kwargs.get("full_description", {}).get("markdown")
|
80 |
+
help_uri = kwargs.get("help_uri")
|
81 |
+
|
82 |
+
rule = cls(
|
83 |
+
id=kwargs["id"],
|
84 |
+
name=kwargs["name"],
|
85 |
+
message_default_template=kwargs["message_strings"]["default"]["text"],
|
86 |
+
short_description=short_description,
|
87 |
+
full_description=full_description,
|
88 |
+
full_description_markdown=full_description_markdown,
|
89 |
+
help_uri=help_uri,
|
90 |
+
)
|
91 |
+
return rule
|
92 |
+
|
93 |
+
def sarif(self) -> sarif.ReportingDescriptor:
|
94 |
+
"""Returns a SARIF reporting descriptor of this Rule."""
|
95 |
+
short_description = (
|
96 |
+
sarif.MultiformatMessageString(text=self.short_description)
|
97 |
+
if self.short_description is not None
|
98 |
+
else None
|
99 |
+
)
|
100 |
+
full_description = (
|
101 |
+
sarif.MultiformatMessageString(
|
102 |
+
text=self.full_description, markdown=self.full_description_markdown
|
103 |
+
)
|
104 |
+
if self.full_description is not None
|
105 |
+
else None
|
106 |
+
)
|
107 |
+
return sarif.ReportingDescriptor(
|
108 |
+
id=self.id,
|
109 |
+
name=self.name,
|
110 |
+
short_description=short_description,
|
111 |
+
full_description=full_description,
|
112 |
+
help_uri=self.help_uri,
|
113 |
+
)
|
114 |
+
|
115 |
+
def format(self, level: Level, *args, **kwargs) -> Tuple[Rule, Level, str]:
|
116 |
+
"""Returns a tuple of (rule, level, message) for a diagnostic.
|
117 |
+
|
118 |
+
This method is used to format the message of a diagnostic. The message is
|
119 |
+
formatted using the default template of this rule, and the arguments passed in
|
120 |
+
as `*args` and `**kwargs`. The level is used to override the default level of
|
121 |
+
this rule.
|
122 |
+
"""
|
123 |
+
return (self, level, self.format_message(*args, **kwargs))
|
124 |
+
|
125 |
+
def format_message(self, *args, **kwargs) -> str:
|
126 |
+
"""Returns the formatted default message of this Rule.
|
127 |
+
|
128 |
+
This method should be overridden (with code generation) by subclasses to reflect
|
129 |
+
the exact arguments needed by the message template. This is a helper method to
|
130 |
+
create the default message for a diagnostic.
|
131 |
+
"""
|
132 |
+
return self.message_default_template.format(*args, **kwargs)
|
133 |
+
|
134 |
+
|
135 |
+
@dataclasses.dataclass
|
136 |
+
class Location:
|
137 |
+
uri: Optional[str] = None
|
138 |
+
line: Optional[int] = None
|
139 |
+
message: Optional[str] = None
|
140 |
+
start_column: Optional[int] = None
|
141 |
+
end_column: Optional[int] = None
|
142 |
+
snippet: Optional[str] = None
|
143 |
+
function: Optional[str] = None
|
144 |
+
|
145 |
+
def sarif(self) -> sarif.Location:
|
146 |
+
"""Returns the SARIF representation of this location."""
|
147 |
+
return sarif.Location(
|
148 |
+
physical_location=sarif.PhysicalLocation(
|
149 |
+
artifact_location=sarif.ArtifactLocation(uri=self.uri),
|
150 |
+
region=sarif.Region(
|
151 |
+
start_line=self.line,
|
152 |
+
start_column=self.start_column,
|
153 |
+
end_column=self.end_column,
|
154 |
+
snippet=sarif.ArtifactContent(text=self.snippet),
|
155 |
+
),
|
156 |
+
),
|
157 |
+
message=sarif.Message(text=self.message)
|
158 |
+
if self.message is not None
|
159 |
+
else None,
|
160 |
+
)
|
161 |
+
|
162 |
+
|
163 |
+
@dataclasses.dataclass
|
164 |
+
class StackFrame:
|
165 |
+
location: Location
|
166 |
+
|
167 |
+
def sarif(self) -> sarif.StackFrame:
|
168 |
+
"""Returns the SARIF representation of this stack frame."""
|
169 |
+
return sarif.StackFrame(location=self.location.sarif())
|
170 |
+
|
171 |
+
|
172 |
+
@dataclasses.dataclass
|
173 |
+
class Stack:
|
174 |
+
"""Records a stack trace. The frames are in order from newest to oldest stack frame."""
|
175 |
+
|
176 |
+
frames: List[StackFrame] = dataclasses.field(default_factory=list)
|
177 |
+
message: Optional[str] = None
|
178 |
+
|
179 |
+
def sarif(self) -> sarif.Stack:
|
180 |
+
"""Returns the SARIF representation of this stack."""
|
181 |
+
return sarif.Stack(
|
182 |
+
frames=[frame.sarif() for frame in self.frames],
|
183 |
+
message=sarif.Message(text=self.message)
|
184 |
+
if self.message is not None
|
185 |
+
else None,
|
186 |
+
)
|
187 |
+
|
188 |
+
|
189 |
+
@dataclasses.dataclass
|
190 |
+
class ThreadFlowLocation:
|
191 |
+
"""Records code location and the initial state."""
|
192 |
+
|
193 |
+
location: Location
|
194 |
+
state: Mapping[str, str]
|
195 |
+
index: int
|
196 |
+
stack: Optional[Stack] = None
|
197 |
+
|
198 |
+
def sarif(self) -> sarif.ThreadFlowLocation:
|
199 |
+
"""Returns the SARIF representation of this thread flow location."""
|
200 |
+
return sarif.ThreadFlowLocation(
|
201 |
+
location=self.location.sarif(),
|
202 |
+
state=self.state,
|
203 |
+
stack=self.stack.sarif() if self.stack is not None else None,
|
204 |
+
)
|
205 |
+
|
206 |
+
|
207 |
+
@dataclasses.dataclass
|
208 |
+
class Graph:
|
209 |
+
"""A graph of diagnostics.
|
210 |
+
|
211 |
+
This class stores the string representation of a model graph.
|
212 |
+
The `nodes` and `edges` fields are unused in the current implementation.
|
213 |
+
"""
|
214 |
+
|
215 |
+
graph: str
|
216 |
+
name: str
|
217 |
+
description: Optional[str] = None
|
218 |
+
|
219 |
+
def sarif(self) -> sarif.Graph:
|
220 |
+
"""Returns the SARIF representation of this graph."""
|
221 |
+
return sarif.Graph(
|
222 |
+
description=sarif.Message(text=self.graph),
|
223 |
+
properties=PatchedPropertyBag(name=self.name, description=self.description),
|
224 |
+
)
|
225 |
+
|
226 |
+
|
227 |
+
@dataclasses.dataclass
|
228 |
+
class RuleCollection:
|
229 |
+
_rule_id_name_set: FrozenSet[Tuple[str, str]] = dataclasses.field(init=False)
|
230 |
+
|
231 |
+
def __post_init__(self) -> None:
|
232 |
+
self._rule_id_name_set = frozenset(
|
233 |
+
{
|
234 |
+
(field.default.id, field.default.name)
|
235 |
+
for field in dataclasses.fields(self)
|
236 |
+
if isinstance(field.default, Rule)
|
237 |
+
}
|
238 |
+
)
|
239 |
+
|
240 |
+
def __contains__(self, rule: Rule) -> bool:
|
241 |
+
"""Checks if the rule is in the collection."""
|
242 |
+
return (rule.id, rule.name) in self._rule_id_name_set
|
243 |
+
|
244 |
+
@classmethod
|
245 |
+
def custom_collection_from_list(
|
246 |
+
cls, new_collection_class_name: str, rules: Sequence[Rule]
|
247 |
+
) -> RuleCollection:
|
248 |
+
"""Creates a custom class inherited from RuleCollection with the list of rules."""
|
249 |
+
return dataclasses.make_dataclass(
|
250 |
+
new_collection_class_name,
|
251 |
+
[
|
252 |
+
(
|
253 |
+
formatter.kebab_case_to_snake_case(rule.name),
|
254 |
+
type(rule),
|
255 |
+
dataclasses.field(default=rule),
|
256 |
+
)
|
257 |
+
for rule in rules
|
258 |
+
],
|
259 |
+
bases=(cls,),
|
260 |
+
)()
|
261 |
+
|
262 |
+
|
263 |
+
class Invocation:
|
264 |
+
# TODO: Implement this.
|
265 |
+
# Tracks top level call arguments and diagnostic options.
|
266 |
+
def __init__(self) -> None:
|
267 |
+
raise NotImplementedError()
|
268 |
+
|
269 |
+
|
270 |
+
@dataclasses.dataclass
|
271 |
+
class DiagnosticOptions:
|
272 |
+
"""Options for diagnostic context.
|
273 |
+
|
274 |
+
Attributes:
|
275 |
+
verbosity_level: Set the amount of information logged for each diagnostics,
|
276 |
+
equivalent to the 'level' in Python logging module.
|
277 |
+
warnings_as_errors: When True, warning diagnostics are treated as error diagnostics.
|
278 |
+
"""
|
279 |
+
|
280 |
+
verbosity_level: int = dataclasses.field(default=logging.INFO)
|
281 |
+
"""Set the amount of information logged for each diagnostics, equivalent to the 'level' in Python logging module."""
|
282 |
+
|
283 |
+
warnings_as_errors: bool = dataclasses.field(default=False)
|
284 |
+
"""If True, warning diagnostics are treated as error diagnostics."""
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/context.py
ADDED
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""A diagnostic context based on SARIF."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
import contextlib
|
6 |
+
|
7 |
+
import dataclasses
|
8 |
+
import gzip
|
9 |
+
|
10 |
+
import logging
|
11 |
+
|
12 |
+
from typing import (
|
13 |
+
Callable,
|
14 |
+
Generator,
|
15 |
+
Generic,
|
16 |
+
List,
|
17 |
+
Literal,
|
18 |
+
Mapping,
|
19 |
+
Optional,
|
20 |
+
Type,
|
21 |
+
TypeVar,
|
22 |
+
)
|
23 |
+
|
24 |
+
from torch.onnx._internal.diagnostics import infra
|
25 |
+
from torch.onnx._internal.diagnostics.infra import formatter, sarif, utils
|
26 |
+
from torch.onnx._internal.diagnostics.infra.sarif import version as sarif_version
|
27 |
+
|
28 |
+
|
29 |
+
# This is a workaround for mypy not supporting Self from typing_extensions.
|
30 |
+
_Diagnostic = TypeVar("_Diagnostic", bound="Diagnostic")
|
31 |
+
diagnostic_logger: logging.Logger = logging.getLogger(__name__)
|
32 |
+
|
33 |
+
|
34 |
+
@dataclasses.dataclass
|
35 |
+
class Diagnostic:
|
36 |
+
rule: infra.Rule
|
37 |
+
level: infra.Level
|
38 |
+
message: Optional[str] = None
|
39 |
+
locations: List[infra.Location] = dataclasses.field(default_factory=list)
|
40 |
+
stacks: List[infra.Stack] = dataclasses.field(default_factory=list)
|
41 |
+
graphs: List[infra.Graph] = dataclasses.field(default_factory=list)
|
42 |
+
thread_flow_locations: List[infra.ThreadFlowLocation] = dataclasses.field(
|
43 |
+
default_factory=list
|
44 |
+
)
|
45 |
+
additional_messages: List[str] = dataclasses.field(default_factory=list)
|
46 |
+
tags: List[infra.Tag] = dataclasses.field(default_factory=list)
|
47 |
+
source_exception: Optional[Exception] = None
|
48 |
+
"""The exception that caused this diagnostic to be created."""
|
49 |
+
logger: logging.Logger = dataclasses.field(init=False, default=diagnostic_logger)
|
50 |
+
"""The logger for this diagnostic. Defaults to 'diagnostic_logger' which has the same
|
51 |
+
log level setting with `DiagnosticOptions.verbosity_level`."""
|
52 |
+
_current_log_section_depth: int = 0
|
53 |
+
|
54 |
+
def __post_init__(self) -> None:
|
55 |
+
pass
|
56 |
+
|
57 |
+
def sarif(self) -> sarif.Result:
|
58 |
+
"""Returns the SARIF Result representation of this diagnostic."""
|
59 |
+
message = self.message or self.rule.message_default_template
|
60 |
+
if self.additional_messages:
|
61 |
+
additional_message = "\n".join(self.additional_messages)
|
62 |
+
message_markdown = (
|
63 |
+
f"{message}\n\n## Additional Message:\n\n{additional_message}"
|
64 |
+
)
|
65 |
+
else:
|
66 |
+
message_markdown = message
|
67 |
+
|
68 |
+
kind: Literal["informational", "fail"] = (
|
69 |
+
"informational" if self.level == infra.Level.NONE else "fail"
|
70 |
+
)
|
71 |
+
|
72 |
+
sarif_result = sarif.Result(
|
73 |
+
message=sarif.Message(text=message, markdown=message_markdown),
|
74 |
+
level=self.level.name.lower(), # type: ignore[arg-type]
|
75 |
+
rule_id=self.rule.id,
|
76 |
+
kind=kind,
|
77 |
+
)
|
78 |
+
sarif_result.locations = [location.sarif() for location in self.locations]
|
79 |
+
sarif_result.stacks = [stack.sarif() for stack in self.stacks]
|
80 |
+
sarif_result.graphs = [graph.sarif() for graph in self.graphs]
|
81 |
+
sarif_result.code_flows = [
|
82 |
+
sarif.CodeFlow(
|
83 |
+
thread_flows=[
|
84 |
+
sarif.ThreadFlow(
|
85 |
+
locations=[loc.sarif() for loc in self.thread_flow_locations]
|
86 |
+
)
|
87 |
+
]
|
88 |
+
)
|
89 |
+
]
|
90 |
+
sarif_result.properties = sarif.PropertyBag(
|
91 |
+
tags=[tag.value for tag in self.tags]
|
92 |
+
)
|
93 |
+
return sarif_result
|
94 |
+
|
95 |
+
def with_location(self: _Diagnostic, location: infra.Location) -> _Diagnostic:
|
96 |
+
"""Adds a location to the diagnostic."""
|
97 |
+
self.locations.append(location)
|
98 |
+
return self
|
99 |
+
|
100 |
+
def with_thread_flow_location(
|
101 |
+
self: _Diagnostic, location: infra.ThreadFlowLocation
|
102 |
+
) -> _Diagnostic:
|
103 |
+
"""Adds a thread flow location to the diagnostic."""
|
104 |
+
self.thread_flow_locations.append(location)
|
105 |
+
return self
|
106 |
+
|
107 |
+
def with_stack(self: _Diagnostic, stack: infra.Stack) -> _Diagnostic:
|
108 |
+
"""Adds a stack to the diagnostic."""
|
109 |
+
self.stacks.append(stack)
|
110 |
+
return self
|
111 |
+
|
112 |
+
def with_graph(self: _Diagnostic, graph: infra.Graph) -> _Diagnostic:
|
113 |
+
"""Adds a graph to the diagnostic."""
|
114 |
+
self.graphs.append(graph)
|
115 |
+
return self
|
116 |
+
|
117 |
+
@contextlib.contextmanager
|
118 |
+
def log_section(
|
119 |
+
self, level: int, message: str, *args, **kwargs
|
120 |
+
) -> Generator[None, None, None]:
|
121 |
+
"""
|
122 |
+
Context manager for a section of log messages, denoted by a title message and increased indentation.
|
123 |
+
|
124 |
+
Same api as `logging.Logger.log`.
|
125 |
+
|
126 |
+
This context manager logs the given title at the specified log level, increases the current
|
127 |
+
section depth for subsequent log messages, and ensures that the section depth is decreased
|
128 |
+
again when exiting the context.
|
129 |
+
|
130 |
+
Args:
|
131 |
+
level: The log level.
|
132 |
+
message: The title message to log.
|
133 |
+
*args: The arguments to the message. Use `LazyString` to defer the
|
134 |
+
expensive evaluation of the arguments until the message is actually logged.
|
135 |
+
**kwargs: The keyword arguments for `logging.Logger.log`.
|
136 |
+
|
137 |
+
Yields:
|
138 |
+
None: This context manager does not yield any value.
|
139 |
+
|
140 |
+
Example:
|
141 |
+
>>> with DiagnosticContext("DummyContext", "1.0"):
|
142 |
+
... rule = infra.Rule("RuleID", "DummyRule", "Rule message")
|
143 |
+
... diagnostic = Diagnostic(rule, infra.Level.WARNING)
|
144 |
+
... with diagnostic.log_section(logging.INFO, "My Section"):
|
145 |
+
... diagnostic.log(logging.INFO, "My Message")
|
146 |
+
... with diagnostic.log_section(logging.INFO, "My Subsection"):
|
147 |
+
... diagnostic.log(logging.INFO, "My Submessage")
|
148 |
+
... diagnostic.additional_messages
|
149 |
+
['## My Section', 'My Message', '### My Subsection', 'My Submessage']
|
150 |
+
"""
|
151 |
+
if self.logger.isEnabledFor(level):
|
152 |
+
indented_format_message = (
|
153 |
+
f"##{'#' * self._current_log_section_depth } {message}"
|
154 |
+
)
|
155 |
+
self.log(
|
156 |
+
level,
|
157 |
+
indented_format_message,
|
158 |
+
*args,
|
159 |
+
**kwargs,
|
160 |
+
)
|
161 |
+
self._current_log_section_depth += 1
|
162 |
+
try:
|
163 |
+
yield
|
164 |
+
finally:
|
165 |
+
self._current_log_section_depth -= 1
|
166 |
+
|
167 |
+
def log(self, level: int, message: str, *args, **kwargs) -> None:
|
168 |
+
"""Logs a message within the diagnostic. Same api as `logging.Logger.log`.
|
169 |
+
|
170 |
+
If logger is not enabled for the given level, the message will not be logged.
|
171 |
+
Otherwise, the message will be logged and also added to the diagnostic's additional_messages.
|
172 |
+
|
173 |
+
The default setting for `DiagnosticOptions.verbosity_level` is `logging.INFO`. Based on this default,
|
174 |
+
the log level recommendations are as follows. If you've set a different default verbosity level in your
|
175 |
+
application, please adjust accordingly:
|
176 |
+
|
177 |
+
- logging.ERROR: Log any events leading to application failure.
|
178 |
+
- logging.WARNING: Log events that might result in application issues or failures, although not guaranteed.
|
179 |
+
- logging.INFO: Log general useful information, ensuring minimal performance overhead.
|
180 |
+
- logging.DEBUG: Log detailed debug information, which might affect performance when logged.
|
181 |
+
|
182 |
+
Args:
|
183 |
+
level: The log level.
|
184 |
+
message: The message to log.
|
185 |
+
*args: The arguments to the message. Use `LazyString` to defer the
|
186 |
+
expensive evaluation of the arguments until the message is actually logged.
|
187 |
+
**kwargs: The keyword arguments for `logging.Logger.log`.
|
188 |
+
"""
|
189 |
+
if self.logger.isEnabledFor(level):
|
190 |
+
formatted_message = message % args
|
191 |
+
self.logger.log(level, formatted_message, **kwargs)
|
192 |
+
self.additional_messages.append(formatted_message)
|
193 |
+
|
194 |
+
def debug(self, message: str, *args, **kwargs) -> None:
|
195 |
+
"""Logs a debug message within the diagnostic. Same api as logging.Logger.debug.
|
196 |
+
|
197 |
+
Checkout `log` for more details.
|
198 |
+
"""
|
199 |
+
self.log(logging.DEBUG, message, *args, **kwargs)
|
200 |
+
|
201 |
+
def info(self, message: str, *args, **kwargs) -> None:
|
202 |
+
"""Logs an info message within the diagnostic. Same api as logging.Logger.info.
|
203 |
+
|
204 |
+
Checkout `log` for more details.
|
205 |
+
"""
|
206 |
+
self.log(logging.INFO, message, *args, **kwargs)
|
207 |
+
|
208 |
+
def warning(self, message: str, *args, **kwargs) -> None:
|
209 |
+
"""Logs a warning message within the diagnostic. Same api as logging.Logger.warning.
|
210 |
+
|
211 |
+
Checkout `log` for more details.
|
212 |
+
"""
|
213 |
+
self.log(logging.WARNING, message, *args, **kwargs)
|
214 |
+
|
215 |
+
def error(self, message: str, *args, **kwargs) -> None:
|
216 |
+
"""Logs an error message within the diagnostic. Same api as logging.Logger.error.
|
217 |
+
|
218 |
+
Checkout `log` for more details.
|
219 |
+
"""
|
220 |
+
self.log(logging.ERROR, message, *args, **kwargs)
|
221 |
+
|
222 |
+
def log_source_exception(self, level: int, exception: Exception) -> None:
|
223 |
+
"""Logs a source exception within the diagnostic.
|
224 |
+
|
225 |
+
Invokes `log_section` and `log` to log the exception in markdown section format.
|
226 |
+
"""
|
227 |
+
self.source_exception = exception
|
228 |
+
with self.log_section(level, "Exception log"):
|
229 |
+
self.log(level, "%s", formatter.lazy_format_exception(exception))
|
230 |
+
|
231 |
+
def record_python_call_stack(self, frames_to_skip: int) -> infra.Stack:
|
232 |
+
"""Records the current Python call stack."""
|
233 |
+
frames_to_skip += 1 # Skip this function.
|
234 |
+
stack = utils.python_call_stack(frames_to_skip=frames_to_skip)
|
235 |
+
self.with_stack(stack)
|
236 |
+
if len(stack.frames) > 0:
|
237 |
+
self.with_location(stack.frames[0].location)
|
238 |
+
return stack
|
239 |
+
|
240 |
+
def record_python_call(
|
241 |
+
self,
|
242 |
+
fn: Callable,
|
243 |
+
state: Mapping[str, str],
|
244 |
+
message: Optional[str] = None,
|
245 |
+
frames_to_skip: int = 0,
|
246 |
+
) -> infra.ThreadFlowLocation:
|
247 |
+
"""Records a python call as one thread flow step."""
|
248 |
+
frames_to_skip += 1 # Skip this function.
|
249 |
+
stack = utils.python_call_stack(frames_to_skip=frames_to_skip, frames_to_log=5)
|
250 |
+
location = utils.function_location(fn)
|
251 |
+
location.message = message
|
252 |
+
# Add function location to the top of the stack.
|
253 |
+
stack.frames.insert(0, infra.StackFrame(location=location))
|
254 |
+
thread_flow_location = infra.ThreadFlowLocation(
|
255 |
+
location=location,
|
256 |
+
state=state,
|
257 |
+
index=len(self.thread_flow_locations),
|
258 |
+
stack=stack,
|
259 |
+
)
|
260 |
+
self.with_thread_flow_location(thread_flow_location)
|
261 |
+
return thread_flow_location
|
262 |
+
|
263 |
+
|
264 |
+
class RuntimeErrorWithDiagnostic(RuntimeError):
|
265 |
+
"""Runtime error with enclosed diagnostic information."""
|
266 |
+
|
267 |
+
def __init__(self, diagnostic: Diagnostic):
|
268 |
+
super().__init__(diagnostic.message)
|
269 |
+
self.diagnostic = diagnostic
|
270 |
+
|
271 |
+
|
272 |
+
@dataclasses.dataclass
|
273 |
+
class DiagnosticContext(Generic[_Diagnostic]):
|
274 |
+
name: str
|
275 |
+
version: str
|
276 |
+
options: infra.DiagnosticOptions = dataclasses.field(
|
277 |
+
default_factory=infra.DiagnosticOptions
|
278 |
+
)
|
279 |
+
diagnostics: List[_Diagnostic] = dataclasses.field(init=False, default_factory=list)
|
280 |
+
# TODO(bowbao): Implement this.
|
281 |
+
# _invocation: infra.Invocation = dataclasses.field(init=False)
|
282 |
+
_inflight_diagnostics: List[_Diagnostic] = dataclasses.field(
|
283 |
+
init=False, default_factory=list
|
284 |
+
)
|
285 |
+
_previous_log_level: int = dataclasses.field(init=False, default=logging.WARNING)
|
286 |
+
logger: logging.Logger = dataclasses.field(init=False, default=diagnostic_logger)
|
287 |
+
_bound_diagnostic_type: Type = dataclasses.field(init=False, default=Diagnostic)
|
288 |
+
|
289 |
+
def __enter__(self):
|
290 |
+
self._previous_log_level = self.logger.level
|
291 |
+
self.logger.setLevel(self.options.verbosity_level)
|
292 |
+
return self
|
293 |
+
|
294 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
295 |
+
self.logger.setLevel(self._previous_log_level)
|
296 |
+
return None
|
297 |
+
|
298 |
+
def sarif(self) -> sarif.Run:
|
299 |
+
"""Returns the SARIF Run object."""
|
300 |
+
unique_rules = {diagnostic.rule for diagnostic in self.diagnostics}
|
301 |
+
return sarif.Run(
|
302 |
+
sarif.Tool(
|
303 |
+
driver=sarif.ToolComponent(
|
304 |
+
name=self.name,
|
305 |
+
version=self.version,
|
306 |
+
rules=[rule.sarif() for rule in unique_rules],
|
307 |
+
)
|
308 |
+
),
|
309 |
+
results=[diagnostic.sarif() for diagnostic in self.diagnostics],
|
310 |
+
)
|
311 |
+
|
312 |
+
def sarif_log(self) -> sarif.SarifLog: # type: ignore[name-defined]
|
313 |
+
"""Returns the SARIF Log object."""
|
314 |
+
return sarif.SarifLog(
|
315 |
+
version=sarif_version.SARIF_VERSION,
|
316 |
+
schema_uri=sarif_version.SARIF_SCHEMA_LINK,
|
317 |
+
runs=[self.sarif()],
|
318 |
+
)
|
319 |
+
|
320 |
+
def to_json(self) -> str:
|
321 |
+
return formatter.sarif_to_json(self.sarif_log())
|
322 |
+
|
323 |
+
def dump(self, file_path: str, compress: bool = False) -> None:
|
324 |
+
"""Dumps the SARIF log to a file."""
|
325 |
+
if compress:
|
326 |
+
with gzip.open(file_path, "wt") as f:
|
327 |
+
f.write(self.to_json())
|
328 |
+
else:
|
329 |
+
with open(file_path, "w") as f:
|
330 |
+
f.write(self.to_json())
|
331 |
+
|
332 |
+
def log(self, diagnostic: _Diagnostic) -> None:
|
333 |
+
"""Logs a diagnostic.
|
334 |
+
|
335 |
+
This method should be used only after all the necessary information for the diagnostic
|
336 |
+
has been collected.
|
337 |
+
|
338 |
+
Args:
|
339 |
+
diagnostic: The diagnostic to add.
|
340 |
+
"""
|
341 |
+
if not isinstance(diagnostic, self._bound_diagnostic_type):
|
342 |
+
raise TypeError(
|
343 |
+
f"Expected diagnostic of type {self._bound_diagnostic_type}, got {type(diagnostic)}"
|
344 |
+
)
|
345 |
+
if self.options.warnings_as_errors and diagnostic.level == infra.Level.WARNING:
|
346 |
+
diagnostic.level = infra.Level.ERROR
|
347 |
+
self.diagnostics.append(diagnostic)
|
348 |
+
|
349 |
+
def log_and_raise_if_error(self, diagnostic: _Diagnostic) -> None:
|
350 |
+
"""Logs a diagnostic and raises an exception if it is an error.
|
351 |
+
|
352 |
+
Use this method for logging non inflight diagnostics where diagnostic level is not known or
|
353 |
+
lower than ERROR. If it is always expected raise, use `log` and explicit
|
354 |
+
`raise` instead. Otherwise there is no way to convey the message that it always
|
355 |
+
raises to Python intellisense and type checking tools.
|
356 |
+
|
357 |
+
This method should be used only after all the necessary information for the diagnostic
|
358 |
+
has been collected.
|
359 |
+
|
360 |
+
Args:
|
361 |
+
diagnostic: The diagnostic to add.
|
362 |
+
"""
|
363 |
+
self.log(diagnostic)
|
364 |
+
if diagnostic.level == infra.Level.ERROR:
|
365 |
+
if diagnostic.source_exception is not None:
|
366 |
+
raise diagnostic.source_exception
|
367 |
+
raise RuntimeErrorWithDiagnostic(diagnostic)
|
368 |
+
|
369 |
+
@contextlib.contextmanager
|
370 |
+
def add_inflight_diagnostic(
|
371 |
+
self, diagnostic: _Diagnostic
|
372 |
+
) -> Generator[_Diagnostic, None, None]:
|
373 |
+
"""Adds a diagnostic to the context.
|
374 |
+
|
375 |
+
Use this method to add diagnostics that are not created by the context.
|
376 |
+
Args:
|
377 |
+
diagnostic: The diagnostic to add.
|
378 |
+
"""
|
379 |
+
self._inflight_diagnostics.append(diagnostic)
|
380 |
+
try:
|
381 |
+
yield diagnostic
|
382 |
+
finally:
|
383 |
+
self._inflight_diagnostics.pop()
|
384 |
+
|
385 |
+
def push_inflight_diagnostic(self, diagnostic: _Diagnostic) -> None:
|
386 |
+
"""Pushes a diagnostic to the inflight diagnostics stack.
|
387 |
+
|
388 |
+
Args:
|
389 |
+
diagnostic: The diagnostic to push.
|
390 |
+
|
391 |
+
Raises:
|
392 |
+
ValueError: If the rule is not supported by the tool.
|
393 |
+
"""
|
394 |
+
self._inflight_diagnostics.append(diagnostic)
|
395 |
+
|
396 |
+
def pop_inflight_diagnostic(self) -> _Diagnostic:
|
397 |
+
"""Pops the last diagnostic from the inflight diagnostics stack.
|
398 |
+
|
399 |
+
Returns:
|
400 |
+
The popped diagnostic.
|
401 |
+
"""
|
402 |
+
return self._inflight_diagnostics.pop()
|
403 |
+
|
404 |
+
def inflight_diagnostic(self, rule: Optional[infra.Rule] = None) -> _Diagnostic:
|
405 |
+
if rule is None:
|
406 |
+
# TODO(bowbao): Create builtin-rules and create diagnostic using that.
|
407 |
+
if len(self._inflight_diagnostics) <= 0:
|
408 |
+
raise AssertionError("No inflight diagnostics")
|
409 |
+
|
410 |
+
return self._inflight_diagnostics[-1]
|
411 |
+
else:
|
412 |
+
for diagnostic in reversed(self._inflight_diagnostics):
|
413 |
+
if diagnostic.rule == rule:
|
414 |
+
return diagnostic
|
415 |
+
raise AssertionError(f"No inflight diagnostic for rule {rule.name}")
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/decorator.py
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
|
3 |
+
import functools
|
4 |
+
import logging
|
5 |
+
import traceback
|
6 |
+
from typing import Any, Callable, Dict, Optional, Tuple, Type
|
7 |
+
|
8 |
+
from torch.onnx._internal import _beartype
|
9 |
+
from torch.onnx._internal.diagnostics import infra
|
10 |
+
from torch.onnx._internal.diagnostics.infra import formatter, utils
|
11 |
+
|
12 |
+
|
13 |
+
MessageFormatterType = Callable[..., str]
|
14 |
+
|
15 |
+
|
16 |
+
@_beartype.beartype
|
17 |
+
def format_message_in_text(fn: Callable, *args: Any, **kwargs: Any) -> str:
|
18 |
+
return f"{formatter.display_name(fn)}. "
|
19 |
+
|
20 |
+
|
21 |
+
@_beartype.beartype
|
22 |
+
def format_exception_in_markdown(exception: Exception) -> str:
|
23 |
+
msg_list = ["### Exception log", "```"]
|
24 |
+
msg_list.extend(
|
25 |
+
traceback.format_exception(type(exception), exception, exception.__traceback__)
|
26 |
+
)
|
27 |
+
msg_list.append("```")
|
28 |
+
return "\n".join(msg_list)
|
29 |
+
|
30 |
+
|
31 |
+
@_beartype.beartype
|
32 |
+
def format_function_signature_in_markdown(
|
33 |
+
fn: Callable,
|
34 |
+
args: Tuple[Any, ...],
|
35 |
+
kwargs: Dict[str, Any],
|
36 |
+
format_argument: Callable[[Any], str] = formatter.format_argument,
|
37 |
+
) -> str:
|
38 |
+
msg_list = [f"### Function Signature {formatter.display_name(fn)}"]
|
39 |
+
|
40 |
+
state = utils.function_state(fn, args, kwargs)
|
41 |
+
|
42 |
+
for k, v in state.items():
|
43 |
+
msg_list.append(f"- {k}: {format_argument(v)}")
|
44 |
+
|
45 |
+
return "\n".join(msg_list)
|
46 |
+
|
47 |
+
|
48 |
+
@_beartype.beartype
|
49 |
+
def format_return_values_in_markdown(
|
50 |
+
return_values: Any,
|
51 |
+
format_argument: Callable[[Any], str] = formatter.format_argument,
|
52 |
+
) -> str:
|
53 |
+
return f"{format_argument(return_values)}"
|
54 |
+
|
55 |
+
|
56 |
+
ModifierCallableType = Callable[
|
57 |
+
[infra.Diagnostic, Callable, Tuple[Any, ...], Dict[str, Any], Any], None
|
58 |
+
]
|
59 |
+
|
60 |
+
|
61 |
+
@_beartype.beartype
|
62 |
+
def diagnose_call(
|
63 |
+
rule: infra.Rule,
|
64 |
+
*,
|
65 |
+
level: infra.Level = infra.Level.NONE,
|
66 |
+
diagnostic_type: Type[infra.Diagnostic] = infra.Diagnostic,
|
67 |
+
format_argument: Callable[[Any], str] = formatter.format_argument,
|
68 |
+
diagnostic_message_formatter: MessageFormatterType = format_message_in_text,
|
69 |
+
) -> Callable:
|
70 |
+
def decorator(fn):
|
71 |
+
@functools.wraps(fn)
|
72 |
+
def wrapper(*args, **kwargs):
|
73 |
+
common_error_message = "diagnose_call can only be applied to callables"
|
74 |
+
if not callable(fn):
|
75 |
+
raise AssertionError(
|
76 |
+
f"{common_error_message}. Got {type(fn)} instead of callable."
|
77 |
+
)
|
78 |
+
arg0 = args[0] if len(args) > 0 else None
|
79 |
+
if isinstance(ctx := arg0, infra.DiagnosticContext):
|
80 |
+
pass
|
81 |
+
elif isinstance(
|
82 |
+
ctx := getattr(arg0, "diagnostic_context", None),
|
83 |
+
infra.DiagnosticContext,
|
84 |
+
):
|
85 |
+
pass
|
86 |
+
else:
|
87 |
+
# NOTE: At decorate time, it can't tell if a callable is function or method.
|
88 |
+
# Technically both are regarded as function at that time.
|
89 |
+
raise AssertionError(
|
90 |
+
f"{common_error_message}. For {fn}, "
|
91 |
+
f"If it is a function, a DiagnosticContext instance must be present as "
|
92 |
+
f"the first argument. "
|
93 |
+
f"If it is a method, a DiagnosticContext instance must be present as "
|
94 |
+
f"the attribute 'diagnostic_context' of the 'self' argument."
|
95 |
+
)
|
96 |
+
|
97 |
+
diag = diagnostic_type(
|
98 |
+
rule,
|
99 |
+
level,
|
100 |
+
diagnostic_message_formatter(fn, *args, **kwargs),
|
101 |
+
)
|
102 |
+
|
103 |
+
# pop the decorator frame
|
104 |
+
# TODO(bowbao): by default diagnostic doesn't have stack.
|
105 |
+
# So need to check before doing this. Make the code cleaner.
|
106 |
+
# Option: do not capture stack by default in diagnostic initialization.
|
107 |
+
stack: Optional[infra.Stack] = None
|
108 |
+
if len(diag.stacks) > 0:
|
109 |
+
stack = diag.stacks[0]
|
110 |
+
stack.frames.pop(0)
|
111 |
+
|
112 |
+
# set function location
|
113 |
+
fn_location = utils.function_location(fn)
|
114 |
+
diag.locations.insert(0, fn_location)
|
115 |
+
# Add function location to the top of the stack.
|
116 |
+
if stack is not None:
|
117 |
+
stack.frames.insert(0, infra.StackFrame(location=fn_location))
|
118 |
+
|
119 |
+
with diag.log_section(logging.INFO, "Function Signature"):
|
120 |
+
diag.log(
|
121 |
+
logging.INFO,
|
122 |
+
"%s",
|
123 |
+
formatter.LazyString(
|
124 |
+
format_function_signature_in_markdown,
|
125 |
+
fn,
|
126 |
+
args,
|
127 |
+
kwargs,
|
128 |
+
format_argument,
|
129 |
+
),
|
130 |
+
)
|
131 |
+
|
132 |
+
return_values: Any = None
|
133 |
+
with ctx.add_inflight_diagnostic(diag) as diag:
|
134 |
+
try:
|
135 |
+
return_values = fn(*args, **kwargs)
|
136 |
+
with diag.log_section(logging.INFO, "Return values"):
|
137 |
+
diag.log(
|
138 |
+
logging.INFO,
|
139 |
+
"%s",
|
140 |
+
formatter.LazyString(
|
141 |
+
format_return_values_in_markdown,
|
142 |
+
return_values,
|
143 |
+
format_argument,
|
144 |
+
),
|
145 |
+
)
|
146 |
+
return return_values
|
147 |
+
except Exception as e:
|
148 |
+
diag.log_source_exception(logging.ERROR, e)
|
149 |
+
diag.level = infra.Level.ERROR
|
150 |
+
finally:
|
151 |
+
ctx.log_and_raise_if_error(diag)
|
152 |
+
|
153 |
+
return wrapper
|
154 |
+
|
155 |
+
return decorator
|
156 |
+
|
157 |
+
|
158 |
+
# TODO(bowbao): decorator to report only when failed.
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/formatter.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
|
3 |
+
import dataclasses
|
4 |
+
import json
|
5 |
+
import re
|
6 |
+
import traceback
|
7 |
+
from typing import Any, Callable, Dict, List, Optional, Union
|
8 |
+
|
9 |
+
from torch._logging import LazyString
|
10 |
+
from torch.onnx._internal import _beartype
|
11 |
+
from torch.onnx._internal.diagnostics.infra import sarif
|
12 |
+
|
13 |
+
|
14 |
+
# A list of types in the SARIF module to support pretty printing.
|
15 |
+
# This is solely for type annotation for the functions below.
|
16 |
+
_SarifClass = Union[
|
17 |
+
sarif.SarifLog,
|
18 |
+
sarif.Run,
|
19 |
+
sarif.ReportingDescriptor,
|
20 |
+
sarif.Result,
|
21 |
+
]
|
22 |
+
|
23 |
+
|
24 |
+
def lazy_format_exception(exception: Exception) -> LazyString:
|
25 |
+
return LazyString(
|
26 |
+
lambda: "\n".join(
|
27 |
+
(
|
28 |
+
"```",
|
29 |
+
*traceback.format_exception(
|
30 |
+
type(exception), exception, exception.__traceback__
|
31 |
+
),
|
32 |
+
"```",
|
33 |
+
)
|
34 |
+
),
|
35 |
+
)
|
36 |
+
|
37 |
+
|
38 |
+
@_beartype.beartype
|
39 |
+
def snake_case_to_camel_case(s: str) -> str:
|
40 |
+
splits = s.split("_")
|
41 |
+
if len(splits) <= 1:
|
42 |
+
return s
|
43 |
+
return "".join([splits[0], *map(str.capitalize, splits[1:])])
|
44 |
+
|
45 |
+
|
46 |
+
@_beartype.beartype
|
47 |
+
def camel_case_to_snake_case(s: str) -> str:
|
48 |
+
return re.sub(r"([A-Z])", r"_\1", s).lower()
|
49 |
+
|
50 |
+
|
51 |
+
@_beartype.beartype
|
52 |
+
def kebab_case_to_snake_case(s: str) -> str:
|
53 |
+
return s.replace("-", "_")
|
54 |
+
|
55 |
+
|
56 |
+
@_beartype.beartype
|
57 |
+
def _convert_key(
|
58 |
+
object: Union[Dict[str, Any], Any], convert: Callable[[str], str]
|
59 |
+
) -> Union[Dict[str, Any], Any]:
|
60 |
+
"""Convert and update keys in a dictionary with "convert".
|
61 |
+
|
62 |
+
Any value that is a dictionary will be recursively updated.
|
63 |
+
Any value that is a list will be recursively searched.
|
64 |
+
|
65 |
+
Args:
|
66 |
+
object: The object to update.
|
67 |
+
convert: The function to convert the keys, e.g. `kebab_case_to_snake_case`.
|
68 |
+
|
69 |
+
Returns:
|
70 |
+
The updated object.
|
71 |
+
"""
|
72 |
+
if not isinstance(object, Dict):
|
73 |
+
return object
|
74 |
+
new_dict = {}
|
75 |
+
for k, v in object.items():
|
76 |
+
new_k = convert(k)
|
77 |
+
if isinstance(v, Dict):
|
78 |
+
new_v = _convert_key(v, convert)
|
79 |
+
elif isinstance(v, List):
|
80 |
+
new_v = [_convert_key(elem, convert) for elem in v]
|
81 |
+
else:
|
82 |
+
new_v = v
|
83 |
+
if new_v is None:
|
84 |
+
# Otherwise unnecessarily bloated sarif log with "null"s.
|
85 |
+
continue
|
86 |
+
if new_v == -1:
|
87 |
+
# WAR: -1 as default value shouldn't be logged into sarif.
|
88 |
+
continue
|
89 |
+
|
90 |
+
new_dict[new_k] = new_v
|
91 |
+
|
92 |
+
return new_dict
|
93 |
+
|
94 |
+
|
95 |
+
@_beartype.beartype
|
96 |
+
def sarif_to_json(attr_cls_obj: _SarifClass, indent: Optional[str] = " ") -> str:
|
97 |
+
dict = dataclasses.asdict(attr_cls_obj)
|
98 |
+
dict = _convert_key(dict, snake_case_to_camel_case)
|
99 |
+
return json.dumps(dict, indent=indent, separators=(",", ":"))
|
100 |
+
|
101 |
+
|
102 |
+
@_beartype.beartype
|
103 |
+
def format_argument(obj: Any) -> str:
|
104 |
+
return f"{type(obj)}"
|
105 |
+
|
106 |
+
|
107 |
+
@_beartype.beartype
|
108 |
+
def display_name(fn: Callable) -> str:
|
109 |
+
if hasattr(fn, "__qualname__"):
|
110 |
+
return fn.__qualname__
|
111 |
+
elif hasattr(fn, "__name__"):
|
112 |
+
return fn.__name__
|
113 |
+
else:
|
114 |
+
return str(fn)
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/__init__.py
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from torch.onnx._internal.diagnostics.infra.sarif._address import Address
|
5 |
+
from torch.onnx._internal.diagnostics.infra.sarif._artifact import Artifact
|
6 |
+
from torch.onnx._internal.diagnostics.infra.sarif._artifact_change import ArtifactChange
|
7 |
+
from torch.onnx._internal.diagnostics.infra.sarif._artifact_content import (
|
8 |
+
ArtifactContent,
|
9 |
+
)
|
10 |
+
from torch.onnx._internal.diagnostics.infra.sarif._artifact_location import (
|
11 |
+
ArtifactLocation,
|
12 |
+
)
|
13 |
+
from torch.onnx._internal.diagnostics.infra.sarif._attachment import Attachment
|
14 |
+
from torch.onnx._internal.diagnostics.infra.sarif._code_flow import CodeFlow
|
15 |
+
from torch.onnx._internal.diagnostics.infra.sarif._configuration_override import (
|
16 |
+
ConfigurationOverride,
|
17 |
+
)
|
18 |
+
from torch.onnx._internal.diagnostics.infra.sarif._conversion import Conversion
|
19 |
+
from torch.onnx._internal.diagnostics.infra.sarif._edge import Edge
|
20 |
+
from torch.onnx._internal.diagnostics.infra.sarif._edge_traversal import EdgeTraversal
|
21 |
+
from torch.onnx._internal.diagnostics.infra.sarif._exception import Exception
|
22 |
+
from torch.onnx._internal.diagnostics.infra.sarif._external_properties import (
|
23 |
+
ExternalProperties,
|
24 |
+
)
|
25 |
+
from torch.onnx._internal.diagnostics.infra.sarif._external_property_file_reference import (
|
26 |
+
ExternalPropertyFileReference,
|
27 |
+
)
|
28 |
+
from torch.onnx._internal.diagnostics.infra.sarif._external_property_file_references import (
|
29 |
+
ExternalPropertyFileReferences,
|
30 |
+
)
|
31 |
+
from torch.onnx._internal.diagnostics.infra.sarif._fix import Fix
|
32 |
+
from torch.onnx._internal.diagnostics.infra.sarif._graph import Graph
|
33 |
+
from torch.onnx._internal.diagnostics.infra.sarif._graph_traversal import GraphTraversal
|
34 |
+
from torch.onnx._internal.diagnostics.infra.sarif._invocation import Invocation
|
35 |
+
from torch.onnx._internal.diagnostics.infra.sarif._location import Location
|
36 |
+
from torch.onnx._internal.diagnostics.infra.sarif._location_relationship import (
|
37 |
+
LocationRelationship,
|
38 |
+
)
|
39 |
+
from torch.onnx._internal.diagnostics.infra.sarif._logical_location import (
|
40 |
+
LogicalLocation,
|
41 |
+
)
|
42 |
+
from torch.onnx._internal.diagnostics.infra.sarif._message import Message
|
43 |
+
from torch.onnx._internal.diagnostics.infra.sarif._multiformat_message_string import (
|
44 |
+
MultiformatMessageString,
|
45 |
+
)
|
46 |
+
from torch.onnx._internal.diagnostics.infra.sarif._node import Node
|
47 |
+
from torch.onnx._internal.diagnostics.infra.sarif._notification import Notification
|
48 |
+
from torch.onnx._internal.diagnostics.infra.sarif._physical_location import (
|
49 |
+
PhysicalLocation,
|
50 |
+
)
|
51 |
+
from torch.onnx._internal.diagnostics.infra.sarif._property_bag import PropertyBag
|
52 |
+
from torch.onnx._internal.diagnostics.infra.sarif._rectangle import Rectangle
|
53 |
+
from torch.onnx._internal.diagnostics.infra.sarif._region import Region
|
54 |
+
from torch.onnx._internal.diagnostics.infra.sarif._replacement import Replacement
|
55 |
+
from torch.onnx._internal.diagnostics.infra.sarif._reporting_configuration import (
|
56 |
+
ReportingConfiguration,
|
57 |
+
)
|
58 |
+
from torch.onnx._internal.diagnostics.infra.sarif._reporting_descriptor import (
|
59 |
+
ReportingDescriptor,
|
60 |
+
)
|
61 |
+
from torch.onnx._internal.diagnostics.infra.sarif._reporting_descriptor_reference import (
|
62 |
+
ReportingDescriptorReference,
|
63 |
+
)
|
64 |
+
from torch.onnx._internal.diagnostics.infra.sarif._reporting_descriptor_relationship import (
|
65 |
+
ReportingDescriptorRelationship,
|
66 |
+
)
|
67 |
+
from torch.onnx._internal.diagnostics.infra.sarif._result import Result
|
68 |
+
from torch.onnx._internal.diagnostics.infra.sarif._result_provenance import (
|
69 |
+
ResultProvenance,
|
70 |
+
)
|
71 |
+
from torch.onnx._internal.diagnostics.infra.sarif._run import Run
|
72 |
+
from torch.onnx._internal.diagnostics.infra.sarif._run_automation_details import (
|
73 |
+
RunAutomationDetails,
|
74 |
+
)
|
75 |
+
from torch.onnx._internal.diagnostics.infra.sarif._sarif_log import SarifLog
|
76 |
+
from torch.onnx._internal.diagnostics.infra.sarif._special_locations import (
|
77 |
+
SpecialLocations,
|
78 |
+
)
|
79 |
+
from torch.onnx._internal.diagnostics.infra.sarif._stack import Stack
|
80 |
+
from torch.onnx._internal.diagnostics.infra.sarif._stack_frame import StackFrame
|
81 |
+
from torch.onnx._internal.diagnostics.infra.sarif._suppression import Suppression
|
82 |
+
from torch.onnx._internal.diagnostics.infra.sarif._thread_flow import ThreadFlow
|
83 |
+
from torch.onnx._internal.diagnostics.infra.sarif._thread_flow_location import (
|
84 |
+
ThreadFlowLocation,
|
85 |
+
)
|
86 |
+
from torch.onnx._internal.diagnostics.infra.sarif._tool import Tool
|
87 |
+
from torch.onnx._internal.diagnostics.infra.sarif._tool_component import ToolComponent
|
88 |
+
from torch.onnx._internal.diagnostics.infra.sarif._tool_component_reference import (
|
89 |
+
ToolComponentReference,
|
90 |
+
)
|
91 |
+
from torch.onnx._internal.diagnostics.infra.sarif._translation_metadata import (
|
92 |
+
TranslationMetadata,
|
93 |
+
)
|
94 |
+
from torch.onnx._internal.diagnostics.infra.sarif._version_control_details import (
|
95 |
+
VersionControlDetails,
|
96 |
+
)
|
97 |
+
from torch.onnx._internal.diagnostics.infra.sarif._web_request import WebRequest
|
98 |
+
from torch.onnx._internal.diagnostics.infra.sarif._web_response import WebResponse
|
99 |
+
|
100 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/__pycache__/_fix.cpython-310.pyc
ADDED
Binary file (1.22 kB). View file
|
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/__pycache__/_physical_location.cpython-310.pyc
ADDED
Binary file (1.34 kB). View file
|
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_address.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class Address(object):
|
14 |
+
"""A physical or virtual address, or a range of addresses, in an 'addressable region' (memory or a binary file)."""
|
15 |
+
|
16 |
+
absolute_address: int = dataclasses.field(
|
17 |
+
default=-1, metadata={"schema_property_name": "absoluteAddress"}
|
18 |
+
)
|
19 |
+
fully_qualified_name: Optional[str] = dataclasses.field(
|
20 |
+
default=None, metadata={"schema_property_name": "fullyQualifiedName"}
|
21 |
+
)
|
22 |
+
index: int = dataclasses.field(
|
23 |
+
default=-1, metadata={"schema_property_name": "index"}
|
24 |
+
)
|
25 |
+
kind: Optional[str] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "kind"}
|
27 |
+
)
|
28 |
+
length: Optional[int] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "length"}
|
30 |
+
)
|
31 |
+
name: Optional[str] = dataclasses.field(
|
32 |
+
default=None, metadata={"schema_property_name": "name"}
|
33 |
+
)
|
34 |
+
offset_from_parent: Optional[int] = dataclasses.field(
|
35 |
+
default=None, metadata={"schema_property_name": "offsetFromParent"}
|
36 |
+
)
|
37 |
+
parent_index: int = dataclasses.field(
|
38 |
+
default=-1, metadata={"schema_property_name": "parentIndex"}
|
39 |
+
)
|
40 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
41 |
+
default=None, metadata={"schema_property_name": "properties"}
|
42 |
+
)
|
43 |
+
relative_address: Optional[int] = dataclasses.field(
|
44 |
+
default=None, metadata={"schema_property_name": "relativeAddress"}
|
45 |
+
)
|
46 |
+
|
47 |
+
|
48 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact.py
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Any, List, Literal, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_content,
|
11 |
+
_artifact_location,
|
12 |
+
_message,
|
13 |
+
_property_bag,
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class Artifact(object):
|
19 |
+
"""A single artifact. In some cases, this artifact might be nested within another artifact."""
|
20 |
+
|
21 |
+
contents: Optional[_artifact_content.ArtifactContent] = dataclasses.field(
|
22 |
+
default=None, metadata={"schema_property_name": "contents"}
|
23 |
+
)
|
24 |
+
description: Optional[_message.Message] = dataclasses.field(
|
25 |
+
default=None, metadata={"schema_property_name": "description"}
|
26 |
+
)
|
27 |
+
encoding: Optional[str] = dataclasses.field(
|
28 |
+
default=None, metadata={"schema_property_name": "encoding"}
|
29 |
+
)
|
30 |
+
hashes: Any = dataclasses.field(
|
31 |
+
default=None, metadata={"schema_property_name": "hashes"}
|
32 |
+
)
|
33 |
+
last_modified_time_utc: Optional[str] = dataclasses.field(
|
34 |
+
default=None, metadata={"schema_property_name": "lastModifiedTimeUtc"}
|
35 |
+
)
|
36 |
+
length: int = dataclasses.field(
|
37 |
+
default=-1, metadata={"schema_property_name": "length"}
|
38 |
+
)
|
39 |
+
location: Optional[_artifact_location.ArtifactLocation] = dataclasses.field(
|
40 |
+
default=None, metadata={"schema_property_name": "location"}
|
41 |
+
)
|
42 |
+
mime_type: Optional[str] = dataclasses.field(
|
43 |
+
default=None, metadata={"schema_property_name": "mimeType"}
|
44 |
+
)
|
45 |
+
offset: Optional[int] = dataclasses.field(
|
46 |
+
default=None, metadata={"schema_property_name": "offset"}
|
47 |
+
)
|
48 |
+
parent_index: int = dataclasses.field(
|
49 |
+
default=-1, metadata={"schema_property_name": "parentIndex"}
|
50 |
+
)
|
51 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
52 |
+
default=None, metadata={"schema_property_name": "properties"}
|
53 |
+
)
|
54 |
+
roles: Optional[
|
55 |
+
List[
|
56 |
+
Literal[
|
57 |
+
"analysisTarget",
|
58 |
+
"attachment",
|
59 |
+
"responseFile",
|
60 |
+
"resultFile",
|
61 |
+
"standardStream",
|
62 |
+
"tracedFile",
|
63 |
+
"unmodified",
|
64 |
+
"modified",
|
65 |
+
"added",
|
66 |
+
"deleted",
|
67 |
+
"renamed",
|
68 |
+
"uncontrolled",
|
69 |
+
"driver",
|
70 |
+
"extension",
|
71 |
+
"translation",
|
72 |
+
"taxonomy",
|
73 |
+
"policy",
|
74 |
+
"referencedOnCommandLine",
|
75 |
+
"memoryContents",
|
76 |
+
"directory",
|
77 |
+
"userSpecifiedConfiguration",
|
78 |
+
"toolSpecifiedConfiguration",
|
79 |
+
"debugOutputFile",
|
80 |
+
]
|
81 |
+
]
|
82 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "roles"})
|
83 |
+
source_language: Optional[str] = dataclasses.field(
|
84 |
+
default=None, metadata={"schema_property_name": "sourceLanguage"}
|
85 |
+
)
|
86 |
+
|
87 |
+
|
88 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_change.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_location,
|
11 |
+
_property_bag,
|
12 |
+
_replacement,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class ArtifactChange(object):
|
18 |
+
"""A change to a single artifact."""
|
19 |
+
|
20 |
+
artifact_location: _artifact_location.ArtifactLocation = dataclasses.field(
|
21 |
+
metadata={"schema_property_name": "artifactLocation"}
|
22 |
+
)
|
23 |
+
replacements: List[_replacement.Replacement] = dataclasses.field(
|
24 |
+
metadata={"schema_property_name": "replacements"}
|
25 |
+
)
|
26 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "properties"}
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_content.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_multiformat_message_string,
|
11 |
+
_property_bag,
|
12 |
+
)
|
13 |
+
|
14 |
+
|
15 |
+
@dataclasses.dataclass
|
16 |
+
class ArtifactContent(object):
|
17 |
+
"""Represents the contents of an artifact."""
|
18 |
+
|
19 |
+
binary: Optional[str] = dataclasses.field(
|
20 |
+
default=None, metadata={"schema_property_name": "binary"}
|
21 |
+
)
|
22 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
23 |
+
default=None, metadata={"schema_property_name": "properties"}
|
24 |
+
)
|
25 |
+
rendered: Optional[
|
26 |
+
_multiformat_message_string.MultiformatMessageString
|
27 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "rendered"})
|
28 |
+
text: Optional[str] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "text"}
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_location.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _message, _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class ArtifactLocation(object):
|
14 |
+
"""Specifies the location of an artifact."""
|
15 |
+
|
16 |
+
description: Optional[_message.Message] = dataclasses.field(
|
17 |
+
default=None, metadata={"schema_property_name": "description"}
|
18 |
+
)
|
19 |
+
index: int = dataclasses.field(
|
20 |
+
default=-1, metadata={"schema_property_name": "index"}
|
21 |
+
)
|
22 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
23 |
+
default=None, metadata={"schema_property_name": "properties"}
|
24 |
+
)
|
25 |
+
uri: Optional[str] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "uri"}
|
27 |
+
)
|
28 |
+
uri_base_id: Optional[str] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "uriBaseId"}
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_attachment.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_location,
|
11 |
+
_message,
|
12 |
+
_property_bag,
|
13 |
+
_rectangle,
|
14 |
+
_region,
|
15 |
+
)
|
16 |
+
|
17 |
+
|
18 |
+
@dataclasses.dataclass
|
19 |
+
class Attachment(object):
|
20 |
+
"""An artifact relevant to a result."""
|
21 |
+
|
22 |
+
artifact_location: _artifact_location.ArtifactLocation = dataclasses.field(
|
23 |
+
metadata={"schema_property_name": "artifactLocation"}
|
24 |
+
)
|
25 |
+
description: Optional[_message.Message] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "description"}
|
27 |
+
)
|
28 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "properties"}
|
30 |
+
)
|
31 |
+
rectangles: Optional[List[_rectangle.Rectangle]] = dataclasses.field(
|
32 |
+
default=None, metadata={"schema_property_name": "rectangles"}
|
33 |
+
)
|
34 |
+
regions: Optional[List[_region.Region]] = dataclasses.field(
|
35 |
+
default=None, metadata={"schema_property_name": "regions"}
|
36 |
+
)
|
37 |
+
|
38 |
+
|
39 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_code_flow.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_message,
|
11 |
+
_property_bag,
|
12 |
+
_thread_flow,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class CodeFlow(object):
|
18 |
+
"""A set of threadFlows which together describe a pattern of code execution relevant to detecting a result."""
|
19 |
+
|
20 |
+
thread_flows: List[_thread_flow.ThreadFlow] = dataclasses.field(
|
21 |
+
metadata={"schema_property_name": "threadFlows"}
|
22 |
+
)
|
23 |
+
message: Optional[_message.Message] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "message"}
|
25 |
+
)
|
26 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "properties"}
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_configuration_override.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_property_bag,
|
11 |
+
_reporting_configuration,
|
12 |
+
_reporting_descriptor_reference,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class ConfigurationOverride(object):
|
18 |
+
"""Information about how a specific rule or notification was reconfigured at runtime."""
|
19 |
+
|
20 |
+
configuration: _reporting_configuration.ReportingConfiguration = dataclasses.field(
|
21 |
+
metadata={"schema_property_name": "configuration"}
|
22 |
+
)
|
23 |
+
descriptor: _reporting_descriptor_reference.ReportingDescriptorReference = (
|
24 |
+
dataclasses.field(metadata={"schema_property_name": "descriptor"})
|
25 |
+
)
|
26 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "properties"}
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_conversion.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_location,
|
11 |
+
_invocation,
|
12 |
+
_property_bag,
|
13 |
+
_tool,
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class Conversion(object):
|
19 |
+
"""Describes how a converter transformed the output of a static analysis tool from the analysis tool's native output format into the SARIF format."""
|
20 |
+
|
21 |
+
tool: _tool.Tool = dataclasses.field(metadata={"schema_property_name": "tool"})
|
22 |
+
analysis_tool_log_files: Optional[
|
23 |
+
List[_artifact_location.ArtifactLocation]
|
24 |
+
] = dataclasses.field(
|
25 |
+
default=None, metadata={"schema_property_name": "analysisToolLogFiles"}
|
26 |
+
)
|
27 |
+
invocation: Optional[_invocation.Invocation] = dataclasses.field(
|
28 |
+
default=None, metadata={"schema_property_name": "invocation"}
|
29 |
+
)
|
30 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
31 |
+
default=None, metadata={"schema_property_name": "properties"}
|
32 |
+
)
|
33 |
+
|
34 |
+
|
35 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_edge.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _message, _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class Edge(object):
|
14 |
+
"""Represents a directed edge in a graph."""
|
15 |
+
|
16 |
+
id: str = dataclasses.field(metadata={"schema_property_name": "id"})
|
17 |
+
source_node_id: str = dataclasses.field(
|
18 |
+
metadata={"schema_property_name": "sourceNodeId"}
|
19 |
+
)
|
20 |
+
target_node_id: str = dataclasses.field(
|
21 |
+
metadata={"schema_property_name": "targetNodeId"}
|
22 |
+
)
|
23 |
+
label: Optional[_message.Message] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "label"}
|
25 |
+
)
|
26 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "properties"}
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_edge_traversal.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Any, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _message, _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class EdgeTraversal(object):
|
14 |
+
"""Represents the traversal of a single edge during a graph traversal."""
|
15 |
+
|
16 |
+
edge_id: str = dataclasses.field(metadata={"schema_property_name": "edgeId"})
|
17 |
+
final_state: Any = dataclasses.field(
|
18 |
+
default=None, metadata={"schema_property_name": "finalState"}
|
19 |
+
)
|
20 |
+
message: Optional[_message.Message] = dataclasses.field(
|
21 |
+
default=None, metadata={"schema_property_name": "message"}
|
22 |
+
)
|
23 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "properties"}
|
25 |
+
)
|
26 |
+
step_over_edge_count: Optional[int] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "stepOverEdgeCount"}
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_exception.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_exception,
|
11 |
+
_property_bag,
|
12 |
+
_stack,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class Exception(object):
|
18 |
+
"""Describes a runtime exception encountered during the execution of an analysis tool."""
|
19 |
+
|
20 |
+
inner_exceptions: Optional[List[_exception.Exception]] = dataclasses.field(
|
21 |
+
default=None, metadata={"schema_property_name": "innerExceptions"}
|
22 |
+
)
|
23 |
+
kind: Optional[str] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "kind"}
|
25 |
+
)
|
26 |
+
message: Optional[str] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "message"}
|
28 |
+
)
|
29 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
30 |
+
default=None, metadata={"schema_property_name": "properties"}
|
31 |
+
)
|
32 |
+
stack: Optional[_stack.Stack] = dataclasses.field(
|
33 |
+
default=None, metadata={"schema_property_name": "stack"}
|
34 |
+
)
|
35 |
+
|
36 |
+
|
37 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_external_properties.py
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Literal, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_address,
|
11 |
+
_artifact,
|
12 |
+
_conversion,
|
13 |
+
_graph,
|
14 |
+
_invocation,
|
15 |
+
_logical_location,
|
16 |
+
_property_bag,
|
17 |
+
_result,
|
18 |
+
_thread_flow_location,
|
19 |
+
_tool_component,
|
20 |
+
_web_request,
|
21 |
+
_web_response,
|
22 |
+
)
|
23 |
+
|
24 |
+
|
25 |
+
@dataclasses.dataclass
|
26 |
+
class ExternalProperties(object):
|
27 |
+
"""The top-level element of an external property file."""
|
28 |
+
|
29 |
+
addresses: Optional[List[_address.Address]] = dataclasses.field(
|
30 |
+
default=None, metadata={"schema_property_name": "addresses"}
|
31 |
+
)
|
32 |
+
artifacts: Optional[List[_artifact.Artifact]] = dataclasses.field(
|
33 |
+
default=None, metadata={"schema_property_name": "artifacts"}
|
34 |
+
)
|
35 |
+
conversion: Optional[_conversion.Conversion] = dataclasses.field(
|
36 |
+
default=None, metadata={"schema_property_name": "conversion"}
|
37 |
+
)
|
38 |
+
driver: Optional[_tool_component.ToolComponent] = dataclasses.field(
|
39 |
+
default=None, metadata={"schema_property_name": "driver"}
|
40 |
+
)
|
41 |
+
extensions: Optional[List[_tool_component.ToolComponent]] = dataclasses.field(
|
42 |
+
default=None, metadata={"schema_property_name": "extensions"}
|
43 |
+
)
|
44 |
+
externalized_properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
45 |
+
default=None, metadata={"schema_property_name": "externalizedProperties"}
|
46 |
+
)
|
47 |
+
graphs: Optional[List[_graph.Graph]] = dataclasses.field(
|
48 |
+
default=None, metadata={"schema_property_name": "graphs"}
|
49 |
+
)
|
50 |
+
guid: Optional[str] = dataclasses.field(
|
51 |
+
default=None, metadata={"schema_property_name": "guid"}
|
52 |
+
)
|
53 |
+
invocations: Optional[List[_invocation.Invocation]] = dataclasses.field(
|
54 |
+
default=None, metadata={"schema_property_name": "invocations"}
|
55 |
+
)
|
56 |
+
logical_locations: Optional[
|
57 |
+
List[_logical_location.LogicalLocation]
|
58 |
+
] = dataclasses.field(
|
59 |
+
default=None, metadata={"schema_property_name": "logicalLocations"}
|
60 |
+
)
|
61 |
+
policies: Optional[List[_tool_component.ToolComponent]] = dataclasses.field(
|
62 |
+
default=None, metadata={"schema_property_name": "policies"}
|
63 |
+
)
|
64 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
65 |
+
default=None, metadata={"schema_property_name": "properties"}
|
66 |
+
)
|
67 |
+
results: Optional[List[_result.Result]] = dataclasses.field(
|
68 |
+
default=None, metadata={"schema_property_name": "results"}
|
69 |
+
)
|
70 |
+
run_guid: Optional[str] = dataclasses.field(
|
71 |
+
default=None, metadata={"schema_property_name": "runGuid"}
|
72 |
+
)
|
73 |
+
schema: Optional[str] = dataclasses.field(
|
74 |
+
default=None, metadata={"schema_property_name": "schema"}
|
75 |
+
)
|
76 |
+
taxonomies: Optional[List[_tool_component.ToolComponent]] = dataclasses.field(
|
77 |
+
default=None, metadata={"schema_property_name": "taxonomies"}
|
78 |
+
)
|
79 |
+
thread_flow_locations: Optional[
|
80 |
+
List[_thread_flow_location.ThreadFlowLocation]
|
81 |
+
] = dataclasses.field(
|
82 |
+
default=None, metadata={"schema_property_name": "threadFlowLocations"}
|
83 |
+
)
|
84 |
+
translations: Optional[List[_tool_component.ToolComponent]] = dataclasses.field(
|
85 |
+
default=None, metadata={"schema_property_name": "translations"}
|
86 |
+
)
|
87 |
+
version: Optional[Literal["2.1.0"]] = dataclasses.field(
|
88 |
+
default=None, metadata={"schema_property_name": "version"}
|
89 |
+
)
|
90 |
+
web_requests: Optional[List[_web_request.WebRequest]] = dataclasses.field(
|
91 |
+
default=None, metadata={"schema_property_name": "webRequests"}
|
92 |
+
)
|
93 |
+
web_responses: Optional[List[_web_response.WebResponse]] = dataclasses.field(
|
94 |
+
default=None, metadata={"schema_property_name": "webResponses"}
|
95 |
+
)
|
96 |
+
|
97 |
+
|
98 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_external_property_file_reference.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_location,
|
11 |
+
_property_bag,
|
12 |
+
)
|
13 |
+
|
14 |
+
|
15 |
+
@dataclasses.dataclass
|
16 |
+
class ExternalPropertyFileReference(object):
|
17 |
+
"""Contains information that enables a SARIF consumer to locate the external property file that contains the value of an externalized property associated with the run."""
|
18 |
+
|
19 |
+
guid: Optional[str] = dataclasses.field(
|
20 |
+
default=None, metadata={"schema_property_name": "guid"}
|
21 |
+
)
|
22 |
+
item_count: int = dataclasses.field(
|
23 |
+
default=-1, metadata={"schema_property_name": "itemCount"}
|
24 |
+
)
|
25 |
+
location: Optional[_artifact_location.ArtifactLocation] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "location"}
|
27 |
+
)
|
28 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "properties"}
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_external_property_file_references.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_external_property_file_reference,
|
11 |
+
_property_bag,
|
12 |
+
)
|
13 |
+
|
14 |
+
|
15 |
+
@dataclasses.dataclass
|
16 |
+
class ExternalPropertyFileReferences(object):
|
17 |
+
"""References to external property files that should be inlined with the content of a root log file."""
|
18 |
+
|
19 |
+
addresses: Optional[
|
20 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
21 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "addresses"})
|
22 |
+
artifacts: Optional[
|
23 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
24 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "artifacts"})
|
25 |
+
conversion: Optional[
|
26 |
+
_external_property_file_reference.ExternalPropertyFileReference
|
27 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "conversion"})
|
28 |
+
driver: Optional[
|
29 |
+
_external_property_file_reference.ExternalPropertyFileReference
|
30 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "driver"})
|
31 |
+
extensions: Optional[
|
32 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
33 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "extensions"})
|
34 |
+
externalized_properties: Optional[
|
35 |
+
_external_property_file_reference.ExternalPropertyFileReference
|
36 |
+
] = dataclasses.field(
|
37 |
+
default=None, metadata={"schema_property_name": "externalizedProperties"}
|
38 |
+
)
|
39 |
+
graphs: Optional[
|
40 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
41 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "graphs"})
|
42 |
+
invocations: Optional[
|
43 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
44 |
+
] = dataclasses.field(
|
45 |
+
default=None, metadata={"schema_property_name": "invocations"}
|
46 |
+
)
|
47 |
+
logical_locations: Optional[
|
48 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
49 |
+
] = dataclasses.field(
|
50 |
+
default=None, metadata={"schema_property_name": "logicalLocations"}
|
51 |
+
)
|
52 |
+
policies: Optional[
|
53 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
54 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "policies"})
|
55 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
56 |
+
default=None, metadata={"schema_property_name": "properties"}
|
57 |
+
)
|
58 |
+
results: Optional[
|
59 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
60 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "results"})
|
61 |
+
taxonomies: Optional[
|
62 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
63 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "taxonomies"})
|
64 |
+
thread_flow_locations: Optional[
|
65 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
66 |
+
] = dataclasses.field(
|
67 |
+
default=None, metadata={"schema_property_name": "threadFlowLocations"}
|
68 |
+
)
|
69 |
+
translations: Optional[
|
70 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
71 |
+
] = dataclasses.field(
|
72 |
+
default=None, metadata={"schema_property_name": "translations"}
|
73 |
+
)
|
74 |
+
web_requests: Optional[
|
75 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
76 |
+
] = dataclasses.field(
|
77 |
+
default=None, metadata={"schema_property_name": "webRequests"}
|
78 |
+
)
|
79 |
+
web_responses: Optional[
|
80 |
+
List[_external_property_file_reference.ExternalPropertyFileReference]
|
81 |
+
] = dataclasses.field(
|
82 |
+
default=None, metadata={"schema_property_name": "webResponses"}
|
83 |
+
)
|
84 |
+
|
85 |
+
|
86 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_fix.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_change,
|
11 |
+
_message,
|
12 |
+
_property_bag,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class Fix(object):
|
18 |
+
"""A proposed fix for the problem represented by a result object. A fix specifies a set of artifacts to modify. For each artifact, it specifies a set of bytes to remove, and provides a set of new bytes to replace them."""
|
19 |
+
|
20 |
+
artifact_changes: List[_artifact_change.ArtifactChange] = dataclasses.field(
|
21 |
+
metadata={"schema_property_name": "artifactChanges"}
|
22 |
+
)
|
23 |
+
description: Optional[_message.Message] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "description"}
|
25 |
+
)
|
26 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "properties"}
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_graph.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_edge,
|
11 |
+
_message,
|
12 |
+
_node,
|
13 |
+
_property_bag,
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class Graph(object):
|
19 |
+
"""A network of nodes and directed edges that describes some aspect of the structure of the code (for example, a call graph)."""
|
20 |
+
|
21 |
+
description: Optional[_message.Message] = dataclasses.field(
|
22 |
+
default=None, metadata={"schema_property_name": "description"}
|
23 |
+
)
|
24 |
+
edges: Optional[List[_edge.Edge]] = dataclasses.field(
|
25 |
+
default=None, metadata={"schema_property_name": "edges"}
|
26 |
+
)
|
27 |
+
nodes: Optional[List[_node.Node]] = dataclasses.field(
|
28 |
+
default=None, metadata={"schema_property_name": "nodes"}
|
29 |
+
)
|
30 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
31 |
+
default=None, metadata={"schema_property_name": "properties"}
|
32 |
+
)
|
33 |
+
|
34 |
+
|
35 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_graph_traversal.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Any, List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_edge_traversal,
|
11 |
+
_message,
|
12 |
+
_property_bag,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class GraphTraversal(object):
|
18 |
+
"""Represents a path through a graph."""
|
19 |
+
|
20 |
+
description: Optional[_message.Message] = dataclasses.field(
|
21 |
+
default=None, metadata={"schema_property_name": "description"}
|
22 |
+
)
|
23 |
+
edge_traversals: Optional[List[_edge_traversal.EdgeTraversal]] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "edgeTraversals"}
|
25 |
+
)
|
26 |
+
immutable_state: Any = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "immutableState"}
|
28 |
+
)
|
29 |
+
initial_state: Any = dataclasses.field(
|
30 |
+
default=None, metadata={"schema_property_name": "initialState"}
|
31 |
+
)
|
32 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
33 |
+
default=None, metadata={"schema_property_name": "properties"}
|
34 |
+
)
|
35 |
+
result_graph_index: int = dataclasses.field(
|
36 |
+
default=-1, metadata={"schema_property_name": "resultGraphIndex"}
|
37 |
+
)
|
38 |
+
run_graph_index: int = dataclasses.field(
|
39 |
+
default=-1, metadata={"schema_property_name": "runGraphIndex"}
|
40 |
+
)
|
41 |
+
|
42 |
+
|
43 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_invocation.py
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Any, List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_location,
|
11 |
+
_configuration_override,
|
12 |
+
_notification,
|
13 |
+
_property_bag,
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class Invocation(object):
|
19 |
+
"""The runtime environment of the analysis tool run."""
|
20 |
+
|
21 |
+
execution_successful: bool = dataclasses.field(
|
22 |
+
metadata={"schema_property_name": "executionSuccessful"}
|
23 |
+
)
|
24 |
+
account: Optional[str] = dataclasses.field(
|
25 |
+
default=None, metadata={"schema_property_name": "account"}
|
26 |
+
)
|
27 |
+
arguments: Optional[List[str]] = dataclasses.field(
|
28 |
+
default=None, metadata={"schema_property_name": "arguments"}
|
29 |
+
)
|
30 |
+
command_line: Optional[str] = dataclasses.field(
|
31 |
+
default=None, metadata={"schema_property_name": "commandLine"}
|
32 |
+
)
|
33 |
+
end_time_utc: Optional[str] = dataclasses.field(
|
34 |
+
default=None, metadata={"schema_property_name": "endTimeUtc"}
|
35 |
+
)
|
36 |
+
environment_variables: Any = dataclasses.field(
|
37 |
+
default=None, metadata={"schema_property_name": "environmentVariables"}
|
38 |
+
)
|
39 |
+
executable_location: Optional[
|
40 |
+
_artifact_location.ArtifactLocation
|
41 |
+
] = dataclasses.field(
|
42 |
+
default=None, metadata={"schema_property_name": "executableLocation"}
|
43 |
+
)
|
44 |
+
exit_code: Optional[int] = dataclasses.field(
|
45 |
+
default=None, metadata={"schema_property_name": "exitCode"}
|
46 |
+
)
|
47 |
+
exit_code_description: Optional[str] = dataclasses.field(
|
48 |
+
default=None, metadata={"schema_property_name": "exitCodeDescription"}
|
49 |
+
)
|
50 |
+
exit_signal_name: Optional[str] = dataclasses.field(
|
51 |
+
default=None, metadata={"schema_property_name": "exitSignalName"}
|
52 |
+
)
|
53 |
+
exit_signal_number: Optional[int] = dataclasses.field(
|
54 |
+
default=None, metadata={"schema_property_name": "exitSignalNumber"}
|
55 |
+
)
|
56 |
+
machine: Optional[str] = dataclasses.field(
|
57 |
+
default=None, metadata={"schema_property_name": "machine"}
|
58 |
+
)
|
59 |
+
notification_configuration_overrides: Optional[
|
60 |
+
List[_configuration_override.ConfigurationOverride]
|
61 |
+
] = dataclasses.field(
|
62 |
+
default=None,
|
63 |
+
metadata={"schema_property_name": "notificationConfigurationOverrides"},
|
64 |
+
)
|
65 |
+
process_id: Optional[int] = dataclasses.field(
|
66 |
+
default=None, metadata={"schema_property_name": "processId"}
|
67 |
+
)
|
68 |
+
process_start_failure_message: Optional[str] = dataclasses.field(
|
69 |
+
default=None, metadata={"schema_property_name": "processStartFailureMessage"}
|
70 |
+
)
|
71 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
72 |
+
default=None, metadata={"schema_property_name": "properties"}
|
73 |
+
)
|
74 |
+
response_files: Optional[
|
75 |
+
List[_artifact_location.ArtifactLocation]
|
76 |
+
] = dataclasses.field(
|
77 |
+
default=None, metadata={"schema_property_name": "responseFiles"}
|
78 |
+
)
|
79 |
+
rule_configuration_overrides: Optional[
|
80 |
+
List[_configuration_override.ConfigurationOverride]
|
81 |
+
] = dataclasses.field(
|
82 |
+
default=None, metadata={"schema_property_name": "ruleConfigurationOverrides"}
|
83 |
+
)
|
84 |
+
start_time_utc: Optional[str] = dataclasses.field(
|
85 |
+
default=None, metadata={"schema_property_name": "startTimeUtc"}
|
86 |
+
)
|
87 |
+
stderr: Optional[_artifact_location.ArtifactLocation] = dataclasses.field(
|
88 |
+
default=None, metadata={"schema_property_name": "stderr"}
|
89 |
+
)
|
90 |
+
stdin: Optional[_artifact_location.ArtifactLocation] = dataclasses.field(
|
91 |
+
default=None, metadata={"schema_property_name": "stdin"}
|
92 |
+
)
|
93 |
+
stdout: Optional[_artifact_location.ArtifactLocation] = dataclasses.field(
|
94 |
+
default=None, metadata={"schema_property_name": "stdout"}
|
95 |
+
)
|
96 |
+
stdout_stderr: Optional[_artifact_location.ArtifactLocation] = dataclasses.field(
|
97 |
+
default=None, metadata={"schema_property_name": "stdoutStderr"}
|
98 |
+
)
|
99 |
+
tool_configuration_notifications: Optional[
|
100 |
+
List[_notification.Notification]
|
101 |
+
] = dataclasses.field(
|
102 |
+
default=None,
|
103 |
+
metadata={"schema_property_name": "toolConfigurationNotifications"},
|
104 |
+
)
|
105 |
+
tool_execution_notifications: Optional[
|
106 |
+
List[_notification.Notification]
|
107 |
+
] = dataclasses.field(
|
108 |
+
default=None, metadata={"schema_property_name": "toolExecutionNotifications"}
|
109 |
+
)
|
110 |
+
working_directory: Optional[
|
111 |
+
_artifact_location.ArtifactLocation
|
112 |
+
] = dataclasses.field(
|
113 |
+
default=None, metadata={"schema_property_name": "workingDirectory"}
|
114 |
+
)
|
115 |
+
|
116 |
+
|
117 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_location.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_location_relationship,
|
11 |
+
_logical_location,
|
12 |
+
_message,
|
13 |
+
_physical_location,
|
14 |
+
_property_bag,
|
15 |
+
_region,
|
16 |
+
)
|
17 |
+
|
18 |
+
|
19 |
+
@dataclasses.dataclass
|
20 |
+
class Location(object):
|
21 |
+
"""A location within a programming artifact."""
|
22 |
+
|
23 |
+
annotations: Optional[List[_region.Region]] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "annotations"}
|
25 |
+
)
|
26 |
+
id: int = dataclasses.field(default=-1, metadata={"schema_property_name": "id"})
|
27 |
+
logical_locations: Optional[
|
28 |
+
List[_logical_location.LogicalLocation]
|
29 |
+
] = dataclasses.field(
|
30 |
+
default=None, metadata={"schema_property_name": "logicalLocations"}
|
31 |
+
)
|
32 |
+
message: Optional[_message.Message] = dataclasses.field(
|
33 |
+
default=None, metadata={"schema_property_name": "message"}
|
34 |
+
)
|
35 |
+
physical_location: Optional[
|
36 |
+
_physical_location.PhysicalLocation
|
37 |
+
] = dataclasses.field(
|
38 |
+
default=None, metadata={"schema_property_name": "physicalLocation"}
|
39 |
+
)
|
40 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
41 |
+
default=None, metadata={"schema_property_name": "properties"}
|
42 |
+
)
|
43 |
+
relationships: Optional[
|
44 |
+
List[_location_relationship.LocationRelationship]
|
45 |
+
] = dataclasses.field(
|
46 |
+
default=None, metadata={"schema_property_name": "relationships"}
|
47 |
+
)
|
48 |
+
|
49 |
+
|
50 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_location_relationship.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _message, _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class LocationRelationship(object):
|
14 |
+
"""Information about the relation of one location to another."""
|
15 |
+
|
16 |
+
target: int = dataclasses.field(metadata={"schema_property_name": "target"})
|
17 |
+
description: Optional[_message.Message] = dataclasses.field(
|
18 |
+
default=None, metadata={"schema_property_name": "description"}
|
19 |
+
)
|
20 |
+
kinds: List[str] = dataclasses.field(
|
21 |
+
default_factory=lambda: ["relevant"], metadata={"schema_property_name": "kinds"}
|
22 |
+
)
|
23 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "properties"}
|
25 |
+
)
|
26 |
+
|
27 |
+
|
28 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_logical_location.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class LogicalLocation(object):
|
14 |
+
"""A logical location of a construct that produced a result."""
|
15 |
+
|
16 |
+
decorated_name: Optional[str] = dataclasses.field(
|
17 |
+
default=None, metadata={"schema_property_name": "decoratedName"}
|
18 |
+
)
|
19 |
+
fully_qualified_name: Optional[str] = dataclasses.field(
|
20 |
+
default=None, metadata={"schema_property_name": "fullyQualifiedName"}
|
21 |
+
)
|
22 |
+
index: int = dataclasses.field(
|
23 |
+
default=-1, metadata={"schema_property_name": "index"}
|
24 |
+
)
|
25 |
+
kind: Optional[str] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "kind"}
|
27 |
+
)
|
28 |
+
name: Optional[str] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "name"}
|
30 |
+
)
|
31 |
+
parent_index: int = dataclasses.field(
|
32 |
+
default=-1, metadata={"schema_property_name": "parentIndex"}
|
33 |
+
)
|
34 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
35 |
+
default=None, metadata={"schema_property_name": "properties"}
|
36 |
+
)
|
37 |
+
|
38 |
+
|
39 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_message.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class Message(object):
|
14 |
+
"""Encapsulates a message intended to be read by the end user."""
|
15 |
+
|
16 |
+
arguments: Optional[List[str]] = dataclasses.field(
|
17 |
+
default=None, metadata={"schema_property_name": "arguments"}
|
18 |
+
)
|
19 |
+
id: Optional[str] = dataclasses.field(
|
20 |
+
default=None, metadata={"schema_property_name": "id"}
|
21 |
+
)
|
22 |
+
markdown: Optional[str] = dataclasses.field(
|
23 |
+
default=None, metadata={"schema_property_name": "markdown"}
|
24 |
+
)
|
25 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "properties"}
|
27 |
+
)
|
28 |
+
text: Optional[str] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "text"}
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_multiformat_message_string.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class MultiformatMessageString(object):
|
14 |
+
"""A message string or message format string rendered in multiple formats."""
|
15 |
+
|
16 |
+
text: str = dataclasses.field(metadata={"schema_property_name": "text"})
|
17 |
+
markdown: Optional[str] = dataclasses.field(
|
18 |
+
default=None, metadata={"schema_property_name": "markdown"}
|
19 |
+
)
|
20 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
21 |
+
default=None, metadata={"schema_property_name": "properties"}
|
22 |
+
)
|
23 |
+
|
24 |
+
|
25 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_node.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_location,
|
11 |
+
_message,
|
12 |
+
_node,
|
13 |
+
_property_bag,
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class Node(object):
|
19 |
+
"""Represents a node in a graph."""
|
20 |
+
|
21 |
+
id: str = dataclasses.field(metadata={"schema_property_name": "id"})
|
22 |
+
children: Optional[List[_node.Node]] = dataclasses.field(
|
23 |
+
default=None, metadata={"schema_property_name": "children"}
|
24 |
+
)
|
25 |
+
label: Optional[_message.Message] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "label"}
|
27 |
+
)
|
28 |
+
location: Optional[_location.Location] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "location"}
|
30 |
+
)
|
31 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
32 |
+
default=None, metadata={"schema_property_name": "properties"}
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_notification.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Literal, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_exception,
|
11 |
+
_location,
|
12 |
+
_message,
|
13 |
+
_property_bag,
|
14 |
+
_reporting_descriptor_reference,
|
15 |
+
)
|
16 |
+
|
17 |
+
|
18 |
+
@dataclasses.dataclass
|
19 |
+
class Notification(object):
|
20 |
+
"""Describes a condition relevant to the tool itself, as opposed to being relevant to a target being analyzed by the tool."""
|
21 |
+
|
22 |
+
message: _message.Message = dataclasses.field(
|
23 |
+
metadata={"schema_property_name": "message"}
|
24 |
+
)
|
25 |
+
associated_rule: Optional[
|
26 |
+
_reporting_descriptor_reference.ReportingDescriptorReference
|
27 |
+
] = dataclasses.field(
|
28 |
+
default=None, metadata={"schema_property_name": "associatedRule"}
|
29 |
+
)
|
30 |
+
descriptor: Optional[
|
31 |
+
_reporting_descriptor_reference.ReportingDescriptorReference
|
32 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "descriptor"})
|
33 |
+
exception: Optional[_exception.Exception] = dataclasses.field(
|
34 |
+
default=None, metadata={"schema_property_name": "exception"}
|
35 |
+
)
|
36 |
+
level: Literal["none", "note", "warning", "error"] = dataclasses.field(
|
37 |
+
default="warning", metadata={"schema_property_name": "level"}
|
38 |
+
)
|
39 |
+
locations: Optional[List[_location.Location]] = dataclasses.field(
|
40 |
+
default=None, metadata={"schema_property_name": "locations"}
|
41 |
+
)
|
42 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
43 |
+
default=None, metadata={"schema_property_name": "properties"}
|
44 |
+
)
|
45 |
+
thread_id: Optional[int] = dataclasses.field(
|
46 |
+
default=None, metadata={"schema_property_name": "threadId"}
|
47 |
+
)
|
48 |
+
time_utc: Optional[str] = dataclasses.field(
|
49 |
+
default=None, metadata={"schema_property_name": "timeUtc"}
|
50 |
+
)
|
51 |
+
|
52 |
+
|
53 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_physical_location.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_address,
|
11 |
+
_artifact_location,
|
12 |
+
_property_bag,
|
13 |
+
_region,
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class PhysicalLocation(object):
|
19 |
+
"""A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of bytes or characters within that artifact."""
|
20 |
+
|
21 |
+
address: Optional[_address.Address] = dataclasses.field(
|
22 |
+
default=None, metadata={"schema_property_name": "address"}
|
23 |
+
)
|
24 |
+
artifact_location: Optional[
|
25 |
+
_artifact_location.ArtifactLocation
|
26 |
+
] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "artifactLocation"}
|
28 |
+
)
|
29 |
+
context_region: Optional[_region.Region] = dataclasses.field(
|
30 |
+
default=None, metadata={"schema_property_name": "contextRegion"}
|
31 |
+
)
|
32 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
33 |
+
default=None, metadata={"schema_property_name": "properties"}
|
34 |
+
)
|
35 |
+
region: Optional[_region.Region] = dataclasses.field(
|
36 |
+
default=None, metadata={"schema_property_name": "region"}
|
37 |
+
)
|
38 |
+
|
39 |
+
|
40 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_property_bag.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import List, Optional
|
8 |
+
|
9 |
+
|
10 |
+
@dataclasses.dataclass
|
11 |
+
class PropertyBag(object):
|
12 |
+
"""Key/value pairs that provide additional information about the object."""
|
13 |
+
|
14 |
+
tags: Optional[List[str]] = dataclasses.field(
|
15 |
+
default=None, metadata={"schema_property_name": "tags"}
|
16 |
+
)
|
17 |
+
|
18 |
+
|
19 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_rectangle.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _message, _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class Rectangle(object):
|
14 |
+
"""An area within an image."""
|
15 |
+
|
16 |
+
bottom: Optional[float] = dataclasses.field(
|
17 |
+
default=None, metadata={"schema_property_name": "bottom"}
|
18 |
+
)
|
19 |
+
left: Optional[float] = dataclasses.field(
|
20 |
+
default=None, metadata={"schema_property_name": "left"}
|
21 |
+
)
|
22 |
+
message: Optional[_message.Message] = dataclasses.field(
|
23 |
+
default=None, metadata={"schema_property_name": "message"}
|
24 |
+
)
|
25 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "properties"}
|
27 |
+
)
|
28 |
+
right: Optional[float] = dataclasses.field(
|
29 |
+
default=None, metadata={"schema_property_name": "right"}
|
30 |
+
)
|
31 |
+
top: Optional[float] = dataclasses.field(
|
32 |
+
default=None, metadata={"schema_property_name": "top"}
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_region.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_content,
|
11 |
+
_message,
|
12 |
+
_property_bag,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class Region(object):
|
18 |
+
"""A region within an artifact where a result was detected."""
|
19 |
+
|
20 |
+
byte_length: Optional[int] = dataclasses.field(
|
21 |
+
default=None, metadata={"schema_property_name": "byteLength"}
|
22 |
+
)
|
23 |
+
byte_offset: int = dataclasses.field(
|
24 |
+
default=-1, metadata={"schema_property_name": "byteOffset"}
|
25 |
+
)
|
26 |
+
char_length: Optional[int] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "charLength"}
|
28 |
+
)
|
29 |
+
char_offset: int = dataclasses.field(
|
30 |
+
default=-1, metadata={"schema_property_name": "charOffset"}
|
31 |
+
)
|
32 |
+
end_column: Optional[int] = dataclasses.field(
|
33 |
+
default=None, metadata={"schema_property_name": "endColumn"}
|
34 |
+
)
|
35 |
+
end_line: Optional[int] = dataclasses.field(
|
36 |
+
default=None, metadata={"schema_property_name": "endLine"}
|
37 |
+
)
|
38 |
+
message: Optional[_message.Message] = dataclasses.field(
|
39 |
+
default=None, metadata={"schema_property_name": "message"}
|
40 |
+
)
|
41 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
42 |
+
default=None, metadata={"schema_property_name": "properties"}
|
43 |
+
)
|
44 |
+
snippet: Optional[_artifact_content.ArtifactContent] = dataclasses.field(
|
45 |
+
default=None, metadata={"schema_property_name": "snippet"}
|
46 |
+
)
|
47 |
+
source_language: Optional[str] = dataclasses.field(
|
48 |
+
default=None, metadata={"schema_property_name": "sourceLanguage"}
|
49 |
+
)
|
50 |
+
start_column: Optional[int] = dataclasses.field(
|
51 |
+
default=None, metadata={"schema_property_name": "startColumn"}
|
52 |
+
)
|
53 |
+
start_line: Optional[int] = dataclasses.field(
|
54 |
+
default=None, metadata={"schema_property_name": "startLine"}
|
55 |
+
)
|
56 |
+
|
57 |
+
|
58 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_replacement.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_artifact_content,
|
11 |
+
_property_bag,
|
12 |
+
_region,
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
@dataclasses.dataclass
|
17 |
+
class Replacement(object):
|
18 |
+
"""The replacement of a single region of an artifact."""
|
19 |
+
|
20 |
+
deleted_region: _region.Region = dataclasses.field(
|
21 |
+
metadata={"schema_property_name": "deletedRegion"}
|
22 |
+
)
|
23 |
+
inserted_content: Optional[_artifact_content.ArtifactContent] = dataclasses.field(
|
24 |
+
default=None, metadata={"schema_property_name": "insertedContent"}
|
25 |
+
)
|
26 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
27 |
+
default=None, metadata={"schema_property_name": "properties"}
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_configuration.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Literal, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import _property_bag
|
10 |
+
|
11 |
+
|
12 |
+
@dataclasses.dataclass
|
13 |
+
class ReportingConfiguration(object):
|
14 |
+
"""Information about a rule or notification that can be configured at runtime."""
|
15 |
+
|
16 |
+
enabled: bool = dataclasses.field(
|
17 |
+
default=True, metadata={"schema_property_name": "enabled"}
|
18 |
+
)
|
19 |
+
level: Literal["none", "note", "warning", "error"] = dataclasses.field(
|
20 |
+
default="warning", metadata={"schema_property_name": "level"}
|
21 |
+
)
|
22 |
+
parameters: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
23 |
+
default=None, metadata={"schema_property_name": "parameters"}
|
24 |
+
)
|
25 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
26 |
+
default=None, metadata={"schema_property_name": "properties"}
|
27 |
+
)
|
28 |
+
rank: float = dataclasses.field(
|
29 |
+
default=-1.0, metadata={"schema_property_name": "rank"}
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
+
# flake8: noqa
|
venv/lib/python3.10/site-packages/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_descriptor.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29,
|
2 |
+
# with extension for dataclasses and type annotation.
|
3 |
+
|
4 |
+
from __future__ import annotations
|
5 |
+
|
6 |
+
import dataclasses
|
7 |
+
from typing import Any, List, Optional
|
8 |
+
|
9 |
+
from torch.onnx._internal.diagnostics.infra.sarif import (
|
10 |
+
_multiformat_message_string,
|
11 |
+
_property_bag,
|
12 |
+
_reporting_configuration,
|
13 |
+
_reporting_descriptor_relationship,
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class ReportingDescriptor(object):
|
19 |
+
"""Metadata that describes a specific report produced by the tool, as part of the analysis it provides or its runtime reporting."""
|
20 |
+
|
21 |
+
id: str = dataclasses.field(metadata={"schema_property_name": "id"})
|
22 |
+
default_configuration: Optional[
|
23 |
+
_reporting_configuration.ReportingConfiguration
|
24 |
+
] = dataclasses.field(
|
25 |
+
default=None, metadata={"schema_property_name": "defaultConfiguration"}
|
26 |
+
)
|
27 |
+
deprecated_guids: Optional[List[str]] = dataclasses.field(
|
28 |
+
default=None, metadata={"schema_property_name": "deprecatedGuids"}
|
29 |
+
)
|
30 |
+
deprecated_ids: Optional[List[str]] = dataclasses.field(
|
31 |
+
default=None, metadata={"schema_property_name": "deprecatedIds"}
|
32 |
+
)
|
33 |
+
deprecated_names: Optional[List[str]] = dataclasses.field(
|
34 |
+
default=None, metadata={"schema_property_name": "deprecatedNames"}
|
35 |
+
)
|
36 |
+
full_description: Optional[
|
37 |
+
_multiformat_message_string.MultiformatMessageString
|
38 |
+
] = dataclasses.field(
|
39 |
+
default=None, metadata={"schema_property_name": "fullDescription"}
|
40 |
+
)
|
41 |
+
guid: Optional[str] = dataclasses.field(
|
42 |
+
default=None, metadata={"schema_property_name": "guid"}
|
43 |
+
)
|
44 |
+
help: Optional[
|
45 |
+
_multiformat_message_string.MultiformatMessageString
|
46 |
+
] = dataclasses.field(default=None, metadata={"schema_property_name": "help"})
|
47 |
+
help_uri: Optional[str] = dataclasses.field(
|
48 |
+
default=None, metadata={"schema_property_name": "helpUri"}
|
49 |
+
)
|
50 |
+
message_strings: Any = dataclasses.field(
|
51 |
+
default=None, metadata={"schema_property_name": "messageStrings"}
|
52 |
+
)
|
53 |
+
name: Optional[str] = dataclasses.field(
|
54 |
+
default=None, metadata={"schema_property_name": "name"}
|
55 |
+
)
|
56 |
+
properties: Optional[_property_bag.PropertyBag] = dataclasses.field(
|
57 |
+
default=None, metadata={"schema_property_name": "properties"}
|
58 |
+
)
|
59 |
+
relationships: Optional[
|
60 |
+
List[_reporting_descriptor_relationship.ReportingDescriptorRelationship]
|
61 |
+
] = dataclasses.field(
|
62 |
+
default=None, metadata={"schema_property_name": "relationships"}
|
63 |
+
)
|
64 |
+
short_description: Optional[
|
65 |
+
_multiformat_message_string.MultiformatMessageString
|
66 |
+
] = dataclasses.field(
|
67 |
+
default=None, metadata={"schema_property_name": "shortDescription"}
|
68 |
+
)
|
69 |
+
|
70 |
+
|
71 |
+
# flake8: noqa
|