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/onnx/_internal/diagnostics/infra/sarif/_artifact_content.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,012 | 28.794118 | 86 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_special_locations.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... | 782 | 26.964286 | 84 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_replacement.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_content,
_property_bag,... | 905 | 27.3125 | 86 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_region.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_content,
_message,
... | 2,031 | 33.440678 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_message.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 _property_bag
@dataclasses.dataclas... | 1,062 | 30.264706 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_run_automation_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 _message, _property_bag
@dataclasses.data... | 1,136 | 32.441176 | 100 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_edge_traversal.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 _message, _property_bag
@dataclasses... | 1,083 | 32.875 | 81 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_graph_traversal.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, Optional
from torch.onnx._internal.diagnostics.infra.sarif import (
_edge_traversal,
_mess... | 1,423 | 31.363636 | 87 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_external_property_file_reference.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,120 | 31.970588 | 174 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_location_relationship.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
@dataclasse... | 964 | 32.275862 | 88 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_configuration.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 _property_bag
@dataclasses.datac... | 1,136 | 32.441176 | 85 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_tool_component_reference.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... | 947 | 29.580645 | 90 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_thread_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 Any, List, Optional
from torch.onnx._internal.diagnostics.infra.sarif import (
_message,
_property_ba... | 1,351 | 31.97561 | 143 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_descriptor_reference.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,
_tool_component_re... | 1,166 | 28.923077 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_invocation.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, Optional
from torch.onnx._internal.diagnostics.infra.sarif import (
_artifact_location,
_c... | 4,597 | 37.966102 | 85 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_node.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,
_message,
_n... | 1,075 | 28.081081 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_artifact.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_content... | 3,026 | 33.011236 | 98 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_notification.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 (
_exception,
_locat... | 1,934 | 34.833333 | 129 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_stack_frame.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, _property_bag
@dataclass... | 1,088 | 31.029412 | 81 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_run.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 (
_address,
_ar... | 5,306 | 38.311111 | 99 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_external_property_file_references.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 (
_external_property_file_referen... | 3,901 | 43.850575 | 107 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_tool.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 _property_bag, _tool_component
@dat... | 848 | 29.321429 | 87 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_result_provenance.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 (
_physical_location,
_proper... | 1,551 | 33.488889 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_descriptor_relationship.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,
... | 1,110 | 30.742857 | 88 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/__init__.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 torch.onnx._internal.diagnostics.infra.sarif._address import Address
from torch.onnx._internal.diagnostics.infra.sarif._artifact import Artifact
from torch.onnx._internal.diagnost... | 4,984 | 48.356436 | 93 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_stack.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,
... | 859 | 25.875 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_graph.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 (
_edge,
_message,
_node,... | 1,090 | 29.305556 | 132 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_reporting_descriptor.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, Optional
from torch.onnx._internal.diagnostics.infra.sarif import (
_multiformat_message_strin... | 2,746 | 37.152778 | 135 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_change.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,
_proper... | 893 | 26.9375 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_address.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,748 | 34.693878 | 119 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_attachment.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,
_messag... | 1,213 | 29.35 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_thread_flow_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 Any, List, Literal, Optional
from torch.onnx._internal.diagnostics.infra.sarif import (
_location,
_p... | 2,517 | 36.029412 | 107 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_web_request.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,543 | 30.510204 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_artifact_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 _message, _property_bag
@dataclasses.data... | 1,061 | 30.235294 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/diagnostics/infra/sarif/_edge.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... | 983 | 29.75 | 80 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/type_utils.py | """Utilities for converting and operating on ONNX, JIT and torch types."""
from __future__ import annotations
from typing import (
Any,
Dict,
List,
Optional,
Protocol,
runtime_checkable,
Set,
Tuple,
TYPE_CHECKING,
Union,
)
import torch
if TYPE_CHECKING:
import onnx.defs.Op... | 3,511 | 28.024793 | 98 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/dynamo_graph_extractor.py | # NOTE: This file is referenced by name at
# /opt/pytorch/torch/_dynamo/eval_frame.py::DONT_WRAP_FILES.
# introduced by https://github.com/pytorch/pytorch/pull/98894.
# If this file is renamed, moved, etc please update the reference there!
from __future__ import annotations
import functools
import i... | 7,159 | 33.589372 | 94 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/fx_onnx_interpreter.py | from __future__ import annotations
import inspect
import operator
import re
import types
from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
import onnxscript # type: ignore[import]
from onnxscript.function_libs.torch_lib import ( # type: ignore[import]
graph_building as onnxscript_graph_b... | 26,352 | 38.450599 | 125 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/op_validation.py | """Module for handling op-level validation during exporting."""
from __future__ import annotations
from typing import Any, Callable, Dict, List, Sequence, Tuple, Union
import onnxscript # type: ignore[import]
from onnxscript import evaluator # type: ignore[import]
import torch
import torch.fx
from torch.onnx impo... | 14,215 | 40.205797 | 128 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/_pass.py | from __future__ import annotations
import abc
import contextlib
import difflib
import io
import sys
from typing import Any, Callable
import torch
import torch.fx
from torch.onnx._internal import _beartype
from torch.onnx._internal.fx import diagnostics, onnxfunction_dispatcher
@contextlib.contextmanager
def _pat... | 8,145 | 34.72807 | 104 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/registration.py | """Module for handling ATen to ONNX functions registration."""
from __future__ import annotations
import dataclasses
from collections import defaultdict
from typing import Dict, List, Optional, Set, TYPE_CHECKING, Union
import torch._ops
from torch.onnx._internal import _beartype
# We can only import onnx from this... | 8,420 | 37.452055 | 108 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/onnxfunction_dispatcher.py | """Dispatcher for AtenLib functions from onnx-script."""
from __future__ import annotations
import operator
from typing import (
Any,
Callable,
Dict,
List,
Optional,
Sequence,
Set,
Tuple,
TYPE_CHECKING,
Union,
)
import torch
import torch._ops
import torch.fx
from torch.onnx._i... | 28,878 | 42.038748 | 156 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/fx_symbolic_graph_extractor.py | from __future__ import annotations
import functools
from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Union
import torch
import torch.fx
import torch.onnx
import torch.onnx._internal.fx.passes as passes
from torch.onnx._internal import _beartype, exporter, io_adapter
# Functions directly ... | 9,586 | 39.795745 | 99 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/decomposition_table.py | """Dispatcher for AtenLib functions from onnx-script."""
from __future__ import annotations
from typing import Callable, Dict, Set, Union
import torch
import torch._ops
import torch.fx
from torch.onnx._internal import _beartype
from torch.onnx._internal.fx import registration
@_beartype.beartype
def _create_onnx... | 4,935 | 42.681416 | 119 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/diagnostics.py | from __future__ import annotations
import dataclasses
import functools
from typing import Any, Optional
import onnxscript # type: ignore[import]
from onnxscript.function_libs.torch_lib import graph_building # type: ignore[import]
import torch
import torch.fx
from torch.onnx._internal import diagnostics
from torc... | 4,131 | 32.593496 | 104 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/patcher.py | import copy
import io
from typing import List, Union
import torch
class ONNXTorchPatcher:
"""Context manager to temporarily patch PyTorch during FX-to-ONNX export.
This class is a collection of "patches" required by FX-to-ONNX exporter.
This context overrides several torch functions to support symbolic... | 4,882 | 45.066038 | 100 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/serialization.py | from __future__ import annotations
import io
import os
from typing import Tuple, TYPE_CHECKING, Union
import torch
from torch.onnx import _type_utils as jit_type_utils
from torch.onnx._internal import _beartype
if TYPE_CHECKING:
import onnx
@_beartype.beartype
def _create_tensor_proto_with_external_data(
t... | 7,494 | 44.981595 | 116 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/analysis/unsupported_nodes.py | from __future__ import annotations
import dataclasses
from typing import Dict, List
import torch
from torch.onnx._internal.fx import _pass, diagnostics
@dataclasses.dataclass
class UnsupportedFxNodesAnalysisResult(_pass.AnalysisResult):
unsupported_op_to_target_mapping: Dict[str, Dict[str, None]]
class Unsupp... | 2,694 | 34.460526 | 102 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/passes/decomp.py | from __future__ import annotations
from typing import Callable, Mapping, Optional
import torch
import torch._ops
import torch.fx
from torch.fx.experimental import proxy_tensor
from torch.onnx._internal import _beartype
from torch.onnx._internal.fx import _pass, diagnostics
from torch.onnx._internal.fx.passes import ... | 2,587 | 38.212121 | 92 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/passes/_utils.py | """Common utility functions for FX passes.
These functions should NOT be directly invoked outside of `passes` package.
"""
from __future__ import annotations
import collections
import re
from typing import Callable, Dict, Optional, Tuple
import torch.fx
import torch.fx.traceback as fx_traceback
from torch.onnx._in... | 4,338 | 35.158333 | 99 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/passes/virtualization.py | from __future__ import annotations
from typing import List, Optional, Tuple
import torch
import torch.fx
from torch.onnx._internal import _beartype
from torch.onnx._internal.fx import _pass
class MovePlaceholderToFront(_pass.Transform):
"""This pass move all placeholder nodes to the front of the graph node lis... | 3,868 | 38.886598 | 85 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/passes/functionalization.py | from __future__ import annotations
from typing import Callable, Optional
import torch
import torch._ops
import torch.func
import torch.fx
from torch.fx.experimental import proxy_tensor
from torch.onnx._internal import _beartype
from torch.onnx._internal.fx import _pass, diagnostics
from torch.onnx._internal.fx.passe... | 5,676 | 38.699301 | 92 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/passes/readability.py | from __future__ import annotations
from typing import Dict, List, Sequence, Tuple, Union
import torch
from torch.onnx._internal import _beartype
from torch.onnx._internal.fx import _pass, diagnostics
class RestoreParameterAndBufferNames(_pass.Transform):
"""Restore parameter and buffer names from original nn.mo... | 5,894 | 45.417323 | 115 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/passes/type_promotion.py | # Owner(s): ["module: onnx"]
from __future__ import annotations
import abc
import dataclasses
import inspect
import logging
from types import ModuleType
from typing import Any, Callable, Mapping, Optional, Sequence, Set
import torch
import torch._ops
import torch.fx
import torch.fx.traceback as fx_traceback
from t... | 64,731 | 37.69217 | 196 | py |
pytorch | pytorch-main/torch/onnx/_internal/fx/passes/shape_inference.py | from __future__ import annotations
import itertools
from typing import Optional
import torch
import torch._dynamo
import torch.fx
from torch._subclasses import fake_tensor
from torch.fx.experimental import proxy_tensor
from torch.fx.node import map_aggregate
from torch.nn.utils import stateless
from torch.onnx._inte... | 4,164 | 35.217391 | 114 | py |
pytorch | pytorch-main/torch/_decomp/decompositions.py | import functools
import operator
import sys
from enum import Enum
from functools import partial, reduce
from itertools import product
from typing import Callable, cast, Iterable, List, Optional, Tuple, Union
import torch
import torch._prims as prims
import torch._prims_common as utils
import torch.nn.functional as F
f... | 118,527 | 32.491947 | 151 | py |
pytorch | pytorch-main/torch/_decomp/decompositions_for_rng.py | import functools
from collections import defaultdict
from typing import Callable, Dict
import torch
import torch._decomp as decomp
from torch._decomp import get_decompositions
from torch._ops import OpOverload
aten = torch.ops.aten
rng_decompositions: Dict[str, Dict[OpOverload, Callable]] = defaultdict(dict)
def r... | 9,050 | 33.545802 | 104 | py |
pytorch | pytorch-main/torch/_decomp/__init__.py | import inspect
from collections import defaultdict
from functools import wraps
from itertools import chain
from typing import Callable, Dict, Sequence, Union
import torch
import torch.library
from torch._ops import OpOverload, OpOverloadPacket
from torch.utils._pytree import tree_map
__all__ = [
"decomposition_ta... | 12,267 | 32.703297 | 102 | py |
pytorch | pytorch-main/torch/_decomp/decompositions_for_jvp.py | import inspect
from typing import Callable, Dict, List, Optional, Tuple
import torch
import torch._decomp
from torch import Tensor
decomposition_table = torch._decomp.decomposition_table
decomposition_table_for_jvp: Dict[torch._ops.OpOverload, Callable] = {}
register_decomposition = torch._decomp.register_decompositi... | 10,503 | 34.486486 | 111 | py |
pytorch | pytorch-main/torch/compiler/__init__.py | import torch
from typing import List
__all__ = [
"compile",
"assume_constant_result",
"reset",
"allow_in_graph",
"list_backends",
"disable",
]
def compile(*args, **kwargs):
"""
See :func:`torch.compile` for details on the arguments for this function.
"""
return torch.compile(*a... | 3,070 | 31.326316 | 104 | py |
pytorch | pytorch-main/torch/cpu/__init__.py | r"""
This package implements abstractions found in ``torch.cuda``
to facilitate writing device-agnostic code.
"""
from typing import Any, Optional, Union
from contextlib import AbstractContextManager
from . import amp
from .. import device as _device
import torch
__all__ = [
"is_available",
"synchronize",
... | 2,786 | 24.336364 | 85 | py |
pytorch | pytorch-main/torch/cpu/amp/autocast_mode.py | import torch
from typing import Any
__all__ = ["autocast"]
class autocast(torch.amp.autocast_mode.autocast):
r"""
See :class:`torch.autocast`.
``torch.cpu.amp.autocast(args...)`` is equivalent to ``torch.autocast("cpu", args...)``
"""
def __init__(self, enabled : bool = True, dtype : torch.dtype =... | 1,186 | 33.911765 | 113 | py |
pytorch | pytorch-main/torch/_prims_common/wrappers.py | import torch
from torch._prims_common import (
Number,
NumberType,
TensorLike,
TensorLikeType,
ShapeType,
ELEMENTWISE_TYPE_PROMOTION_KIND,
)
import torch._prims_common as utils
from torch.utils._pytree import tree_flatten, tree_unflatten
from typing import Callable, Sequence, Tuple, NamedTuple,... | 13,364 | 37.076923 | 116 | py |
pytorch | pytorch-main/torch/_prims_common/__init__.py | from __future__ import annotations
from contextlib import nullcontext
from typing import Any, Union, Sequence, Optional, Tuple, List, Callable, Type, overload, cast
from enum import Enum
from functools import reduce, cmp_to_key
import operator
import sympy
import weakref
import warnings
import torch
from torch import ... | 60,686 | 31.839286 | 129 | py |
pytorch | pytorch-main/torch/utils/hooks.py | import torch
from collections import OrderedDict
import weakref
import warnings
from typing import Any, Tuple
__all__ = ["RemovableHandle", "unserializable_hook", "warn_if_has_hooks", "BackwardHook"]
class RemovableHandle:
r"""
A handle which provides the capability to remove a hook.
Args:
hooks_... | 9,302 | 37.127049 | 131 | py |
pytorch | pytorch-main/torch/utils/cpp_backtrace.py | from torch._C import _get_cpp_backtrace
def get_cpp_backtrace(frames_to_skip=0, maximum_number_of_frames=64) -> str:
r"""
Returns a string containing the C++ stack trace of the current thread.
Args:
frames_to_skip (int): the number of frames to skip from the top of the stack
maximum_number_... | 457 | 37.166667 | 84 | py |
pytorch | pytorch-main/torch/utils/checkpoint.py | import contextlib
import uuid
import warnings
import weakref
from collections import defaultdict
from typing import (
Any,
Callable,
ContextManager,
DefaultDict,
Dict,
Iterable,
List,
Optional,
Tuple,
)
from weakref import ReferenceType
from torch.testing._internal.logging_tensor imp... | 51,497 | 41.14239 | 106 | py |
pytorch | pytorch-main/torch/utils/_traceback.py | from types import TracebackType
import tempfile
import traceback
import contextlib
import inspect
import os.path
# This file contains utilities for ensuring dynamically compile()'d
# code fragments display their line numbers in backtraces.
#
# The constraints:
#
# - We don't have control over the user exception printe... | 6,809 | 43.509804 | 101 | py |
pytorch | pytorch-main/torch/utils/backend_registration.py | import torch
from torch._C import _rename_privateuse1_backend, _get_privateuse1_backend_name
from typing import List, Optional, Union
__all__ = ["rename_privateuse1_backend", "generate_methods_for_privateuse1_backend"]
# TODO: Should use `torch._C._get_privateuse1_backend_name()` to get
# renamed-backend name for `pr... | 16,981 | 48.800587 | 123 | py |
pytorch | pytorch-main/torch/utils/_content_store.py | # This module provides a FAST (on GPU) content addressable store for storages
# (and tensors on top of them) with VERY WEAK portability guarantees (e.g.,
# don't expect CPU/CUDA to address to the same hash, don't expect it to be
# portable across devices) that is NOT cryptographically secure. In return,
# we are able ... | 8,655 | 38.167421 | 113 | py |
pytorch | pytorch-main/torch/utils/mkldnn.py | import torch
class MkldnnLinear(torch.jit.ScriptModule):
def __init__(self, dense_module, dtype):
super().__init__()
self.register_buffer('weight', dense_module.weight.to_mkldnn(dtype))
if dense_module.bias is not None:
# Bias can be fp32 or bf16 for OneDNN bf16 path, but for g... | 7,862 | 32.746781 | 90 | py |
pytorch | pytorch-main/torch/utils/bundled_inputs.py | #!/usr/bin/env python3
from typing import Any, TypeVar, Optional, Tuple, List, NamedTuple, Union, Sequence, Dict, Callable
import textwrap
import torch
from torch._C import TupleType, ListType
from torch.jit._recursive import wrap_cpp_module
T = TypeVar("T")
MAX_RAW_TENSOR_SIZE = 16
class InflatableArg(NamedTuple):... | 22,643 | 46.772152 | 127 | py |
pytorch | pytorch-main/torch/utils/throughput_benchmark.py |
import torch._C
def format_time(time_us=None, time_ms=None, time_s=None):
'''Defines how to format time'''
assert sum([time_us is not None, time_ms is not None, time_s is not None]) == 1
US_IN_SECOND = 1e6
US_IN_MS = 1e3
if time_us is None:
if time_ms is not None:
time_us = ... | 6,418 | 39.626582 | 111 | py |
pytorch | pytorch-main/torch/utils/model_zoo.py | # torchvision imports tqdm from here.
from torch.hub import tqdm, load_state_dict_from_url as load_url # noqa: F401
| 117 | 38.333333 | 78 | py |
pytorch | pytorch-main/torch/utils/_foreach_utils.py | from typing import List, Dict, Tuple, Optional
import torch
from torch import Tensor
from torch.autograd.grad_mode import no_grad
def _get_foreach_kernels_supported_devices() -> List[str]:
r"""
Return the device type list that supports foreach kernels.
"""
return ["cuda", torch._C._get_privateuse1_bac... | 2,220 | 47.282609 | 110 | py |
pytorch | pytorch-main/torch/utils/_mode_utils.py | import torch
from typing import TypeVar
T = TypeVar('T')
# returns if all are the same mode
def all_same_mode(modes):
return all(tuple(mode == modes[0] for mode in modes))
no_dispatch = torch._C._DisableTorchDispatch
| 224 | 19.454545 | 57 | py |
pytorch | pytorch-main/torch/utils/collect_env.py |
# Unlike the rest of the PyTorch this file must be python2 compliant.
# This script outputs relevant system environment info
# Run it with `python collect_env.py`.
import datetime
import locale
import re
import subprocess
import sys
import os
from collections import namedtuple
try:
import torch
TORCH_AVAILAB... | 21,653 | 34.498361 | 123 | py |
pytorch | pytorch-main/torch/utils/_freeze.py | """
Freeze Python packages.
Freezing makes it possible to ship arbitrary Python modules as part of a C++
library. The Python source of the module is compiled to bytecode and written
to `.c` files, to be imported by Python's built-in FrozenImporter.
In a normal Python installation, FrozenImporter is only used to boots... | 9,940 | 34.127208 | 115 | py |
pytorch | pytorch-main/torch/utils/_stats.py | # NOTE! PLEASE KEEP THIS FILE *FREE* OF TORCH DEPS! IT SHOULD BE IMPORTABLE ANYWHERE.
# IF YOU FEEL AN OVERWHELMING URGE TO ADD A TORCH DEP, MAKE A TRAMPOLINE FILE A LA torch._dynamo.utils
# AND SCRUB AWAY TORCH NOTIONS THERE.
import collections
import functools
from typing import OrderedDict
simple_call_counter: Orde... | 810 | 35.863636 | 102 | py |
pytorch | pytorch-main/torch/utils/_python_dispatch.py | import contextlib
from typing import Optional
import warnings
import torch
from torch._C import _len_torch_dispatch_stack, _get_dispatch_stack_at,\
_pop_torch_dispatch_stack, _push_on_torch_dispatch_stack, DispatchKey
# TODO: Limitations and things about enable_torch_dispatch_mode we should fix before exposing i... | 5,602 | 39.021429 | 105 | py |
pytorch | pytorch-main/torch/utils/weak.py | from __future__ import annotations
import weakref
from weakref import ref
from _weakrefset import _IterationGuard # type: ignore[attr-defined]
from collections.abc import MutableMapping, Mapping
from typing import Dict
from torch import Tensor
import collections.abc as _collections_abc
WeakRef = ref
__all__ = ['T... | 9,674 | 32.133562 | 90 | py |
pytorch | pytorch-main/torch/utils/cpp_extension.py | import copy
import glob
import importlib
import importlib.abc
import os
import re
import shlex
import shutil
import setuptools
import subprocess
import sys
import sysconfig
import warnings
import collections
import torch
import torch._appdirs
from .file_baton import FileBaton
from ._cpp_extension_versioner import Exte... | 98,345 | 42.515929 | 181 | py |
pytorch | pytorch-main/torch/utils/flop_counter.py | import torch
import torch.nn as nn
from torch.utils._pytree import tree_map
from typing import List, Any, Dict, Optional, Union, NamedTuple
from collections import defaultdict
from torch.utils._python_dispatch import TorchDispatchMode
from torch.utils.hooks import RemovableHandle
from math import prod
__all__ = ["Flop... | 15,123 | 34.419204 | 121 | py |
pytorch | pytorch-main/torch/utils/dlpack.py | from typing import Any
import torch
import enum
from torch._C import _from_dlpack
from torch._C import _to_dlpack as to_dlpack
class DLDeviceType(enum.IntEnum):
# Enums as in DLPack specification (aten/src/ATen/dlpack.h)
kDLCPU = 1,
kDLGPU = 2,
kDLCPUPinned = 3,
kDLOpenCL = 4,
kDLVulkan = 7,... | 4,454 | 35.516393 | 144 | py |
pytorch | pytorch-main/torch/utils/__init__.py | import os.path as _osp
import torch
from .throughput_benchmark import ThroughputBenchmark
from ._crash_handler import enable_minidumps, disable_minidumps, enable_minidumps_on_exceptions
from .cpp_backtrace import get_cpp_backtrace
from .backend_registration import rename_privateuse1_backend, generate_methods_for_priva... | 781 | 38.1 | 102 | py |
pytorch | pytorch-main/torch/utils/_crash_handler.py | import os
import sys
import pathlib
import torch
DEFAULT_MINIDUMP_DIR = "/tmp/pytorch_crashes"
if sys.platform == "win32":
DEFAULT_MINIDUMP_DIR = str(pathlib.Path.home() / "AppData" / "pytorch_crashes")
def enable_minidumps(directory=DEFAULT_MINIDUMP_DIR):
if directory == DEFAULT_MINIDUMP_DIR:
pathli... | 673 | 24.923077 | 83 | py |
pytorch | pytorch-main/torch/utils/_device.py | import torch
from torch.overrides import TorchFunctionMode
from torch.utils._contextlib import context_decorator
import functools
CURRENT_DEVICE = None
@functools.lru_cache(1)
def _device_constructors():
return {
# standard ones
torch.empty,
torch.empty_permuted,
torch.empty_stride... | 2,658 | 28.544444 | 75 | py |
pytorch | pytorch-main/torch/utils/mobile_optimizer.py | """
This module contains utility method for mobile model optimization and lint.
"""
import torch
from enum import Enum
from torch._C import _MobileOptimizerType as MobileOptimizerType
from typing import Optional, Set, List, AnyStr
class LintCode(Enum):
BUNDLED_INPUT = 1
REQUIRES_GRAD = 2
DROPOUT = 3
B... | 6,347 | 46.022222 | 132 | py |
pytorch | pytorch-main/torch/utils/_sympy/interp.py | """
This is a simple interpreter for Sympy expressions that dispatches to
classes following the torch._inductor.virtualized calling convention.
For directness, the interpreter takes the handler directly rather than
consulting the TLS. It does not use most of the methods on the full
handler; only those with correspondi... | 2,969 | 28.405941 | 92 | py |
pytorch | pytorch-main/torch/utils/_sympy/value_ranges.py | import dataclasses
from copy import deepcopy
import itertools
import sympy
from sympy.logic.boolalg import BooleanAtom, Boolean as SympyBoolean
import operator
import math
import logging
import torch
from typing import Union, Dict
from torch._prims_common import dtype_to_type
from .interp import sympy_interp
log = lo... | 18,645 | 31.885362 | 118 | py |
pytorch | pytorch-main/torch/utils/model_dump/__init__.py | #!/usr/bin/env python3
"""
model_dump: a one-stop shop for TorchScript model inspection.
The goal of this tool is to provide a simple way to extract lots of
useful information from a TorchScript model and make it easy for humans
to consume. It (mostly) replaces zipinfo, common uses of show_pickle,
and various ad-hoc ... | 16,754 | 39.373494 | 107 | py |
pytorch | pytorch-main/torch/utils/backcompat/__init__.py | from torch._C import _set_backcompat_broadcast_warn
from torch._C import _get_backcompat_broadcast_warn
from torch._C import _set_backcompat_keepdim_warn
from torch._C import _get_backcompat_keepdim_warn
class Warning:
def __init__(self, setter, getter):
self.setter = setter
self.getter = getter
... | 667 | 29.363636 | 91 | py |
pytorch | pytorch-main/torch/utils/bottleneck/__main__.py | import argparse
import cProfile
import pstats
import sys
import os
from typing import Dict
import torch
from torch.autograd import profiler
from torch.utils.collect_env import get_env_info
def redirect_argv(new_argv):
sys.argv[:] = new_argv[:]
def compiled_with_cuda(sysinfo):
if sysinfo.cuda_compiled_versi... | 7,219 | 30.391304 | 107 | py |
pytorch | pytorch-main/torch/utils/viz/_cycles.py | import gc
import sys
from typing import Any, Dict, List, NamedTuple, Optional, Tuple
import types
import weakref
import json
from tempfile import NamedTemporaryFile
import torch
from torch.cuda._memory_viz import _frames_fmt, _block_extra
import atexit
import logging
logger = logging.getLogger(__name__)
def observe_ga... | 14,831 | 31.741722 | 114 | py |
pytorch | pytorch-main/torch/utils/hipify/cuda_to_hip_mappings.py | import collections
import os
import re
import subprocess
from .constants import (API_BLAS, API_C10, API_CAFFE2, API_DRIVER, API_FFT,
API_PYTORCH, API_RAND, API_ROCTX, API_RTC, API_RUNTIME,
API_SPECIAL, API_ROCMSMI, CONV_CACHE, CONV_CONTEXT, CONV_D3D9,
... | 341,657 | 38.640097 | 128 | py |
pytorch | pytorch-main/torch/utils/hipify/hipify_python.py | #!/usr/bin/env python3
""" The Python Hipify script.
##
# Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
# 2017-2018 Advanced Micro Devices, Inc. and
# Facebook Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obta... | 45,207 | 39.149201 | 132 | py |
pytorch | pytorch-main/torch/utils/jit/log_extract.py | from contextlib import contextmanager
from typing import Any, List, Tuple, cast
import random
import torch
import time
from torch.utils.benchmark import Timer
def extract_ir(filename: str) -> List[str]:
BEGIN = "<GRAPH_EXPORT>"
END = "</GRAPH_EXPORT>"
pfx = None
current = ""
graphs = []
with op... | 3,759 | 31.982456 | 98 | py |
pytorch | pytorch-main/torch/utils/tensorboard/writer.py | """Provides an API for writing protocol buffers to event files to be
consumed by TensorBoard for visualization."""
import os
import time
import torch
from tensorboard.compat import tf
from tensorboard.compat.proto import event_pb2
from tensorboard.compat.proto.event_pb2 import Event, SessionLog
from tensorboard.plug... | 48,973 | 38.241987 | 127 | py |
pytorch | pytorch-main/torch/utils/tensorboard/_convert_np.py | """
This module converts objects into numpy array.
"""
import numpy as np
import torch
def make_np(x):
"""
Args:
x: An instance of torch tensor or caffe blob name
Returns:
numpy.array: Numpy array
"""
if isinstance(x, np.ndarray):
return x
if isinstance(x, str): # Caffe... | 856 | 19.902439 | 90 | py |
pytorch | pytorch-main/torch/utils/tensorboard/_caffe2_graph.py | import copy
import logging
import os
import re
from tensorboard.compat.proto.graph_pb2 import GraphDef
from tensorboard.compat.proto.node_def_pb2 import NodeDef
from tensorboard.compat.proto.tensor_shape_pb2 import TensorShapeProto
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
from ty... | 26,553 | 31.343484 | 86 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.