repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
pytorch
pytorch-main/torch/jit/_async.py
"""Async API This module contains the API for parallelism in TorchScript, notably: * torch.jit.fork * torch.jit.wait This is not intended to be imported directly; please use the exposed functionalities in `torch.jit`. """ import torch from torch.utils import set_module from torch.jit._builtins import _regist...
3,789
36.9
102
py
pytorch
pytorch-main/torch/jit/_await.py
import torch from torch.utils import set_module from torch.jit._builtins import _register_builtin from torch._jit_internal import _Await set_module(_Await, "torch.jit") def _awaitable(func, *args, **kwargs): r""" Creates Await object that will call specified functioni with specified args, when it is requ...
863
26
80
py
pytorch
pytorch-main/torch/jit/_builtins.py
import math import cmath import warnings import torch import torch.backends.cudnn as cudnn from ..nn.modules.utils import _single, _pair, _triple, _quadruple, _list_with_default from collections import OrderedDict from typing import Dict, Optional _builtin_table: Optional[Dict[int, str]] = None _modules_containing...
6,424
37.244048
183
py
pytorch
pytorch-main/torch/jit/_trace.py
"""Tracing This module contains functionality to support the JIT's tracing frontend, notably: * torch.jit.trace * torch.jit.trace_module This is not intended to be imported directly; please use the exposed functionalities in `torch.jit`. """ import torch import copy import os import contextlib import functoo...
51,187
39.2738
130
py
pytorch
pytorch-main/torch/jit/unsupported_tensor_ops.py
import torch.jit from textwrap import dedent from typing import Dict, Any def execWrapper(code, glob, loc): exec(code, glob, loc) def _gen_unsupported_methods_properties(): tensor_attrs = set(filter(lambda x: x[0] != "_", dir(torch.Tensor))) tensor = torch.tensor([2]) funcs_template = dedent(''' ...
1,819
31.5
118
py
pytorch
pytorch-main/torch/jit/_check.py
import ast import inspect import textwrap import torch import warnings class AttributeTypeIsSupportedChecker(ast.NodeVisitor): """ Checks the ``__init__`` method of a given ``nn.Module`` to ensure that all instance-level attributes can be properly initialized. Specifically, we do type inference based...
9,193
37.957627
100
py
pytorch
pytorch-main/torch/jit/_monkeytype_config.py
import torch import inspect import typing import pathlib import sys from typing import Optional, Iterable, List, Dict from collections import defaultdict from types import CodeType _IS_MONKEYTYPE_INSTALLED = True try: import monkeytype # type: ignore[import] from monkeytype import trace as monkeytype_trace ...
7,129
37.75
111
py
pytorch
pytorch-main/torch/jit/__init__.py
import torch._C from contextlib import contextmanager from typing import Iterator, Any import warnings from torch.utils import set_module # These are imported so users can access them from the `torch.jit` module from torch._jit_internal import ( Final, Future, _Await, _drop, _IgnoreContextManager...
8,239
27.912281
109
py
pytorch
pytorch-main/torch/jit/_decompositions.py
import torch from torch import Tensor aten = torch.ops.aten from typing import Optional, List, Dict, Set import inspect import warnings from torch.types import Number decomposition_table: Dict[str, torch.jit.ScriptFunction] = {} function_name_set: Set[str] = set() def check_decomposition_has_type_annotations(f): ...
4,115
34.482759
113
py
pytorch
pytorch-main/torch/jit/_state.py
"""JIT-related state This module stores various pieces of Python-global state relating to the JIT. This is not intended to be imported directly; please the exposed functionalities in `torch.jit`. """ import torch import os import weakref class EnabledProxy: """Stores whether the JIT is enabled or not. This ...
3,651
29.433333
87
py
pytorch
pytorch-main/torch/jit/_fuser.py
import contextlib import torch from typing import List, Tuple @contextlib.contextmanager def optimized_execution(should_optimize): """ A context manager that controls whether the JIT's executor will run optimizations before executing a function. """ stored_flag = torch._C._get_graph_executor_optim...
7,028
42.658385
106
py
pytorch
pytorch-main/torch/jit/_script.py
"""TorchScript This module contains functionality to support the JIT's scripting frontend, notably: - torch.jit.script This is not intended to be imported directly; please use the exposed functionalities in `torch.jit`. """ import functools import collections import enum import inspect import copy import pickle i...
61,832
37.986759
128
py
pytorch
pytorch-main/torch/jit/frontend.py
import torch import sys import ast import dataclasses import inspect import string import re from collections import namedtuple from textwrap import dedent from typing import List, Tuple # noqa: F401 from torch._C._jit_tree_views import ( ClassDef, Ident, Stmt, Decl, Def, Var, EmptyTypeAnnotation, Param, ExprS...
42,820
39.550189
119
py
pytorch
pytorch-main/torch/jit/mobile/__init__.py
import torch from torch.jit._serialization import validate_map_location import pathlib import os def _load_for_lite_interpreter(f, map_location=None): r""" Load a :class:`LiteScriptModule` saved with :func:`torch.jit._save_for_lite_interpreter` Args: f: a file-like object (has to implement r...
8,063
35.990826
102
py
pytorch
pytorch-main/torch/jit/_passes/_property_propagation.py
""" Tools to help with tensor property propagation. This is not intended to be imported directly; please use the exposed functionalities in `torch.jit`. """ from typing import Any, List import torch from torch import TensorType from torch._C import Graph def apply_input_props_using_example(graph: Graph, example_in...
1,375
31.761905
95
py
pytorch
pytorch-main/torch/_refs/fft.py
import math from typing import Iterable, List, Literal, NamedTuple, Optional, Sequence, Tuple, Union import torch import torch._prims as prims import torch._prims_common as utils from torch._decomp import register_decomposition from torch._prims_common import DimsType, ShapeType, TensorLikeType from torch._prims_comm...
17,194
29.113835
94
py
pytorch
pytorch-main/torch/_refs/_conversions.py
import torch import torch._prims_common as utils # Utilities should come BEFORE this import from torch._decomp import register_decomposition from torch._prims_common import TensorLikeType from torch._prims_common.wrappers import out_wrapper from torch._refs import _broadcast_shapes # Data conversion references. # # ...
3,506
28.470588
90
py
pytorch
pytorch-main/torch/_refs/__init__.py
import builtins import collections import inspect import math import operator import warnings from collections.abc import Iterable from enum import Enum from functools import partial, reduce, singledispatch, wraps from typing import Callable, List, Optional, overload, Sequence, Tuple, Union import torch import torch...
178,113
30.474465
128
py
pytorch
pytorch-main/torch/_refs/nn/functional/__init__.py
import math from functools import wraps from typing import Callable, Optional, Union import torch import torch._prims as prims import torch._prims_common as utils import torch._refs as refs from torch._decomp import register_decomposition from torch._prims_common import ( ELEMENTWISE_TYPE_PROMOTION_KIND, Numbe...
39,020
31.901349
116
py
pytorch
pytorch-main/torch/_refs/linalg/__init__.py
from functools import partial from typing import List, Optional, Tuple, Union import torch import torch._prims as prims import torch._prims_common as utils import torch._refs as refs import torch._refs.linalg as linalg from torch import Tensor from torch._prims_common import ( check_fp_or_complex, check_is_...
8,961
33.469231
121
py
pytorch
pytorch-main/torch/_refs/special/__init__.py
import math from typing import Optional, Union import torch import torch._prims as prims import torch._prims_common as utils import torch._refs as refs from torch import Tensor from torch._decomp import register_decomposition from torch._prims_common import ( ELEMENTWISE_TYPE_PROMOTION_KIND, Number, Numbe...
6,753
27.49789
99
py
pytorch
pytorch-main/torch/special/__init__.py
import torch from torch._C import _add_docstr, _special # type: ignore[attr-defined] from torch._torch_docs import common_args, multi_dim_common __all__ = [ 'airy_ai', 'bessel_j0', 'bessel_j1', 'bessel_y0', 'bessel_y1', 'chebyshev_polynomial_t', 'chebyshev_polynomial_u', 'chebyshev_pol...
32,694
24.463396
118
py
pytorch
pytorch-main/torch/_functorch/top_operators_github_usage.py
""" From https://docs.google.com/spreadsheets/d/12R3nCOLskxPYjjiNkdqy4OdQ65eQp_htebXGODsjSeA/edit#gid=0 Try to keep this list in sync with that. """ top_torch = [ ("t", 6837449), ("tensor", 585786), ("mode", 462182), ("cat", 394818), ("max", 368038), ("zeros", 329495), ("load", 327756), ...
21,376
33.258013
99
py
pytorch
pytorch-main/torch/_functorch/make_functional.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import copy from typing import ( Any, Callable, Dict, Iterable, List, NoReturn, Seque...
22,759
35.948052
111
py
pytorch
pytorch-main/torch/_functorch/deprecated.py
import torch._functorch.vmap as _vmap_impl import torch._functorch.eager_transforms as _impl import torch._functorch.apis as apis import torch._functorch.make_functional as _nn_impl from torch._functorch.vmap import in_dims_t, out_dims_t from torch._functorch.eager_transforms import argnums_t import torch.nn as nn impo...
5,128
39.385827
104
py
pytorch
pytorch-main/torch/_functorch/pytree_hacks.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from torch.utils._pytree import tree_flatten, tree_unflatten def tree_map_(fn_, pytree): flat_args, _ = tre...
612
23.52
71
py
pytorch
pytorch-main/torch/_functorch/batch_norm_replacement.py
import torch.nn as nn from torch._functorch.utils import exposed_in def batch_norm_without_running_stats(module: nn.Module): if isinstance(module, nn.modules.batchnorm._BatchNorm) and module.track_running_stats: module.running_mean = None module.running_var = None module.num_batches_tracke...
825
32.04
100
py
pytorch
pytorch-main/torch/_functorch/partitioners.py
from torch.fx.experimental.proxy_tensor import is_sym_node, py_sym_types from torch.fx.experimental.symbolic_shapes import ( hint_int, magic_methods, method_to_operator, free_symbols, is_symbol_binding_fx_node, find_symbol_binding_fx_nodes ) import torch import torch.fx as fx import operator import math import ...
38,861
41.611842
976
py
pytorch
pytorch-main/torch/_functorch/benchmark_utils.py
import contextlib import time import os import json import torch from torch.profiler import profile, ProfilerActivity def synchronize(): pass def dump_chrome_trace(f, input, trace_filename, optimize_ctx, activities, num_runs=1, devices=None, kwargs_for_f=None, kwargs_for_profiler=None): ...
6,086
30.376289
117
py
pytorch
pytorch-main/torch/_functorch/compile_utils.py
import torch import torch.fx as fx from torch.utils._pytree import tree_flatten aten = torch.ops.aten def get_aten_target(node): if hasattr(node.target, 'overloadpacket'): return node.target.overloadpacket return node.target rand_ops = [aten.dropout, aten._fused_dropout, aten._standard_gamma, ...
3,532
37.824176
109
py
pytorch
pytorch-main/torch/_functorch/functional_call.py
from collections import Counter from typing import Any, Dict, List, Optional, Sequence, Tuple, Union import torch import torch.nn as nn from torch import Tensor from torch._functorch.utils import exposed_in @exposed_in("torch.func") def functional_call( module: "torch.nn.Module", parameter_and_buffer_dicts: ...
10,376
40.674699
122
py
pytorch
pytorch-main/torch/_functorch/python_key.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. __all__ = ["make_fx", "dispatch_trace", "PythonKeyTracer", "pythonkey_decompose"] from torch.fx.experimental.proxy...
420
41.1
98
py
pytorch
pytorch-main/torch/_functorch/utils.py
import contextlib import torch from torch._C._functorch import ( set_single_level_autograd_function_allowed, get_single_level_autograd_function_allowed, unwrap_if_dead, ) @contextlib.contextmanager def enable_single_level_autograd_function(): try: prev_state = get_single_level_autograd_function...
1,311
32.641026
87
py
pytorch
pytorch-main/torch/_functorch/pyfunctorch.py
from abc import ABC, abstractmethod import contextlib from typing import Any import torch import torch.utils._pytree as pytree from torch._C._functorch import ( TransformType, RandomnessType, CInterpreter, CGradInterpreterPtr, CFunctionalizeInterpreterPtr, CVmapInterpreterPtr, CJvpInterprete...
8,007
35.56621
90
py
pytorch
pytorch-main/torch/_functorch/aot_autograd.py
import collections import dataclasses import itertools import logging import warnings import pprint from contextlib import contextmanager, nullcontext from dataclasses import dataclass from enum import Enum from functools import partial, wraps from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union, N...
187,674
44.964977
132
py
pytorch
pytorch-main/torch/_functorch/config.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Global flags for aot autograd """ import os import sys # Converts torch rng ops to their functional philox r...
1,219
28.756098
78
py
pytorch
pytorch-main/torch/_functorch/eager_transforms.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Union, Tuple, List, Any, Optional import torch from functools import partial, wraps ...
69,988
41.780562
118
py
pytorch
pytorch-main/torch/_functorch/apis.py
# NOTE: We allow Dynamo to see this file (via torch/_dynamo/skipfiles.py) so that it can # trace through `grad`. # Currently, we can't allow Dynamo to see `eager_transforms.py` as that break a lot of thing # and there isn't a mechanism to selectively expose only some functions (eg. grad) from a file #...
4,743
42.925926
100
py
pytorch
pytorch-main/torch/_functorch/vmap.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch import functools from torch import Tensor from typing import Any, Callable, Optional, Tuple, Union, ...
29,180
42.16716
119
py
pytorch
pytorch-main/torch/_functorch/fx_minifier.py
import torch.fx as fx import copy import torch import math import sys from typing import Callable, List from functools import wraps, partial from dataclasses import dataclass from .compile_utils import get_placeholders, get_outputs from torch.utils._content_store import ContentStoreWriter from torch.hub import tqdm fro...
15,938
36.415493
113
py
pytorch
pytorch-main/torch/_functorch/compilers.py
import copy import logging import os import pickle import random from contextlib import contextmanager from functools import partial from typing import Callable, Union import sympy import torch from torch import SymInt import torch.fx as fx import torch.nn as nn from torch._decomp import get_decompositions from torch....
14,039
30.764706
150
py
pytorch
pytorch-main/torch/_functorch/autograd_function.py
import torch from torch._ops import HigherOrderOperator from torch._C._functorch import TransformType from torch._functorch.utils import enable_single_level_autograd_function import torch.utils._pytree as pytree from torch._C._functorch import ( _wrap_for_grad, _unwrap_for_grad, current_level, ) from torch....
25,183
38.659843
102
py
pytorch
pytorch-main/torch/monitor/__init__.py
from torch._C._monitor import * # noqa: F403 from typing import TYPE_CHECKING if TYPE_CHECKING: from torch.utils.tensorboard import SummaryWriter STAT_EVENT = "torch.monitor.Stat" class TensorboardEventHandler: """ TensorboardEventHandler is an event handler that will write known events to the pr...
1,213
30.947368
85
py
pytorch
pytorch-main/torch/mps/__init__.py
r""" This package enables an interface for accessing MPS (Metal Performance Shaders) backend in Python. Metal is Apple's API for programming metal GPU (graphics processor unit). Using MPS means that increased performance can be achieved, by running work on the metal GPU(s). See https://developer.apple.com/documentation...
4,200
37.190909
104
py
pytorch
pytorch-main/torch/mps/profiler.py
import torch import contextlib __all__ = ["start", "stop", "profile"] def start(mode: str = "interval", wait_until_completed: bool = False) -> None: r"""Start OS Signpost tracing from MPS backend. The generated OS Signposts could be recorded and viewed in XCode Instruments Logging tool. Args: ...
2,341
40.821429
86
py
pytorch
pytorch-main/torch/onnx/operators.py
r"""This file provides a location for operators that help exporting models via onnx. E.g. `shape_as_tensor` and `reshape_from_tensor_shape` are to make all dynamic sizes operations traceable. NOTE: at one point these functions were implemented differently. Since then we have implemented these directly in ATen, so thi...
560
25.714286
84
py
pytorch
pytorch-main/torch/onnx/_type_utils.py
"""Utilities for converting and operating on ONNX, JIT and torch types.""" from __future__ import annotations import enum import typing from typing import Dict, Literal, Optional, Union import torch from torch._C import _onnx as _C_onnx from torch.onnx import errors from torch.onnx._internal import _beartype if typi...
11,773
33.326531
125
py
pytorch
pytorch-main/torch/onnx/symbolic_helper.py
from __future__ import annotations import functools import inspect import sys import typing import warnings from typing import ( Any, Callable, List, Literal, NoReturn, Optional, Sequence, Set, Tuple, Union, ) import torch import torch._C._onnx as _C_onnx from torch import _C ...
63,356
33.302653
115
py
pytorch
pytorch-main/torch/onnx/symbolic_opset16.py
"""This file exports ONNX ops for opset 16. Note [ONNX Operators that are added/updated in opset 16] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ https://github.com/onnx/onnx/blob/main/docs/Changelog.md#version-16-of-the-default-onnx-operator-set New operators: GridSample https://github.com/onnx/onnx/...
6,565
33.925532
118
py
pytorch
pytorch-main/torch/onnx/symbolic_opset14.py
"""This file exports ONNX ops for opset 14. Note [ONNX operators that are added/updated in opset 14] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New operators: HardSwish, Trilu Updated operators: Reshape Add, Sub, Mul, Div GRU, LSTM, RNN BatchNorm, Cumsum, Relu """ # EDITING THIS FIL...
9,228
31.72695
139
py
pytorch
pytorch-main/torch/onnx/symbolic_opset9.py
"""This file exports ONNX ops for opset 9. Opset 9 is supported by ONNX release 1.4.1 release on 01/23/19 """ from __future__ import annotations import builtins import functools import math import sys import warnings from typing import Callable, List, Optional, Sequence, Tuple, Union import torch import torch._C._on...
240,458
32.415648
128
py
pytorch
pytorch-main/torch/onnx/symbolic_opset8.py
""" Note [ONNX operators that are added/updated from opset 8 to opset 9] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New operators: Compress ConstantOfShape EyeLike MaxUnpool OneHot Sinh Cosh Asinh Acosh Atanh Shrink IsNaN Sign Erf Sca...
15,059
30.974522
110
py
pytorch
pytorch-main/torch/onnx/symbolic_opset12.py
from __future__ import annotations import functools import sys from typing import Optional, Tuple import torch from torch._C import _onnx as _C_onnx from torch.onnx import ( _type_utils, errors, symbolic_helper, symbolic_opset9 as opset9, utils, ) from torch.onnx._internal import _beartype, jit_ut...
16,193
32.320988
107
py
pytorch
pytorch-main/torch/onnx/errors.py
"""ONNX exporter exceptions.""" from __future__ import annotations import textwrap from typing import Optional from torch import _C from torch.onnx import _constants from torch.onnx._internal import diagnostics __all__ = [ "OnnxExporterError", "OnnxExporterWarning", "CheckerError", "UnsupportedOperat...
3,582
32.485981
89
py
pytorch
pytorch-main/torch/onnx/symbolic_opset11.py
"""This file exports ONNX ops for opset 11.""" from __future__ import annotations import functools import sys import warnings from typing import Optional, Sequence, Union import torch from torch import _C from torch._C import _onnx as _C_onnx from torch.onnx import ( _type_utils, errors, symbolic_helper, ...
61,599
35.04447
126
py
pytorch
pytorch-main/torch/onnx/symbolic_opset17.py
"""This file exports ONNX ops for opset 17. Note [ONNX Operators that are added/updated in opset 17] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ https://github.com/onnx/onnx/blob/main/docs/Changelog.md#version-17-of-the-default-onnx-operator-set New operators: BlackmanWindow DFT HammingWindow...
6,773
32.534653
100
py
pytorch
pytorch-main/torch/onnx/symbolic_opset7.py
""" Note [ONNX operators that are added/updated from opset 7 to opset 8] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New operators: Expand Updated operators: Min, Max, Sum, Mean: supports multidirectional broadcasting. MaxPool: added optional indices output. Scan """ import functools ...
2,091
30.223881
90
py
pytorch
pytorch-main/torch/onnx/utils.py
"""Functions to export models into the ONNX IR format. These models can be loaded with the ONNX library and then converted to models which run on other deep learning frameworks. """ from __future__ import annotations import contextlib import copy import inspect import io import re import textwrap import typing import...
81,428
38.054676
120
py
pytorch
pytorch-main/torch/onnx/symbolic_caffe2.py
import importlib import inspect from torch.onnx import symbolic_helper, symbolic_opset9 as opset9 from torch.onnx._internal import jit_utils, registration def register_quantized_ops(domain: str, version: int): # Register all quantized ops module = importlib.import_module("torch.onnx.symbolic_caffe2") qua...
10,908
29.302778
108
py
pytorch
pytorch-main/torch/onnx/symbolic_opset18.py
"""This file exports ONNX ops for opset 18. Note [ONNX Operators that are added/updated in opset 18] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ https://github.com/onnx/onnx/blob/main/docs/Changelog.md#version-18-of-the-default-onnx-operator-set New operators: CenterCropPad Col2Im Mish Op...
1,736
23.464789
100
py
pytorch
pytorch-main/torch/onnx/symbolic_opset10.py
import functools import sys import warnings from typing import Callable, List, Optional, Union import torch import torch._C._onnx as _C_onnx import torch.onnx from torch import _C # Monkey-patch graph manipulation methods on Graph, used for the ONNX symbolics from torch.onnx import ( _constants, _type_utils, ...
33,290
30.949136
128
py
pytorch
pytorch-main/torch/onnx/_exporter_states.py
from __future__ import annotations from typing import Dict from torch import _C class ExportTypes: r"""Specifies how the ONNX model is stored.""" PROTOBUF_FILE = "Saves model in the specified protobuf file." ZIP_ARCHIVE = "Saves model in the specified ZIP file (uncompressed)." COMPRESSED_ZIP_ARCHIV...
1,365
33.15
105
py
pytorch
pytorch-main/torch/onnx/_onnx_supported_ops.py
import inspect from typing import Dict, List, Union from torch import _C from torch.onnx import _constants from torch.onnx._internal import registration class _TorchSchema: def __init__(self, schema: Union[_C.FunctionSchema, str]) -> None: if isinstance(schema, _C.FunctionSchema): self.name: ...
3,304
32.72449
88
py
pytorch
pytorch-main/torch/onnx/verification.py
"""Functions to verify exported ONNX model is functionally equivalent to original PyTorch model. ONNX Runtime is required, and is used as the ONNX backend for export verification. """ from __future__ import annotations import contextlib import copy import dataclasses import datetime import difflib import enum import...
69,953
36.110875
107
py
pytorch
pytorch-main/torch/onnx/_globals.py
"""Globals used internally by the ONNX exporter. Do not use this module outside of `torch.onnx` and its tests. Be very judicious when adding any new global variables. Do not create new global variables unless they are absolutely necessary. """ import torch._C._onnx as _C_onnx # This module should only depend on _con...
2,968
33.523256
85
py
pytorch
pytorch-main/torch/onnx/__init__.py
"""ONNX exporter.""" from torch import _C from torch._C import _onnx as _C_onnx from torch._C._onnx import ( _CAFFE2_ATEN_FALLBACK, OperatorExportTypes, TensorProtoDataType, TrainingMode, ) from . import ( # usort:skip. Keep the order instead of sorting lexicographically _deprecation, errors,...
3,820
23.651613
93
py
pytorch
pytorch-main/torch/onnx/_constants.py
"""Constant values used in ONNX.""" ONNX_ARCHIVE_MODEL_PROTO_NAME = "__MODEL_PROTO" ONNX_BASE_OPSET = 9 ONNX_MIN_OPSET = 7 ONNX_MAX_OPSET = 18 # ONNX_DEFAULT_OPSET generated by tools/onnx/update_default_opset_version.py ONNX_DEFAULT_OPSET = 14 ONNX_CONSTANT_FOLDING_MIN_OPSET = 9 PYTORCH_GITHUB_ISSUES_URL = "https://...
567
21.72
76
py
pytorch
pytorch-main/torch/onnx/_experimental.py
"""Experimental classes and functions used by ONNX export.""" import dataclasses from typing import Mapping, Optional, Sequence, Set, Type, Union import torch import torch._C._onnx as _C_onnx @dataclasses.dataclass class ExportOptions: """Arguments used by :func:`torch.onnx.export`. TODO: Adopt this in `to...
1,042
34.965517
88
py
pytorch
pytorch-main/torch/onnx/symbolic_opset15.py
"""This file exports ONNX ops for opset 15. Note [ONNX operators that are added/updated in opset 15] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ https://github.com/onnx/onnx/blob/master/docs/Changelog.md#version-15-of-the-default-onnx-operator-set New operators: Bernoulli CastLike Optional ...
2,935
34.373494
102
py
pytorch
pytorch-main/torch/onnx/symbolic_opset13.py
# EDITING THIS FILE? READ THIS FIRST! # see Note [Edit Symbolic Files] in README.md # This file exports ONNX ops for opset 13 import functools import torch import torch._C._onnx as _C_onnx from torch.onnx import ( _constants, _type_utils, errors, symbolic_helper, symbolic_opset11 as opset11, s...
41,287
35.377093
141
py
pytorch
pytorch-main/torch/onnx/_internal/exporter.py
# necessary to surface onnx.ModelProto through ExportOutput: from __future__ import annotations import abc import contextlib import dataclasses import io import logging import os from typing import ( Any, Callable, Dict, Final, Mapping, Optional, Protocol, runtime_checkable, Sequen...
35,255
38.129856
121
py
pytorch
pytorch-main/torch/onnx/_internal/registration.py
"""Module for handling symbolic function registration.""" import warnings from typing import ( Callable, Collection, Dict, Generic, Optional, Sequence, Set, TypeVar, Union, ) from torch.onnx import _constants, errors from torch.onnx._internal import _beartype OpsetVersion = int ...
11,072
31.567647
110
py
pytorch
pytorch-main/torch/onnx/_internal/jit_utils.py
"""Utilities for manipulating the torch.Graph object and the torchscript.""" from __future__ import annotations # TODO(justinchuby): Move more of the symbolic helper functions here and expose # them to the user. import dataclasses import re import typing from typing import Any, Dict, Iterable, Optional, Sequence, Tup...
14,778
35.9475
118
py
pytorch
pytorch-main/torch/onnx/_internal/io_adapter.py
from __future__ import annotations import inspect from typing import ( Any, Callable, List, Mapping, Optional, Protocol, runtime_checkable, Sequence, Tuple, Union, ) import torch from torch.onnx._internal import _beartype from torch.utils import _pytree as pytree # TODO(bowb...
14,920
33.539352
105
py
pytorch
pytorch-main/torch/onnx/_internal/onnx_proto_utils.py
"""Utilities for manipulating the onnx and onnx-script dependencies and ONNX proto.""" from __future__ import annotations import glob import io import os import shutil import zipfile from typing import Any, List, Mapping, Set, Tuple, Union import torch import torch.jit._trace import torch.serialization from torch.on...
11,169
36.864407
110
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/_rules.py
""" GENERATED CODE - DO NOT EDIT DIRECTLY This file is generated by gen_diagnostics.py. See tools/onnx/gen_diagnostics.py for more information. Diagnostic rules for PyTorch ONNX export. """ import dataclasses from typing import Tuple # flake8: noqa from torch.onnx._internal.diagnostics import infra """ GENERATED CO...
50,174
46.604364
1,589
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/_diagnostic.py
"""Diagnostic components for TorchScript based ONNX export, i.e. `torch.onnx.export`.""" from __future__ import annotations import contextlib import gzip from collections.abc import Generator from typing import List, Optional, Type import torch from torch.onnx._internal.diagnostics import infra from torch.onnx._inte...
7,557
34.153488
93
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/decorator.py
from __future__ import annotations import functools import traceback from typing import Any, Callable, Dict, Optional, Tuple, Type from torch.onnx._internal import _beartype from torch.onnx._internal.diagnostics import infra from torch.onnx._internal.diagnostics.infra import formatter, utils MessageFormatterType = ...
5,382
34.886667
92
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/context.py
"""A diagnostic context based on SARIF.""" from __future__ import annotations import contextlib import dataclasses import gzip import logging from typing import Callable, Generator, List, Literal, Mapping, Optional, TypeVar from torch.onnx._internal.diagnostics import infra from torch.onnx._internal.diagnostics.i...
13,322
36.111421
102
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/utils.py
from __future__ import annotations import functools import inspect import traceback from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple from torch.onnx._internal import _beartype from torch.onnx._internal.diagnostics.infra import _infra, formatter @_beartype.beartype def python_frame(frame: ...
2,507
32
90
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/_infra.py
"""This file defines an additional layer of abstraction on top of the SARIF OM.""" from __future__ import annotations import dataclasses import enum import pprint from typing import FrozenSet, List, Mapping, Optional, Sequence, Tuple from torch.onnx._internal.diagnostics.infra import formatter, sarif class Level(e...
11,112
33.088957
91
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/formatter.py
from __future__ import annotations import dataclasses import json import re from typing import Any, Callable, Dict, List, Optional, Union from torch.onnx._internal import _beartype from torch.onnx._internal.diagnostics.infra import sarif # A list of types in the SARIF module to support pretty printing. # This is so...
3,334
24.265152
83
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_multiformat_message_string.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Optional from torch.onnx._internal.diagnostics.infra.sarif import _property_bag @dataclasses.dataclass clas...
805
30
81
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_translation_metadata.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _multiformat_message_string, _pro...
1,494
32.222222
80
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_exception.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import List, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _exception, _property_bag, ...
1,168
29.763158
93
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_location.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import List, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _location_relationship, _lo...
1,610
30.588235
84
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_rectangle.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Optional from torch.onnx._internal.diagnostics.infra.sarif import _message, _property_bag @dataclasses.data...
1,159
30.351351
80
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_tool_component.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Any, List, Literal, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _artifact_locatio...
4,987
39.225806
90
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_conversion.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import List, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _artifact_location, _invoca...
1,162
31.305556
153
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_physical_location.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _address, _artifact_location, ...
1,337
31.634146
166
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_suppression.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Literal, Optional from torch.onnx._internal.diagnostics.infra.sarif import _location, _property_bag @datacl...
1,249
32.783784
88
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_code_flow.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import List, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _message, _property_bag, ...
935
28.25
114
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_sarif_log.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import List, Literal, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _external_properties, ...
1,237
31.578947
134
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_external_properties.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import List, Literal, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _address, _artifac...
3,816
37.555556
85
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_version_control_details.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _artifact_location, _property_bag...
1,436
32.418605
107
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_configuration_override.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _property_bag, _reporting_configu...
1,004
30.40625
92
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_logical_location.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Optional from torch.onnx._internal.diagnostics.infra.sarif import _property_bag @dataclasses.dataclass clas...
1,314
31.875
80
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_result.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Any, List, Literal, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _artifact_locatio...
5,068
38.294574
87
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_web_response.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import Any, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _artifact_content, _property...
1,611
31.897959
80
py
pytorch
pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_fix.py
# DO NOT EDIT! This file was generated by jschema_to_python version 0.0.1.dev29, # with extension for dataclasses and type annotation. from __future__ import annotations import dataclasses from typing import List, Optional from torch.onnx._internal.diagnostics.infra.sarif import ( _artifact_change, _message,...
1,069
32.4375
225
py