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/utils/tensorboard/_pytorch_graph.py
from collections import OrderedDict import contextlib from typing import Dict, Any from tensorboard.compat.proto.config_pb2 import RunMetadata from tensorboard.compat.proto.graph_pb2 import GraphDef from tensorboard.compat.proto.step_stats_pb2 import StepStats, DeviceStepStats from tensorboard.compat.proto.versions_pb...
13,988
35.054124
120
py
pytorch
pytorch-main/torch/utils/tensorboard/summary.py
import json import logging import os from typing import Optional import torch import numpy as np from google.protobuf import struct_pb2 from tensorboard.compat.proto.summary_pb2 import ( HistogramProto, Summary, SummaryMetadata, ) from tensorboard.compat.proto.tensor_pb2 import TensorProto from tensorboa...
33,399
33.791667
119
py
pytorch
pytorch-main/torch/utils/benchmark/__init__.py
from torch.utils.benchmark.utils.common import * # noqa: F403 from torch.utils.benchmark.utils.timer import * # noqa: F403 from torch.utils.benchmark.utils.compare import * # noqa: F403 from torch.utils.benchmark.utils.fuzzer import * # noqa: F403 from torch.utils.benchmark.utils.valgrind_wrapper.timer_interface im...
411
57.857143
88
py
pytorch
pytorch-main/torch/utils/benchmark/examples/end_to_end.py
# -*- coding: utf-8 -*- """End-to-end example to test a PR for regressions: $ python -m examples.end_to_end --pr 39850 $ python -m examples.end_to_end --pr 39967 $ python -m examples.end_to_end --pr 39744 NOTE: This example assumes that you have and environment prefixed with `ref_`, and another prefixed with `pr_...
14,780
33.535047
118
py
pytorch
pytorch-main/torch/utils/benchmark/examples/simple_timeit.py
"""Trivial use of Timer API: $ python -m examples.simple_timeit """ import torch import torch.utils.benchmark as benchmark_utils def main(): timer = benchmark_utils.Timer( stmt="x + y", globals={"x": torch.ones((4, 8)), "y": torch.ones((1, 8))}, label="Broadcasting add (4x8)", ) ...
533
19.538462
67
py
pytorch
pytorch-main/torch/utils/benchmark/examples/op_benchmark.py
"""Example use of Timer and op fuzzers to measure kernel performance. $ python -m examples.op_benchmark """ import numpy as np import torch from torch.utils.benchmark import Timer from torch.utils.benchmark.op_fuzzers.binary import BinaryOpFuzzer from torch.utils.benchmark.op_fuzzers.unary import UnaryOpFuzzer _ME...
4,176
39.163462
98
py
pytorch
pytorch-main/torch/utils/benchmark/examples/fuzzer.py
"""Example of the Timer and Fuzzer APIs: $ python -m examples.fuzzer """ import sys import torch.utils.benchmark as benchmark_utils def main(): add_fuzzer = benchmark_utils.Fuzzer( parameters=[ [ benchmark_utils.FuzzedParameter( name=f"k{i}", ...
2,623
29.511628
92
py
pytorch
pytorch-main/torch/utils/benchmark/examples/blas_compare_setup.py
import collections import os import shutil import subprocess try: # no type stub for conda command line interface import conda.cli.python_api # type: ignore[import] from conda.cli.python_api import Commands as conda_commands except ImportError: # blas_compare.py will fail to import these when it's ins...
7,018
31.345622
112
py
pytorch
pytorch-main/torch/utils/benchmark/examples/blas_compare.py
import argparse import datetime import itertools as it import multiprocessing import multiprocessing.dummy import os import queue import pickle import shutil import subprocess import sys import tempfile import threading import time from typing import Tuple, Dict from . import blas_compare_setup MIN_RUN_TIME = 1 NUM_...
7,776
32.521552
104
py
pytorch
pytorch-main/torch/utils/benchmark/examples/compare.py
"""Example of Timer and Compare APIs: $ python -m examples.compare """ import pickle import sys import time import torch import torch.utils.benchmark as benchmark_utils class FauxTorch: """Emulate different versions of pytorch. In normal circumstances this would be done with multiple processes writin...
2,888
28.181818
97
py
pytorch
pytorch-main/torch/utils/benchmark/examples/spectral_ops_fuzz_test.py
"""Microbenchmarks for the torch.fft module""" from argparse import ArgumentParser from collections import namedtuple from collections.abc import Iterable import torch import torch.fft from torch.utils import benchmark from torch.utils.benchmark.op_fuzzers.spectral import SpectralOpFuzzer def _dim_options(ndim): ...
4,724
40.447368
106
py
pytorch
pytorch-main/torch/utils/benchmark/examples/sparse/op_benchmark.py
"""Example use of Timer and sparse op fuzzers to measure kernel performance. $ python -m examples.sparse.op_benchmark """ import numpy as np import torch from torch.utils.benchmark import Timer from torch.utils.benchmark.op_fuzzers.sparse_unary import UnaryOpSparseFuzzer from torch.utils.benchmark.op_fuzzers.sparse_...
4,220
41.636364
98
py
pytorch
pytorch-main/torch/utils/benchmark/examples/sparse/fuzzer.py
"""Example of the Timer and Sparse Fuzzer APIs: $ python -m examples.sparse.fuzzer """ import sys import torch.utils.benchmark as benchmark_utils def main(): add_fuzzer = benchmark_utils.Fuzzer( parameters=[ [ benchmark_utils.FuzzedParameter( name=f"k{i}",...
3,417
32.509804
96
py
pytorch
pytorch-main/torch/utils/benchmark/examples/sparse/compare.py
"""Example of Timer and Compare APIs: $ python -m examples.sparse.compare """ import pickle import sys import time import torch import torch.utils.benchmark as benchmark_utils class FauxTorch: """Emulate different versions of pytorch. In normal circumstances this would be done with multiple processes ...
3,873
29.503937
98
py
pytorch
pytorch-main/torch/utils/benchmark/op_fuzzers/sparse_binary.py
import numpy as np import torch from torch.utils.benchmark import Fuzzer, FuzzedParameter, ParameterAlias, FuzzedSparseTensor _MIN_DIM_SIZE = 16 _MAX_DIM_SIZE = 16 * 1024 ** 2 _POW_TWO_SIZES = tuple(2 ** i for i in range( int(np.log2(_MIN_DIM_SIZE)), int(np.log2(_MAX_DIM_SIZE)) + 1, )) class BinaryOpSparse...
4,191
38.17757
107
py
pytorch
pytorch-main/torch/utils/benchmark/op_fuzzers/sparse_unary.py
import numpy as np import torch from torch.utils.benchmark import Fuzzer, FuzzedParameter, ParameterAlias, FuzzedSparseTensor _MIN_DIM_SIZE = 16 _MAX_DIM_SIZE = 16 * 1024 ** 2 _POW_TWO_SIZES = tuple(2 ** i for i in range( int(np.log2(_MIN_DIM_SIZE)), int(np.log2(_MAX_DIM_SIZE)) + 1, )) class UnaryOpSparseFu...
3,219
37.795181
107
py
pytorch
pytorch-main/torch/utils/benchmark/op_fuzzers/binary.py
import numpy as np import torch from torch.utils.benchmark import Fuzzer, FuzzedParameter, ParameterAlias, FuzzedTensor _MIN_DIM_SIZE = 16 _MAX_DIM_SIZE = 16 * 1024 ** 2 _POW_TWO_SIZES = tuple(2 ** i for i in range( int(np.log2(_MIN_DIM_SIZE)), int(np.log2(_MAX_DIM_SIZE)) + 1, )) class BinaryOpFuzzer(Fuzze...
4,109
37.411215
107
py
pytorch
pytorch-main/torch/utils/benchmark/op_fuzzers/unary.py
import numpy as np import torch from torch.utils.benchmark import Fuzzer, FuzzedParameter, ParameterAlias, FuzzedTensor _MIN_DIM_SIZE = 16 _MAX_DIM_SIZE = 16 * 1024 ** 2 _POW_TWO_SIZES = tuple(2 ** i for i in range( int(np.log2(_MIN_DIM_SIZE)), int(np.log2(_MAX_DIM_SIZE)) + 1, )) class UnaryOpFuzzer(Fuzzer...
3,119
37.04878
107
py
pytorch
pytorch-main/torch/utils/benchmark/op_fuzzers/spectral.py
import math import torch from torch.utils import benchmark from torch.utils.benchmark import FuzzedParameter, FuzzedTensor, ParameterAlias __all__ = ['SpectralOpFuzzer'] MIN_DIM_SIZE = 16 MAX_DIM_SIZE = 16 * 1024 def power_range(upper_bound, base): return (base ** i for i in range(int(math.log(upper_bound, bas...
3,597
37.276596
94
py
pytorch
pytorch-main/torch/utils/benchmark/utils/timer.py
"""Timer class based on the timeit.Timer class, but torch aware.""" import enum import timeit import textwrap from typing import overload, Any, Callable, Dict, List, NoReturn, Optional, Tuple, Type, Union import torch from torch.utils.benchmark.utils import common, cpp_jit from torch.utils.benchmark.utils._stubs impor...
19,513
38.263581
100
py
pytorch
pytorch-main/torch/utils/benchmark/utils/sparse_fuzzer.py
from typing import Optional, Tuple, Union from numbers import Number import torch from torch.utils.benchmark import FuzzedTensor import math class FuzzedSparseTensor(FuzzedTensor): def __init__( self, name: str, size: Tuple[Union[str, int], ...], min_elements: Optional[int] = None, ...
5,165
41.694215
114
py
pytorch
pytorch-main/torch/utils/benchmark/utils/fuzzer.py
import functools import itertools as it from typing import Any, Callable, Dict, List, Optional, Tuple, Union import numpy as np import torch __all__ = [ "Fuzzer", "FuzzedParameter", "ParameterAlias", "FuzzedTensor", ] _DISTRIBUTIONS = ( "loguniform", "uniform", ) class FuzzedParameter: ""...
18,218
38.779476
100
py
pytorch
pytorch-main/torch/utils/benchmark/utils/cpp_jit.py
"""JIT C++ strings into executables.""" import atexit import os import re import shutil import textwrap import threading from typing import Any, List, Optional import torch from torch.utils.benchmark.utils._stubs import CallgrindModuleType, TimeitModuleType from torch.utils.benchmark.utils.common import _make_temp_dir...
6,824
38.450867
111
py
pytorch
pytorch-main/torch/utils/benchmark/utils/compile.py
import torch __all__ = ["bench_all", "benchmark_compile"] import torch._dynamo from torch._dynamo.testing import CompileCounterWithBackend from torch.utils.benchmark import Timer from typing import Optional, List, Callable, Union, Any, cast _warned_tensor_cores = False _default_float_32_precision = torch.get_float3...
7,523
39.021277
116
py
pytorch
pytorch-main/torch/utils/benchmark/utils/compare.py
"""Display class to aggregate and print the results of many measurements.""" import collections import enum import itertools as it from typing import DefaultDict, List, Optional, Tuple from torch.utils.benchmark.utils import common from torch import tensor as _tensor __all__ = ["Colorize", "Compare"] BEST = "\033[92...
12,321
37.386293
119
py
pytorch
pytorch-main/torch/utils/benchmark/utils/common.py
"""Base shared classes and utilities.""" import collections import contextlib import dataclasses import os import shutil import tempfile import textwrap import time from typing import cast, Any, DefaultDict, Dict, Iterable, Iterator, List, Optional, Tuple import uuid import torch __all__ = ["TaskSpec", "Measurement...
13,666
37.390449
169
py
pytorch
pytorch-main/torch/utils/benchmark/utils/_stubs.py
from typing import Any, Callable, Dict, Protocol, runtime_checkable class TimerClass(Protocol): """This is the portion of the `timeit.Timer` API used by benchmark utils.""" def __init__( self, stmt: str, setup: str, timer: Callable[[], float], globals: Dict[str, Any], ...
976
22.829268
80
py
pytorch
pytorch-main/torch/utils/benchmark/utils/valgrind_wrapper/timer_interface.py
"""Intermediate layer between `Timer` and `valgrind`.""" import collections import enum import dataclasses import itertools as it import os import pickle import re import shutil import subprocess import sys import textwrap from typing import ( cast, Any, Callable, DefaultDict, Dict, Generator, List, NamedTuple, ...
36,792
39.745293
126
py
pytorch
pytorch-main/torch/utils/data/sampler.py
import torch from torch import Tensor from typing import Iterator, Iterable, Optional, Sequence, List, TypeVar, Generic, Sized, Union __all__ = [ "BatchSampler", "RandomSampler", "Sampler", "SequentialSampler", "SubsetRandomSampler", "WeightedRandomSampler", ] T_co = TypeVar('T_co', covariant...
12,801
40.564935
120
py
pytorch
pytorch-main/torch/utils/data/graph_settings.py
import inspect import warnings from typing import Any, List, Optional, Set import torch from torch.utils.data.datapipes.iter.sharding import ( _ShardingIterDataPipe, SHARDING_PRIORITIES, ) from torch.utils.data.graph import DataPipe, DataPipeGraph, traverse_dps __all__ = [ "apply_random_seed", "appl...
5,463
33.802548
124
py
pytorch
pytorch-main/torch/utils/data/dataloader.py
r"""Definition of the DataLoader and associated iterators that subclass _BaseDataLoaderIter To support these two classes, in `./_utils` we define many utility methods and functions to be run in multiprocessing. E.g., the data loading worker loop is in `./_utils/worker.py`. """ import functools import itertools import...
74,325
49.152497
131
py
pytorch
pytorch-main/torch/utils/data/dataset.py
import bisect import warnings import math from typing import ( Generic, Iterable, Iterator, List, Optional, Sequence, Tuple, TypeVar, Union, Dict ) # No 'default_generator' in torch/__init__.pyi from torch import default_generator, randperm from torch._utils import _accumulate ...
17,140
39.522459
120
py
pytorch
pytorch-main/torch/utils/data/graph.py
import io import pickle import warnings from collections.abc import Collection from typing import Dict, List, Optional, Set, Tuple, Type, Union from torch.utils.data import IterDataPipe, MapDataPipe from torch.utils.data._utils.serialization import DILL_AVAILABLE __all__ = ["traverse", "traverse_dps"] DataPipe = U...
5,810
38.530612
117
py
pytorch
pytorch-main/torch/utils/data/distributed.py
import math from typing import TypeVar, Optional, Iterator import torch from . import Sampler, Dataset import torch.distributed as dist __all__ = ["DistributedSampler", ] T_co = TypeVar('T_co', covariant=True) class DistributedSampler(Sampler[T_co]): r"""Sampler that restricts data loading to a subset of the d...
5,971
42.591241
105
py
pytorch
pytorch-main/torch/utils/data/__init__.py
# TODO(VitalyFedyunin): Rearranging this imports leads to crash, # need to cleanup dependencies and fix it from torch.utils.data.sampler import ( BatchSampler, RandomSampler, Sampler, SequentialSampler, SubsetRandomSampler, WeightedRandomSampler, ) from torch.utils.data.dataset import ( Chai...
1,956
24.415584
64
py
pytorch
pytorch-main/torch/utils/data/_utils/collate.py
r""""Contains definitions of the methods used by the _BaseDataLoaderIter workers to collate samples fetched from dataset into Tensor(s). These **needs** to be in global scope since Py2 doesn't support serializing static methods. `default_collate` and `default_convert` are exposed to users via 'dataloader.py'. """ im...
12,595
46.353383
122
py
pytorch
pytorch-main/torch/utils/data/_utils/__init__.py
r"""Utility classes & functions for data loading. Code in this folder is mostly used by ../dataloder.py. A lot of multiprocessing is used in data loading, which only supports running functions defined in global environment (py2 can't serialize static methods). Therefore, for code tidiness we put these functions into d...
1,596
29.132075
117
py
pytorch
pytorch-main/torch/utils/data/_utils/pin_memory.py
r""""Contains definitions of the methods used by the _BaseDataLoaderIter to put fetched tensors into pinned memory. These **needs** to be in global scope since Py2 doesn't support serializing static methods. """ import collections import queue import torch from . import MP_STATUS_CHECK_INTERVAL from torch._utils imp...
3,134
37.703704
118
py
pytorch
pytorch-main/torch/utils/data/_utils/signal_handling.py
r""""Signal handling for multiprocessing data loading. NOTE [ Signal handling in multiprocessing data loading ] In cases like DataLoader, if a worker process dies due to bus error/segfault or just hang, the main process will hang waiting for data. This is difficult to avoid on PyTorch side as it can be caused by limi...
3,156
42.246575
103
py
pytorch
pytorch-main/torch/utils/data/_utils/worker.py
r""""Contains definitions of the methods used by the _BaseDataLoaderIter workers. These **needs** to be in global scope since Py2 doesn't support serializing static methods. """ import torch import random import os import queue from dataclasses import dataclass from torch._utils import ExceptionWrapper from typing im...
13,425
39.684848
111
py
pytorch
pytorch-main/torch/utils/data/datapipes/_hook_iterator.py
import inspect import functools from enum import Enum import torch.autograd class _SnapshotState(Enum): r""" These are the snapshotting-related states that IterDataPipes can be in. `NotStarted` - allows you to restore a snapshot and create an iterator with reset `Restored` - cannot restore again, all...
11,643
45.390438
116
py
pytorch
pytorch-main/torch/utils/data/datapipes/_decorator.py
import inspect from functools import wraps from typing import Any, Callable, Optional, Type, Union, get_type_hints from torch.utils.data.datapipes.datapipe import IterDataPipe, MapDataPipe from torch.utils.data.datapipes._typing import _DataPipeMeta ###################################################### # Functional ...
7,646
39.893048
120
py
pytorch
pytorch-main/torch/utils/data/datapipes/_typing.py
# Taking reference from official Python typing # https://github.com/python/cpython/blob/master/Lib/typing.py import collections import functools import numbers import sys from torch.utils.data.datapipes._hook_iterator import hook_iterator, _SnapshotState from typing import (Any, Dict, Iterator, Generic, List, Set, Tu...
15,907
36.081585
129
py
pytorch
pytorch-main/torch/utils/data/datapipes/datapipe.py
import functools import pickle from typing import Dict, Callable, Optional, TypeVar, Generic, Iterator from torch.utils.data.datapipes._typing import _DataPipeMeta, _IterDataPipeMeta from torch.utils.data.datapipes._hook_iterator import _SnapshotState from torch.utils.data.datapipes.utils.common import ( _deprecat...
17,031
41.263027
118
py
pytorch
pytorch-main/torch/utils/data/datapipes/dataframe/datapipes.py
import random from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import DFIterDataPipe, IterDataPipe from torch.utils.data.datapipes.dataframe import dataframe_wrapper as df_wrapper __all__ = [ "ConcatDataFramesPipe", "DataFramesAsTuplesPipe", "...
4,435
32.606061
109
py
pytorch
pytorch-main/torch/utils/data/datapipes/dataframe/structures.py
from torch.utils.data.datapipes.datapipe import DataChunk from torch.utils.data.datapipes.dataframe import dataframe_wrapper as df_wrapper __all__ = ["DataChunkDF", ] class DataChunkDF(DataChunk): """ DataChunkDF iterating over individual items inside of DataFrame containers, to access DataFrames...
599
26.272727
83
py
pytorch
pytorch-main/torch/utils/data/datapipes/dataframe/__init__.py
from torch.utils.data.datapipes.dataframe.dataframes import ( CaptureDataFrame, DFIterDataPipe, ) from torch.utils.data.datapipes.dataframe.datapipes import ( DataFramesAsTuplesPipe, ) __all__ = ['CaptureDataFrame', 'DFIterDataPipe', 'DataFramesAsTuplesPipe'] # Please keep this list sorted assert __all__ == s...
335
27
74
py
pytorch
pytorch-main/torch/utils/data/datapipes/dataframe/dataframes.py
from typing import Any, Dict, List from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import DFIterDataPipe, IterDataPipe from torch.utils.data.datapipes.dataframe.structures import DataChunkDF # TODO(VitalyFedyunin): Add error when two different traces get...
13,434
29.956221
115
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/routeddecoder.py
from io import BufferedIOBase from typing import Any, Callable, Iterable, Iterator, Sized, Tuple from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import IterDataPipe from torch.utils.data.datapipes.utils.common import _deprecation_warning from torch.utils.d...
2,730
40.378788
94
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/selecting.py
from typing import Callable, Iterator, Tuple, TypeVar from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import IterDataPipe from torch.utils.data.datapipes.dataframe import dataframe_wrapper as df_wrapper from torch.utils.data.datapipes.utils.common import (...
3,208
32.427083
118
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/filelister.py
from typing import Iterator, List, Sequence, Union from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import IterDataPipe from torch.utils.data.datapipes.iter import IterableWrapper from torch.utils.data.datapipes.utils.common import get_file_pathnames_from...
2,520
37.19697
123
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/utils.py
import copy import warnings from torch.utils.data.datapipes.datapipe import IterDataPipe __all__ = ["IterableWrapperIterDataPipe", ] class IterableWrapperIterDataPipe(IterDataPipe): r""" Wraps an iterable object to create an IterDataPipe. Args: iterable: Iterable object to be wrapped into an Ite...
1,781
33.941176
88
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/fileopener.py
from io import IOBase from typing import Iterable, Tuple, Optional from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import IterDataPipe from torch.utils.data.datapipes.utils.common import get_file_binaries_from_pathnames __all__ = [ "FileOpenerIterData...
2,787
37.191781
96
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/sharding.py
from typing import ( Dict, Sized, Tuple, ) from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import IterDataPipe from enum import IntEnum __all__ = [ "SHARDING_PRIORITIES", "ShardingFilterIterDataPipe", ] class SHARDING_PRIORITIES(IntE...
3,286
38.130952
119
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/streamreader.py
from typing import Tuple from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import IterDataPipe __all__ = ["StreamReaderIterDataPipe", ] @functional_datapipe('read_from_stream') class StreamReaderIterDataPipe(IterDataPipe[Tuple[str, bytes]]): r""" G...
1,402
34.974359
103
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/grouping.py
import warnings from collections import defaultdict from typing import Any, Callable, DefaultDict, Iterator, List, Optional, Sized, TypeVar import torch.utils.data.datapipes.iter.sharding from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import DataChunk, I...
12,269
40.452703
124
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/__init__.py
from torch.utils.data.datapipes.iter.utils import ( IterableWrapperIterDataPipe as IterableWrapper, ) from torch.utils.data.datapipes.iter.callable import ( CollatorIterDataPipe as Collator, MapperIterDataPipe as Mapper, ) from torch.utils.data.datapipes.iter.combinatorics import ( SamplerIterDataPipe a...
1,942
28.892308
59
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/combinatorics.py
import random import torch from torch.utils.data import Sampler, SequentialSampler from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import IterDataPipe from typing import Dict, Iterator, List, Optional, Sized, Tuple, Type, TypeVar __all__ = [ "SamplerI...
6,496
34.895028
122
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/callable.py
import functools from collections import namedtuple from typing import Callable, Iterator, Sized, TypeVar, Optional, Union, Any, Dict, List from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data._utils.collate import default_collate from torch.utils.data.datapipes.dataframe import...
9,041
37.476596
112
py
pytorch
pytorch-main/torch/utils/data/datapipes/iter/combining.py
import warnings from abc import ABC, abstractmethod from collections import deque import copy as copymodule from typing import Any, Callable, Iterator, List, Literal, Optional, Sized, Tuple, TypeVar, Deque from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes._hook_iter...
26,513
41.019017
123
py
pytorch
pytorch-main/torch/utils/data/datapipes/utils/snapshot.py
from torch.utils.data.datapipes._hook_iterator import _SnapshotState from torch.utils.data.datapipes.datapipe import IterDataPipe from torch.utils.data.graph_settings import apply_random_seed # TODO: Caveats # 1. Caller (either the ReadingService or DataLoader) must pass in the initial RNG # 2. `in_batch_shuffle`...
3,137
52.186441
113
py
pytorch
pytorch-main/torch/utils/data/datapipes/utils/common.py
import fnmatch import functools import inspect import os import warnings from io import IOBase from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union from torch.utils.data._utils.serialization import DILL_AVAILABLE __all__ = [ "validate_input_col", "Str...
13,463
33.880829
118
py
pytorch
pytorch-main/torch/utils/data/datapipes/utils/decoder.py
# This file takes partial of the implementation from NVIDIA's webdataset at here: # https://github.com/tmbdev/webdataset/blob/master/webdataset/autodecode.py import io import json import os.path import pickle import tempfile import torch from torch.utils.data.datapipes.utils.common import StreamWrapper __all__ = [ ...
11,023
32.609756
122
py
pytorch
pytorch-main/torch/utils/data/datapipes/map/utils.py
import copy import warnings from torch.utils.data.datapipes.datapipe import MapDataPipe __all__ = ["SequenceWrapperMapDataPipe", ] class SequenceWrapperMapDataPipe(MapDataPipe): r""" Wraps a sequence object into a MapDataPipe. Args: sequence: Sequence object to be wrapped into an MapDataPipe ...
1,547
29.96
87
py
pytorch
pytorch-main/torch/utils/data/datapipes/map/grouping.py
from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import MapDataPipe, DataChunk from typing import List, Sized, TypeVar __all__ = ["BatcherMapDataPipe", ] T = TypeVar('T') @functional_datapipe('batch') class BatcherMapDataPipe(MapDataPipe[DataChunk]): ...
2,449
35.029412
97
py
pytorch
pytorch-main/torch/utils/data/datapipes/map/__init__.py
# Functional DataPipe from torch.utils.data.datapipes.map.callable import MapperMapDataPipe as Mapper from torch.utils.data.datapipes.map.combinatorics import ShufflerIterDataPipe as Shuffler from torch.utils.data.datapipes.map.combining import ( ConcaterMapDataPipe as Concater, ZipperMapDataPipe as Zipper ) fr...
656
35.5
94
py
pytorch
pytorch-main/torch/utils/data/datapipes/map/combinatorics.py
import random import torch from torch.utils.data.datapipes.datapipe import IterDataPipe, MapDataPipe from typing import Iterator, List, Optional, TypeVar __all__ = ["ShufflerIterDataPipe", ] T_co = TypeVar('T_co', covariant=True) # @functional_datapipe('shuffle') class ShufflerIterDataPipe(IterDataPipe[T_co]): ...
4,168
32.087302
106
py
pytorch
pytorch-main/torch/utils/data/datapipes/map/callable.py
from torch.utils.data.datapipes.utils.common import _check_unpickable_fn from typing import Callable, TypeVar from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import MapDataPipe __all__ = ["MapperMapDataPipe", "default_fn"] T_co = TypeVar('T_co', covariant...
1,824
29.416667
96
py
pytorch
pytorch-main/torch/utils/data/datapipes/map/combining.py
from torch.utils.data.datapipes._decorator import functional_datapipe from torch.utils.data.datapipes.datapipe import MapDataPipe from typing import Sized, Tuple, TypeVar __all__ = ["ConcaterMapDataPipe", "ZipperMapDataPipe"] T_co = TypeVar('T_co', covariant=True) @functional_datapipe('concat') class ConcaterMapDat...
3,609
36.604167
113
py
pytorch
pytorch-main/torch/contrib/_tensorboard_vis.py
import time from collections import defaultdict from functools import partial from typing import DefaultDict import torch # Unfortunately it doesn't seem as if there was any way to get TensorBoard to do # anything without having TF installed, and so this file has a hard dependency on it # as well. It really is a deb...
5,925
40.440559
94
py
pytorch
pytorch-main/torch/profiler/_pattern_matcher.py
import json import math import os import re from typing import Dict, List, Optional, Set import torch from torch.profiler import profile import torch.utils.benchmark as benchmark from torch.profiler._utils import index_of_first_match, traverse_bfs, traverse_dfs from torch._C._profiler import (_ProfilerEvent, _ExtraFie...
25,213
37.377473
129
py
pytorch
pytorch-main/torch/profiler/_utils.py
from collections import deque from dataclasses import dataclass import functools import re from typing import Dict, List from torch.profiler import DeviceType from torch.autograd.profiler import profile from torch.autograd import _KinetoEvent def _traverse(tree, next_fn, children_fn=lambda x: x.children, reverse: bo...
13,319
36.206704
91
py
pytorch
pytorch-main/torch/profiler/_memory_profiler.py
import collections import dataclasses import enum import itertools as it import logging from typing import ( Any, cast, DefaultDict, Dict, Iterator, List, Optional, Set, Tuple, Union, ) import torch from torch._C import FunctionSchema from torch._C._autograd import _ProfilerResu...
46,578
39.858772
112
py
pytorch
pytorch-main/torch/profiler/python_tracer.py
import os import site import sys import typing import torch def _prefix_regex() -> typing.List[str]: raw_paths = ( site.getsitepackages() + sys.path + [site.getuserbase()] + [site.getusersitepackages()] + [os.path.dirname(os.path.dirname(torch.__file__))] ) path_p...
497
22.714286
81
py
pytorch
pytorch-main/torch/profiler/itt.py
from contextlib import contextmanager try: from torch._C import _itt except ImportError: class _ITTStub: @staticmethod def _fail(*args, **kwargs): raise RuntimeError("ITT functions not installed. Are you sure you have a ITT build?") @staticmethod def is_available():...
1,723
21.684211
97
py
pytorch
pytorch-main/torch/profiler/__init__.py
r""" PyTorch Profiler is a tool that allows the collection of performance metrics during training and inference. Profiler's context manager API can be used to better understand what model operators are the most expensive, examine their input shapes and stack traces, study device kernel activity and visualize the execut...
1,432
29.489362
110
py
pytorch
pytorch-main/torch/profiler/profiler.py
import gzip import json import os import tempfile from enum import Enum from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple from warnings import warn import torch import torch.autograd.profiler as prof from torch._C._profiler import ( _add_execution_trace_observer,...
28,334
39.887446
126
py
pytorch
pytorch-main/torch/quantization/fake_quantize.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/fake_quantize.py`, while adding an import statement here. ""...
1,015
29.787879
74
py
pytorch
pytorch-main/torch/quantization/fuse_modules.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/fuse_modules.py`, while adding an import statement here. """...
913
35.56
73
py
pytorch
pytorch-main/torch/quantization/quantize_jit.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/quantize_jit.py`, while adding an import statement here. """...
713
25.444444
73
py
pytorch
pytorch-main/torch/quantization/quant_type.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/quant_type.py`, while adding an import statement here. """ ...
443
36
72
py
pytorch
pytorch-main/torch/quantization/stubs.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/stubs.py`, while adding an import statement here. """ from ...
408
26.266667
72
py
pytorch
pytorch-main/torch/quantization/utils.py
# flake8: noqa: F401 r""" Utils shared by different modes of quantization (eager/graph) This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantizati...
833
26.8
72
py
pytorch
pytorch-main/torch/quantization/quantize_fx.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/quantize_fx.py`, while adding an import statement here. """ ...
746
23.9
72
py
pytorch
pytorch-main/torch/quantization/qconfig.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/qconfig.py`, while adding an import statement here. """ from...
909
28.354839
72
py
pytorch
pytorch-main/torch/quantization/_numeric_suite.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/ns/_numeric_suite.py`, while adding an import statement here. """ from t...
779
25.896552
72
py
pytorch
pytorch-main/torch/quantization/quantization_mappings.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/quantization_mappings.py`, while adding an import statement ...
1,147
37.266667
82
py
pytorch
pytorch-main/torch/quantization/_numeric_suite_fx.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/ns/_numeric_suite_fx.py`, while adding an import statement here. """ fro...
752
26.888889
72
py
pytorch
pytorch-main/torch/quantization/__init__.py
from .quantize import * # noqa: F403 from .observer import * # noqa: F403 from .qconfig import * # noqa: F403 from .fake_quantize import * # noqa: F403 from .fuse_modules import fuse_modules from .stubs import * # noqa: F403 from .quant_type import * # noqa: F403 from .quantize_jit import * # noqa: F403 # from ....
2,565
39.730159
87
py
pytorch
pytorch-main/torch/quantization/quantize.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/quantize.py`, while adding an import statement here. """ fr...
1,479
50.034483
81
py
pytorch
pytorch-main/torch/quantization/fuser_method_mappings.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/fuser_method_mappings.py`, while adding an import statement ...
511
31
82
py
pytorch
pytorch-main/torch/quantization/observer.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the `torch/ao/quantization/observer.py`, while adding an import statement here. """ fro...
1,078
28.162162
72
py
pytorch
pytorch-main/torch/quantization/fx/_equalize.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
1,250
31.076923
85
py
pytorch
pytorch-main/torch/quantization/fx/fusion_patterns.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
428
32
85
py
pytorch
pytorch-main/torch/quantization/fx/pattern_utils.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
1,288
38.060606
100
py
pytorch
pytorch-main/torch/quantization/fx/utils.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
722
33.428571
85
py
pytorch
pytorch-main/torch/quantization/fx/graph_module.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
572
30.833333
85
py
pytorch
pytorch-main/torch/quantization/fx/fuse.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
380
37.1
85
py
pytorch
pytorch-main/torch/quantization/fx/prepare.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
394
31.916667
85
py
pytorch
pytorch-main/torch/quantization/fx/quantization_patterns.py
# flake8: noqa: F401 r""" This file is in the process of migration to `torch/ao/quantization`, and is kept here for compatibility while the migration process is ongoing. If you are adding a new entry/functionality, please, add it to the appropriate files under `torch/ao/quantization/fx/`, while adding an import stateme...
2,053
50.35
97
py