python_code
stringlengths
0
1.02M
repo_name
stringlengths
9
48
file_path
stringlengths
5
114
import argparse import concurrent.futures import json import logging import os import sys from enum import Enum from pathlib import Path from typing import Any, List, NamedTuple, Optional from ufmt.core import make_black_config, ufmt_string from usort import Config as UsortConfig IS_WINDOWS: bool = os.name == "nt" ...
pytorch-master
tools/linter/adapters/ufmt_linter.py
#!/usr/bin/env python3 """ Test ownership was introduced in https://github.com/pytorch/pytorch/issues/66232. This lint verifies that every Python test file (file that matches test_*.py or *_test.py in the test folder) has valid ownership information in a comment header. Valid means: - The format of the header follow...
pytorch-master
tools/linter/adapters/testowners_linter.py
""" Checks that the configuration in .circleci/config.yml has been properly regenerated. """ import argparse import json import logging import os import subprocess import sys import time from enum import Enum from typing import List, NamedTuple, Optional CHECKED_IN_FILE = "config.yml" REGENERATION_SCRIPT = "regenera...
pytorch-master
tools/linter/adapters/circleci_linter.py
""" Initializer script that installs stuff to pip. """ import argparse import logging import os import subprocess import sys import time from typing import List def run_command(args: List[str]) -> "subprocess.CompletedProcess[bytes]": logging.debug("$ %s", " ".join(args)) start_time = time.monotonic() tr...
pytorch-master
tools/linter/adapters/pip_init.py
import argparse import json import logging import os import re import subprocess import sys import time from enum import Enum from typing import Any, Dict, List, NamedTuple, Optional, Pattern, Set IS_WINDOWS: bool = os.name == "nt" def eprint(*args: Any, **kwargs: Any) -> None: print(*args, file=sys.stderr, flu...
pytorch-master
tools/linter/adapters/flake8_linter.py
import argparse import hashlib import json import logging import os import platform import stat import subprocess import sys import textwrap import urllib.error import urllib.request from pathlib import Path # String representing the host platform (e.g. Linux, Darwin). HOST_PLATFORM = platform.system() # PyTorch dire...
pytorch-master
tools/linter/adapters/s3_init.py
"""Uploads a new binary to s3 and updates its hash in the config file. You'll need to have appropriate credentials on the PyTorch AWS buckets, see: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#configuration for how to configure them. """ import argparse import hashlib import json impo...
pytorch-master
tools/linter/adapters/update_s3.py
#!/usr/bin/env python3 """ Verify that it is possible to round-trip native_functions.yaml via ruamel under some configuration. Keeping native_functions.yaml consistent in this way allows us to run codemods on the file using ruamel without introducing line noise. Note that we don't want to normalize the YAML file, as ...
pytorch-master
tools/linter/adapters/nativefunctions_linter.py
import argparse import concurrent.futures import json import logging import os import subprocess import sys import time from enum import Enum from pathlib import Path from typing import Any, List, NamedTuple, Optional IS_WINDOWS: bool = os.name == "nt" def eprint(*args: Any, **kwargs: Any) -> None: print(*args,...
pytorch-master
tools/linter/adapters/clangformat_linter.py
""" EXEC: Ensure that source files are not executable. """ import argparse import json import logging import os import sys from enum import Enum from typing import NamedTuple, Optional LINTER_CODE = "EXEC" class LintSeverity(str, Enum): ERROR = "error" WARNING = "warning" ADVICE = "advice" DISABLED ...
pytorch-master
tools/linter/adapters/exec_linter.py
import argparse import concurrent.futures import json import logging import os import re import shutil import subprocess import sys import time from enum import Enum from pathlib import Path from sysconfig import get_paths as gp from typing import Any, List, NamedTuple, Optional, Pattern # PyTorch directory root resul...
pytorch-master
tools/linter/adapters/clangtidy_linter.py
import argparse import json import logging import os import re import subprocess import sys import time from enum import Enum from pathlib import Path from typing import Any, Dict, List, NamedTuple, Optional, Pattern IS_WINDOWS: bool = os.name == "nt" def eprint(*args: Any, **kwargs: Any) -> None: print(*args, ...
pytorch-master
tools/linter/adapters/mypy_linter.py
""" NEWLINE: Checks files to make sure there are no trailing newlines. """ import argparse import json import logging import os import sys from enum import Enum from typing import NamedTuple, Optional NEWLINE = 10 # ASCII "\n" LINTER_CODE = "NEWLINE" class LintSeverity(str, Enum): ERROR = "error" WARNING =...
pytorch-master
tools/linter/adapters/newlines_linter.py
import argparse import json import logging import shutil import subprocess import time from enum import Enum from typing import List, NamedTuple, Optional LINTER_CODE = "SHELLCHECK" class LintSeverity(str, Enum): ERROR = "error" WARNING = "warning" ADVICE = "advice" DISABLED = "disabled" class Lin...
pytorch-master
tools/linter/adapters/shellcheck_linter.py
import os import subprocess import sys from typing import List def run_cmd(cmd: List[str]) -> None: print(f"Running: {cmd}") result = subprocess.run( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) stdout, stderr = ( result.stdout.decode("utf-8").strip(), ...
pytorch-master
tools/linter/clang_tidy/generate_build_files.py
pytorch-master
tools/linter/clang_tidy/__init__.py
# Parses derivatives.yaml into autograd functions # # Each autograd function is represented by `DifferentiabilityInfo` containing # a list of `Derivative`. See `torchgen.api.autograd` for the data models. import re from collections import defaultdict from typing import Any, Counter, Dict, List, Match, Optional, Sequenc...
pytorch-master
tools/autograd/load_derivatives.py
""" To run this file by hand from the root of the PyTorch repository, run: python -m tools.autograd.gen_autograd \ aten/src/ATen/native/native_functions.yaml \ aten/src/ATen/native/tags.yaml \ $OUTPUT_DIR \ tools/autograd Where $OUTPUT_DIR is where you would like the files to be generated....
pytorch-master
tools/autograd/gen_autograd.py
# Generates Python bindings for ATen functions # # The bindings are generated as methods on python_variable or functions on the # torch._C._nn. torch._C._fft, torch._C._linalg, torch._C._sparse or torch._C._special objects. # # Code tries to stick to the following rules: # # - templates should be colocated with the fu...
pytorch-master
tools/autograd/gen_python_functions.py
# Generates C++ autograd functions for the derivatives of ATen operations # # This writes two files: # Functions.h/cpp: subclasses of autograd::Node # python_functions.h/cpp: Python bindings for the above classes # from typing import Dict, List, Sequence, Tuple from torchgen.api.autograd import ( Derivative, ...
pytorch-master
tools/autograd/gen_autograd_functions.py
# Generates C++ functions that wrap ATen tensor factory methods to turn them into Variables. # # This writes one file: variable_factories.h import re from typing import List, Optional import torchgen.api.python as python from torchgen.api import cpp from torchgen.api.types import CppSignatureGroup from torchgen.cont...
pytorch-master
tools/autograd/gen_variable_factories.py
pytorch-master
tools/autograd/__init__.py
# Generates VariableType.h/cpp # # **If any changes are being made to the VariableType codegen please also check # if updates are needed in torch/csrc/autograd/autograd_not_implemented_fallback.cpp # # VariableType is a subclass of at::Type that provides the binding code # necessary to provide a differentiable version ...
pytorch-master
tools/autograd/gen_variable_type.py
import functools from typing import Callable from torchgen.api.autograd import NativeFunctionWithDifferentiabilityInfo as NFWDI from torchgen.context import native_function_manager from torchgen.utils import T # Like tools.api.context.with_native_function, but for # NativeFunctionWithDifferentiabilityInfo. def with_n...
pytorch-master
tools/autograd/context.py
# Generates ADInplaceOrViewType.h/cpp # # NOTE: If any changes are being made to the ADInplaceOrView codegen please also check # if updates are needed in torch/csrc/autograd/autograd_not_implemented_fallback.cpp # The fallback is expected to mimick this codegen, so we should keep the two in sync. from typing import Di...
pytorch-master
tools/autograd/gen_inplace_or_view_type.py
import itertools from typing import Dict, List, Sequence, Union from torchgen.api import cpp from torchgen.api.types import DispatcherSignature from torchgen.code_template import CodeTemplate from torchgen.context import with_native_function from torchgen.model import Argument, NativeFunction, SchemaKind, TensorOptio...
pytorch-master
tools/autograd/gen_trace_type.py
""" For procedural tests needed for __torch_function__, we use this function to export method names and signatures as needed by the tests in test/test_overrides.py. python -m tools.autograd.gen_annotated_fn_args \ aten/src/ATen/native/native_functions.yaml \ aten/src/ATen/native/tags.yaml \ $OUTPU...
pytorch-master
tools/autograd/gen_annotated_fn_args.py
import lldb # type: ignore[import] # load into lldb instance with: # command script import tools/lldb/deploy_debugger.py target = lldb.debugger.GetSelectedTarget() bp = target.BreakpointCreateByRegex("__deploy_register_code") bp.SetScriptCallbackBody( """\ process = frame.thread.GetProcess() target = process.t...
pytorch-master
tools/lldb/deploy_debugger.py
#!/usr/bin/env python3 import argparse import os import sys sys.path.append( os.path.realpath( os.path.join( __file__, os.path.pardir, os.path.pardir, os.path.pardir, "torch", "utils" ) ) ) from hipify import hipify_python # type: ignore[import] parser = argparse.ArgumentParser...
pytorch-master
tools/amd_build/build_amd.py
import argparse import os import pathlib import sys from typing import Any, cast, Optional import yaml try: # use faster C loader if available from yaml import CSafeLoader as YamlLoader except ImportError: from yaml import SafeLoader as YamlLoader # type: ignore[misc] NATIVE_FUNCTIONS_PATH = "aten/src/A...
pytorch-master
tools/setup_helpers/generate_code.py
# Little stub file to get BUILD.bazel to play along import os.path import sys root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.insert(0, root) import tools.jit.gen_unboxing tools.jit.gen_unboxing.main(sys.argv[1:])
pytorch-master
tools/setup_helpers/gen_unboxing.py
import os import platform import struct import sys from itertools import chain from typing import cast, Iterable, List, Optional IS_WINDOWS = platform.system() == "Windows" IS_DARWIN = platform.system() == "Darwin" IS_LINUX = platform.system() == "Linux" IS_CONDA = ( "conda" in sys.version or "Continuum" in ...
pytorch-master
tools/setup_helpers/env.py
# Little stub file to get BUILD.bazel to play along import os.path import sys root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.insert(0, root) import torchgen.gen torchgen.gen.main()
pytorch-master
tools/setup_helpers/gen.py
""" This is refactored from cmake.py to avoid circular imports issue with env.py, which calls get_cmake_cache_variables_from_file """ import re from typing import Dict, IO, Optional, Union CMakeValue = Optional[Union[bool, str]] def convert_cmake_value_to_python_value( cmake_value: str, cmake_type: str ) -> CM...
pytorch-master
tools/setup_helpers/cmake_utils.py
"Manages CMake." import multiprocessing import os import platform import sys import sysconfig from distutils.version import LooseVersion from subprocess import CalledProcessError, check_call, check_output from typing import Any, cast, Dict, List, Optional from . import which from .cmake_utils import CMakeValue, get_...
pytorch-master
tools/setup_helpers/cmake.py
# Ideally, there would be a way in Bazel to parse version.txt # and use the version numbers from there as substitutions for # an expand_template action. Since there isn't, this silly script exists. import argparse import os from typing import cast, Dict, Tuple Version = Tuple[int, int, int] def parse_version(versio...
pytorch-master
tools/setup_helpers/gen_version_header.py
import os import sys from typing import Optional def which(thefile: str) -> Optional[str]: path = os.environ.get("PATH", os.defpath).split(os.pathsep) for d in path: fname = os.path.join(d, thefile) fnames = [fname] if sys.platform == "win32": exts = os.environ.get("PATHEXT...
pytorch-master
tools/setup_helpers/__init__.py
"""NumPy helper. Note: If you plan to add a library detection script like this one, consider it twice. Most library detection should go to CMake script. This one is an exception, because Python code can do a much better job due to NumPy's inherent Pythonic nature. """ from .env import check_negative_env_flag # Set ...
pytorch-master
tools/setup_helpers/numpy_.py
from .cwrap_common import set_declaration_defaults, sort_by_number_of_args from .module_loader import import_module
pytorch-master
tools/shared/__init__.py
# this code should be common among cwrap and ATen preprocessing # for now, I have put it in one place but right now is copied out of cwrap import copy from typing import Any, Dict, Iterable, List, Union Arg = Dict[str, Any] def parse_arguments(args: List[Union[str, Arg]]) -> List[Arg]: new_args = [] for arg...
pytorch-master
tools/shared/cwrap_common.py
from importlib.abc import Loader from types import ModuleType from typing import cast def import_module(name: str, path: str) -> ModuleType: import importlib.util spec = importlib.util.spec_from_file_location(name, path) assert spec is not None module = importlib.util.module_from_spec(spec) cast(...
pytorch-master
tools/shared/module_loader.py
#!/usr/bin/env python3 import argparse import fnmatch import pathlib import subprocess import textwrap from typing import Any, Dict, List import yaml REPO_ROOT = pathlib.Path(__file__).parent.parent.parent CONFIG_YML = REPO_ROOT / ".circleci" / "config.yml" WORKFLOWS_DIR = REPO_ROOT / ".github" / "workflows" WOR...
pytorch-master
tools/testing/explicit_ci_jobs.py
pytorch-master
tools/testing/__init__.py
import os import subprocess from typing import Dict, List, Tuple from tools.stats.import_test_stats import get_disabled_tests, get_slow_tests def calculate_shards( num_shards: int, tests: List[str], job_times: Dict[str, float] ) -> List[Tuple[float, List[str]]]: filtered_job_times: Dict[str, float] = dict()...
pytorch-master
tools/testing/test_selections.py
import modulefinder import os import pathlib import sys import warnings from typing import Any, Dict, List, Set REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent # These tests are slow enough that it's worth calculating whether the patch # touched any related files first. This list was manually genera...
pytorch-master
tools/testing/modulefinder_determinator.py
# Generates RegisterCodegenUnboxedKernels.cpp, UnboxingFunctions.h and UnboxingFunctions.cpp. import argparse import os import pathlib import sys from dataclasses import dataclass from typing import List, Sequence, Union import yaml from torchgen.api import cpp, unboxing from torchgen.api.translate import translate f...
pytorch-master
tools/jit/gen_unboxing.py
pytorch-master
tools/jit/__init__.py
pytorch-master
tools/jit/test/__init__.py
import tempfile import unittest from unittest.mock import NonCallableMock, patch import tools.jit.gen_unboxing as gen_unboxing @patch("tools.jit.gen_unboxing.get_custom_build_selector") @patch("tools.jit.gen_unboxing.parse_native_yaml") @patch("tools.jit.gen_unboxing.make_file_manager") @patch("tools.jit.gen_unboxin...
pytorch-master
tools/jit/test/test_gen_unboxing.py
pytorch-master
tools/lite_interpreter/__init__.py
#!/usr/bin/env python3 import argparse import os from typing import Set import yaml from torchgen.code_template import CodeTemplate from torchgen.selective_build.selector import SelectiveBuilder # Safely load fast C Yaml loader/dumper if they are available try: from yaml import CSafeLoader as Loader except Import...
pytorch-master
tools/lite_interpreter/gen_selected_mobile_ops_header.py
pytorch-master
tools/pyi/__init__.py
import argparse import collections from pprint import pformat from typing import Dict, List, Sequence from torchgen.api.python import ( PythonSignatureGroup, PythonSignatureNativeFunctionPair, returns_named_tuple_pyi, ) from torchgen.gen import parse_native_yaml from torchgen.model import Variant from tor...
pytorch-master
tools/pyi/gen_pyi.py
import setuptools # type: ignore[import] with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setuptools.setup( name="coverage-plugins", version="0.0.1", author="PyTorch Team", author_email="packages@pytorch.org", description="plug-in to coverage for PyTorch JIT",...
pytorch-master
tools/coverage_plugins_package/setup.py
""" This coverage plug-in attempts to cover JIT'd functions and methods that were previously missed in code coverage. Any function and method that was passed through/decorated with torch.jit.script or torch.jit.script_method should now be marked covered when coverage is run with this plug-in. DISCLAIMER: note that thi...
pytorch-master
tools/coverage_plugins_package/src/coverage_plugins/jit_plugin.py
pytorch-master
tools/coverage_plugins_package/src/coverage_plugins/__init__.py
#!/usr/bin/env python3 import argparse import json import sys from typing import Any, Dict, List, Optional import yaml from gen_op_registration_allowlist import ( canonical_name, gen_transitive_closure, load_op_dep_graph, ) from torchgen.selective_build.operator import ( merge_operator_dicts, Selec...
pytorch-master
tools/code_analyzer/gen_operators_yaml.py
#!/usr/bin/env python3 import argparse import json import os import sys from functools import reduce from typing import Any, List, Set import yaml from tools.lite_interpreter.gen_selected_mobile_ops_header import ( write_selected_mobile_ops, ) from torchgen.selective_build.selector import ( combine_selective_b...
pytorch-master
tools/code_analyzer/gen_oplist.py
""" This util is invoked from cmake to produce the op registration allowlist param for `ATen/gen.py` for custom mobile build. For custom build with dynamic dispatch, it takes the op dependency graph of ATen and the list of root ops, and outputs all transitive dependencies of the root ops as the allowlist. For custom bu...
pytorch-master
tools/code_analyzer/gen_op_registration_allowlist.py
#!/usr/bin/env python3 import time from package.oss.cov_json import get_json_report from package.oss.init import initialization from package.tool.summarize_jsons import summarize_jsons from package.util.setting import TestPlatform from package.util.utils import print_time def report_coverage() -> None: start_tim...
pytorch-master
tools/code_coverage/oss_coverage.py
pytorch-master
tools/code_coverage/package/__init__.py
pytorch-master
tools/code_coverage/package/util/__init__.py
import os from enum import Enum from typing import Dict, List, Set # <project folder> HOME_DIR = os.environ["HOME"] TOOLS_FOLDER = os.path.join( os.path.dirname(os.path.realpath(__file__)), os.path.pardir, os.path.pardir ) # <profile folder> PROFILE_DIR = os.path.join(TOOLS_FOLDER, "profile") JSON_FOLDER_BASE_D...
pytorch-master
tools/code_coverage/package/util/setting.py
import argparse import os from typing import Any from .setting import ( JSON_FOLDER_BASE_DIR, LOG_DIR, MERGED_FOLDER_BASE_DIR, Option, PROFILE_DIR, SUMMARY_FOLDER_DIR, ) from .utils import create_folder, get_raw_profiles_folder, remove_file def remove_files() -> None: # remove log rem...
pytorch-master
tools/code_coverage/package/util/utils_init.py
import os import shutil import sys import time from typing import Any, NoReturn, Optional from .setting import ( CompilerType, LOG_DIR, PROFILE_DIR, TestList, TestPlatform, TestType, ) def convert_time(seconds: float) -> str: seconds = int(round(seconds)) seconds = seconds % (24 * 360...
pytorch-master
tools/code_coverage/package/util/utils.py
import os import time from ..tool import clang_coverage, gcc_coverage from ..util.setting import TestList, TestPlatform from ..util.utils import get_raw_profiles_folder, print_time from .utils import get_oss_binary_file def clang_run(tests: TestList) -> None: start_time = time.time() for test in tests: ...
pytorch-master
tools/code_coverage/package/oss/run.py
pytorch-master
tools/code_coverage/package/oss/__init__.py
import os import subprocess from typing import List, Optional from ..util.setting import CompilerType, TestType, TOOLS_FOLDER from ..util.utils import print_error, remove_file def get_oss_binary_folder(test_type: TestType) -> str: assert test_type in {TestType.CPP, TestType.PY} # TODO: change the way we get ...
pytorch-master
tools/code_coverage/package/oss/utils.py
from ..tool import clang_coverage from ..util.setting import CompilerType, Option, TestList, TestPlatform from ..util.utils import check_compiler_type from .init import detect_compiler_type # type: ignore[attr-defined] from .run import clang_run, gcc_run def get_json_report(test_list: TestList, options: Option) -> N...
pytorch-master
tools/code_coverage/package/oss/cov_json.py
import argparse import os from typing import cast, List, Optional, Tuple from ..util.setting import ( CompilerType, JSON_FOLDER_BASE_DIR, LOG_DIR, Option, Test, TestList, TestType, ) from ..util.utils import ( clean_up, create_folder, print_log, raise_no_test_found_exception...
pytorch-master
tools/code_coverage/package/oss/init.py
import json import os import time from typing import Any, Dict, List, Set, Tuple from ..util.setting import ( CompilerType, JSON_FOLDER_BASE_DIR, TestList, TestPlatform, TestStatusType, ) from ..util.utils import ( detect_compiler_type, print_error, print_time, related_to_test_list,...
pytorch-master
tools/code_coverage/package/tool/summarize_jsons.py
pytorch-master
tools/code_coverage/package/tool/__init__.py
import os import subprocess import time from typing import Dict # gcc is only used in oss from ..oss.utils import get_gcda_files, run_oss_python_test from ..util.setting import JSON_FOLDER_BASE_DIR, TestType from ..util.utils import print_log, print_time from .utils import run_cpp_test def update_gzip_dict(gzip_dict...
pytorch-master
tools/code_coverage/package/tool/gcc_coverage.py
import os import subprocess import time from typing import List from ..util.setting import ( JSON_FOLDER_BASE_DIR, MERGED_FOLDER_BASE_DIR, TestList, TestPlatform, TestType, ) from ..util.utils import ( check_platform_type, convert_to_relative_path, create_folder, get_raw_profiles_fo...
pytorch-master
tools/code_coverage/package/tool/clang_coverage.py
import subprocess from ..util.setting import TestPlatform from ..util.utils import print_error def run_cpp_test(binary_file: str) -> None: # cpp test binary try: subprocess.check_call(binary_file) except subprocess.CalledProcessError: print_error(f"Binary failed to run: {binary_file}") ...
pytorch-master
tools/code_coverage/package/tool/utils.py
import os import subprocess from typing import Dict, IO, List, Set, Tuple from ..oss.utils import get_pytorch_folder from ..util.setting import SUMMARY_FOLDER_DIR, TestList, TestStatusType CoverageItem = Tuple[str, float, int, int] def key_by_percentage(x: CoverageItem) -> float: return x[1] def key_by_name(x...
pytorch-master
tools/code_coverage/package/tool/print_report.py
from typing import List, NamedTuple, Optional, Tuple class LlvmCoverageSegment(NamedTuple): line: int col: int segment_count: int has_count: int is_region_entry: int is_gap_entry: Optional[int] @property def has_coverage(self) -> bool: return self.segment_count > 0 @prope...
pytorch-master
tools/code_coverage/package/tool/parser/llvm_coverage_segment.py
from typing import Any, Dict, List, Set, Tuple from .coverage_record import CoverageRecord from .llvm_coverage_segment import LlvmCoverageSegment, parse_segments class LlvmCoverageParser: """ Accepts a parsed json produced by llvm-cov export -- typically, representing a single C++ test and produces a lis...
pytorch-master
tools/code_coverage/package/tool/parser/llvm_coverage_parser.py
from typing import Any, Dict, List, Set from .coverage_record import CoverageRecord class GcovCoverageParser: """ Accepts a parsed json produced by gcov --json-format -- typically, representing a single C++ test and produces a list of CoverageRecord(s). """ def __init__(self, llvm_coverage: ...
pytorch-master
tools/code_coverage/package/tool/parser/gcov_coverage_parser.py
pytorch-master
tools/code_coverage/package/tool/parser/__init__.py
import typing as t class CoverageRecord(t.NamedTuple): filepath: str covered_lines: t.List[int] uncovered_lines: t.Optional[t.List[int]] = None def to_dict(self) -> t.Dict[str, t.Any]: return { "filepath": self.filepath, "covered_lines": self.covered_lines, ...
pytorch-master
tools/code_coverage/package/tool/parser/coverage_record.py
#!/usr/bin/env python3 import datetime import json import signal import time from typing import Any, Dict, List import psutil # type: ignore[import] import pynvml # type: ignore[import] def get_processes_running_python_tests() -> List[Any]: python_processes = [] for process in psutil.process_iter(): ...
pytorch-master
tools/stats/monitor.py
#!/usr/bin/env python3 import datetime import json import os import pathlib import re from typing import Any, Callable, cast, Dict, List, Optional from urllib.request import urlopen def get_disabled_issues() -> List[str]: pr_body = os.getenv("PR_BODY", "") commit_messages = os.getenv("COMMIT_MESSAGES", "") ...
pytorch-master
tools/stats/import_test_stats.py
import gzip import io import json import os import zipfile from pathlib import Path from typing import Any, Dict, List import boto3 # type: ignore[import] import requests import rockset # type: ignore[import] PYTORCH_REPO = "https://api.github.com/repos/pytorch/pytorch" S3_RESOURCE = boto3.resource("s3") def _get...
pytorch-master
tools/stats/upload_stats_lib.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import bz2 import datetime import json import math import os import re import statistics import subprocess import time from collections import defaultdict from pathlib import Path from typing import ( Any, cast, DefaultDict, Dict, Iterable, Iterato...
pytorch-master
tools/stats/print_test_stats.py
import base64 import bz2 import json import os from typing import Any _lambda_client = None def sprint(*args: Any) -> None: print("[scribe]", *args) def aws_lambda() -> Any: global _lambda_client # lazy import so that we don't need to introduce extra dependencies import boto3 # type: ignore[impor...
pytorch-master
tools/stats/scribe.py
pytorch-master
tools/stats/__init__.py
import argparse import json import os from pathlib import Path from tempfile import TemporaryDirectory from typing import Any, Dict, List from tools.stats.upload_stats_lib import ( download_gha_artifacts, download_s3_artifacts, unzip, upload_to_rockset, ) def get_sccache_stats( workflow_run_id: i...
pytorch-master
tools/stats/upload_sccache_stats.py
import pathlib import sys REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent sys.path.append(str(REPO_ROOT)) from tools.stats.import_test_stats import get_test_times TEST_TIMES_FILE = ".pytorch-test-times.json" def main() -> None: print(f"Exporting test times from test-infra to {TEST_TIMES_FILE}"...
pytorch-master
tools/stats/export_test_times.py
import bz2 import json import logging import subprocess from collections import defaultdict from datetime import datetime, timedelta from typing import Any, cast, Dict, List, Optional, Tuple, Union from typing_extensions import Literal, TypedDict try: import boto3 # type: ignore[import] import botocore # ty...
pytorch-master
tools/stats/s3_stat_parser.py
#!/usr/bin/env python3 import argparse import subprocess import sys from datetime import datetime, timezone from signal import SIG_DFL, signal, SIGPIPE from typing import Dict, Iterator, List, Optional, Set, Tuple from tools.stats.s3_stat_parser import get_cases, get_test_stats_summaries, Report def get_git_commit_...
pytorch-master
tools/stats/test_history.py
import argparse import os import sys import xml.etree.ElementTree as ET from pathlib import Path from tempfile import TemporaryDirectory from typing import Any, Dict, List, Tuple from tools.stats.upload_stats_lib import ( download_gha_artifacts, download_s3_artifacts, unzip, upload_to_s3, ) def get_j...
pytorch-master
tools/stats/upload_test_stats.py
# -*- coding: utf-8 -*- # Owner(s): ["module: mps"] import sys import math import random import unittest import warnings import subprocess import tempfile import os import pprint import torch import torch.nn as nn import torch.nn.functional as F import itertools from collections import defaultdict from torch._six impo...
pytorch-master
test/test_mps.py
# Owner(s): ["oncall: jit"] import torch from torch.cuda.amp import autocast from typing import Optional, Tuple import unittest from test_jit import JitTestCase from torch.testing._internal.common_cuda import TEST_CUDA from torch.testing._internal.common_utils import run_tests from torch.testing import FileCheck from...
pytorch-master
test/test_jit_autocast.py
pytorch-master
test/delete.py
# Owner(s): ["module: ci"] import os import run_test from torch.testing._internal.common_utils import TestCase, run_tests class DummyOptions(object): verbose = False class DeterminationTest(TestCase): # Test determination on a subset of tests TESTS = [ "test_nn", "test_jit_profiling", ...
pytorch-master
test/test_determination.py
# Owner(s): ["module: dispatch"] import torch._C as C from torch.testing._internal.common_utils import TestCase, run_tests from torch._python_dispatcher import PythonDispatcher from collections import namedtuple import itertools import os import re import torch.utils.cpp_extension # TODO: Expand the dispatcher API t...
pytorch-master
test/test_dispatch.py
# Owner(s): ["module: scatter & gather ops"] from itertools import product from functools import partial import numpy as np import torch from torch.testing._internal.common_device_type import ( instantiate_device_type_tests, dtypes, ) from torch.testing._internal.common_utils import ( TestCase, run_te...
pytorch-master
test/test_segment_reductions.py
# Owner(s): ["module: fx"] import copy import sys import logging from typing import List, Tuple import torch from torch.fx._symbolic_trace import symbolic_trace from torch.fx.experimental.proxy_tensor import make_fx from torch.fx.passes.backends.nvfuser import NvFuserBackend from torch.testing._internal.common_utils...
pytorch-master
test/test_fx_backends.py
# Owner(s): ["module: masked operators"] """Tests for masked operations. """ import itertools import torch from typing import List, Any from functools import wraps import unittest from torch.testing._internal.common_utils import \ (TestCase, parametrize, suppress_warnings, _TestParametrizer, run_tests) from torc...
pytorch-master
test/test_masked.py