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/scripts/release_notes/namespace_check.py
import argparse import torch from os import path import json # Import all utils so that getattr below can find them from torch.utils import bottleneck, checkpoint, model_zoo all_submod_list = [ "", "nn", "nn.functional", "nn.init", "optim", "autograd", "cuda", "sparse", "distributi...
3,186
26.008475
106
py
pytorch
pytorch-main/scripts/release_notes/classifier.py
import argparse from pathlib import Path import torch import torchtext from torchtext.functional import to_tensor import torch.nn as nn import torch.nn.functional as F from typing import List, Dict import pandas as pd from dataclasses import dataclass import math import pickle import random from tqdm import tqdm from i...
14,504
39.51676
147
py
pytorch
pytorch-main/scripts/release_notes/categorize.py
import argparse import os import textwrap from common import topics, get_commit_data_cache from commitlist import CommitList # Imports for working with classi from classifier import CommitClassifier, CategoryConfig, XLMR_BASE, get_author_map, get_file_map, CommitClassifierInputs import common import torch from pathlib...
6,818
37.965714
133
py
pytorch
pytorch-main/scripts/release_notes/commitlist.py
import argparse from common import run, topics, get_features, frontend_categories from collections import defaultdict import os from pathlib import Path import csv import pprint import common from common import get_commit_data_cache, features_to_dict import re import dataclasses from typing import List """ Example Us...
19,929
41.58547
421
py
pytorch
pytorch-main/scripts/release_notes/common.py
from collections import namedtuple from pathlib import Path import locale import subprocess import re import requests import os import json from dataclasses import dataclass @dataclass class CategoryGroup: name: str categories: list frontend_categories = [ 'meta', 'nn', 'linalg', 'cpp', 'p...
7,519
23.900662
132
py
pytorch
pytorch-main/scripts/jit/log_extract.py
import argparse import functools import traceback from torch.utils.jit.log_extract import extract_ir, load_graph_and_inputs, run_baseline_no_fusion, run_nnc, run_nvfuser from typing import List, Tuple, Callable, Optional ''' Usage: 1. Run your script and pipe into a log file PYTORCH_JIT_LOG_LEVEL=">>graph_fuser" pyt...
4,135
38.390476
130
py
pytorch
pytorch-main/android/pytorch_android/generate_test_torchscripts.py
import torch from torch import Tensor from typing import Dict, List, Tuple, Optional OUTPUT_DIR = "src/androidTest/assets/" def scriptAndSave(module, fileName): print('-' * 80) script_module = torch.jit.script(module) print(script_module.graph) outputFileName = OUTPUT_DIR + fileName # note that th...
3,906
27.727941
102
py
pytorch
pytorch-main/android/test_app/make_assets.py
import torch import torchvision print(torch.version.__version__) resnet18 = torchvision.models.resnet18(pretrained=True) resnet18.eval() resnet18_traced = torch.jit.trace(resnet18, torch.rand(1, 3, 224, 224)).save("app/src/main/assets/resnet18.pt") resnet50 = torchvision.models.resnet50(pretrained=True) resnet50.eva...
629
36.058824
111
py
pytorch
pytorch-main/android/test_app/make_assets_custom.py
""" This is a script for PyTorch Android custom selective build test. It prepares MobileNetV2 TorchScript model, and dumps root ops used by the model for custom build script to create a tailored build which only contains these used ops. """ import torch import torchvision import yaml # Download and trace the model. m...
806
30.038462
78
py
pytorch
pytorch-main/.ci/pytorch/perf_test/compare_with_baseline.py
import sys import json import math import argparse parser = argparse.ArgumentParser() parser.add_argument('--test-name', dest='test_name', action='store', required=True, help='test name') parser.add_argument('--sample-stats', dest='sample_stats', action='store', required=True, h...
2,571
31.15
78
py
pytorch
pytorch-main/.ci/pytorch/win-test-helpers/run_python_nn_smoketests.py
#!/usr/bin/env python3 import subprocess import os COMMON_TESTS = [ ( "Checking that torch is available", "import torch", ), ( "Checking that MKL is available", "import torch; exit(0 if torch.backends.mkl.is_available() else 1)", ), ] GPU_TESTS = [ ( "Check...
1,760
30.446429
99
py
pytorch
pytorch-main/docs/caffe2/process.py
#!/usr/bin/env python3 ## @package process # Module doxygen.process # Script to insert preamble for doxygen and regen API docs import os import shutil # Module caffe2...caffe2.python.control_test def insert(originalfile, first_line, description): with open(originalfile, 'r') as f: f1 = f.readline() ...
2,022
34.491228
99
py
pytorch
pytorch-main/docs/cpp/source/conf.py
# -*- coding: utf-8 -*- # # PyTorch documentation build configuration file, created by # sphinx-quickstart on Fri Dec 23 13:31:47 2016. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # A...
9,310
35.089147
83
py
pytorch
pytorch-main/docs/source/conf.py
# -*- coding: utf-8 -*- # # PyTorch documentation build configuration file, created by # sphinx-quickstart on Fri Dec 23 13:31:47 2016. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # A...
23,143
29.293194
109
py
pytorch
pytorch-main/docs/source/scripts/build_opsets.py
import os from pathlib import Path import torch from collections import OrderedDict from torchgen.gen import parse_native_yaml import torch._prims as prims ROOT = Path(__file__).absolute().parent.parent.parent.parent NATIVE_FUNCTION_YAML_PATH = ROOT / Path("aten/src/ATen/native/native_functions.yaml") TAGS_YAML_PATH ...
2,071
26.626667
85
py
pytorch
pytorch-main/docs/source/scripts/build_activation_images.py
""" This script will generate input-out plots for all of the activation functions. These are for use in the documentation, and potentially in online tutorials. """ from pathlib import Path import torch import matplotlib from matplotlib import pyplot as plt matplotlib.use("Agg") # Create a directory for the images,...
2,109
25.375
78
py
pytorch
pytorch-main/docs/source/scripts/build_quantization_configs.py
""" This script will generate default values of quantization configs. These are for use in the documentation. """ import torch from torch.ao.quantization.backend_config import get_native_backend_config_dict from torch.ao.quantization.backend_config.utils import ( entry_to_pretty_str, remove_boolean_dispatch_fr...
1,920
29.492063
96
py
pytorch
pytorch-main/docs/source/scripts/exportdb/generate_example_rst.py
import inspect import os import re from pathlib import Path import torch import torch._dynamo as torchdynamo from torch._export import export from torch._export.db.case import ExportCase, normalize_inputs from torch._export.db.examples import all_examples PWD = Path(__file__).absolute().parent ROOT = Path(__file__)...
4,512
24.788571
96
py
pytorch
pytorch-main/docs/source/scripts/onnx/build_onnx_diagnostics_rules_md.py
import argparse import os from dataclasses import fields from torch.onnx._internal import diagnostics from torch.onnx._internal.diagnostics import infra def gen_docs(out_dir: str): os.makedirs(out_dir, exist_ok=True) for field in fields(diagnostics.rules): rule = getattr(diagnostics.rules, field.name...
1,115
28.368421
78
py
pytorch
pytorch-main/docs/source/scripts/onnx/build_onnx_supported_aten_op_csv_table.py
""" This script generates a CSV table with all ATen operators supported by `torch.onnx.export`. The generated table is included by docs/source/onnx_supported_aten_list.rst. """ import os from torch.onnx import _onnx_supported_ops # Constants BUILD_DIR = "build/onnx" SUPPORTED_OPS_CSV_FILE = "auto_gen_supported_op_lis...
1,989
27.84058
75
py
pytorch
pytorch-main/aten/src/ATen/native/quantized/cpu/qnnpack/configure.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import confu from confu import arm, x86 parser = confu.standard_parser() def main(ar...
12,127
41.554386
82
py
pytorch
pytorch-main/functorch/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch # Top-level APIs. Please think carefully before adding something to the # top-level namespace: # - p...
996
33.37931
81
py
pytorch
pytorch-main/functorch/_src/aot_autograd/__init__.py
# This file has moved to under torch/_functorch. It is not public API. # If you are not a PyTorch developer and you are relying on the following # imports, please file an issue. from torch._functorch.aot_autograd import ( aot_autograd_decompositions, KNOWN_TYPES, PytreeThunk, )
291
31.444444
73
py
pytorch
pytorch-main/functorch/_src/vmap/__init__.py
# This file has moved to under torch/_functorch. It is not public API. # If you are not a PyTorch developer and you are relying on the following # imports, please file an issue. from torch._functorch.vmap import ( _add_batch_dim, _broadcast_to_and_flatten, _get_name, _remove_batch_dim, _validate_and...
467
26.529412
73
py
pytorch
pytorch-main/functorch/_src/make_functional/__init__.py
# This file has moved to under torch/_functorch. It is not public API. # If you are not a PyTorch developer and you are relying on the following # imports, please file an issue. from torch._functorch.make_functional import _swap_state
235
46.2
73
py
pytorch
pytorch-main/functorch/_src/eager_transforms/__init__.py
# This file has moved to under torch/_functorch. It is not public API. # If you are not a PyTorch developer and you are relying on the following # imports, please file an issue. from torch._functorch.eager_transforms import ( _unwrap_functional_tensor, _assert_wrapped_functional, )
291
35.5
73
py
pytorch
pytorch-main/functorch/dim/batch_tensor.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from torch._C._functorch import ( _vmap_add_layers, _vmap_remove_layers, ) from contextlib import context...
678
24.148148
78
py
pytorch
pytorch-main/functorch/dim/tree_map.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functorch._C import dim tree_flatten = dim.tree_flatten def tree_map(fn, tree): vs, unflatten = tree_fl...
372
27.692308
71
py
pytorch
pytorch-main/functorch/dim/wrap_type.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from types import FunctionType, BuiltinMethodType, MethodDescriptorType, WrapperDescriptorType, GetSetDescriptorT...
1,697
32.96
118
py
pytorch
pytorch-main/functorch/dim/op_properties.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch # pointwise operators can go through a faster pathway tensor_magic_methods = [ 'add', '' ] p...
6,568
22.212014
77
py
pytorch
pytorch-main/functorch/dim/__init__.py
import torch from typing import Union, Sequence import inspect import dis from .tree_map import tree_flatten, tree_map from .wrap_type import wrap_type import functorch._C from functorch._C import dim as _C _C._patch_tensor_class() dims, DimList, dimlists = _C.dims, _C.DimList, _C.dimlists class DimensionMismatchError...
4,711
26.395349
129
py
pytorch
pytorch-main/functorch/dim/delayed_mul_tensor.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from . import _Tensor, Tensor from .reference import _dims, _enable_layers, llist, ltuple class Dela...
2,338
33.397059
96
py
pytorch
pytorch-main/functorch/dim/reference.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # reference python implementations for C ops import torch from .tree_map import tree_flatten, tree_map from .batc...
19,731
34.362007
128
py
pytorch
pytorch-main/functorch/benchmarks/chrome_trace_parser.py
#!/usr/bin/env python3 import argparse import os import logging import pandas as pd from torch._functorch.benchmark_utils import compute_utilization # process the chrome traces output by the pytorch profiler # require the json input file's name to be in format {model_name}_chrome_trace_*.json # the runtimes file sho...
2,192
30.782609
91
py
pytorch
pytorch-main/functorch/benchmarks/pointwise_scorecard.py
import sys import time import torch import inspect import itertools from functorch import pointwise_operator torch.set_num_threads(1) torch._C._debug_set_fusion_group_inlining(False) def rand(*shape): return torch.rand(*shape).mul(16).add(1) # -------------------------------------------------------------------...
5,939
24.826087
116
py
pytorch
pytorch-main/functorch/benchmarks/cse.py
import torch import torch.fx as fx from functorch import make_fx from torch.profiler import profile, ProfilerActivity from torch._functorch.compile_utils import fx_graph_cse def profile_it(f, inp): for _ in range(5): f(inp) itr = 5 with profile(activities=[ProfilerActivity.CUDA], record_shapes=Tr...
2,399
22.076923
104
py
pytorch
pytorch-main/functorch/benchmarks/per_sample_grads.py
import torch import torch.nn as nn import torchvision.models as models from opacus.utils.module_modification import convert_batchnorm_modules import time from functorch import vmap, grad from functorch import make_functional from opacus import PrivacyEngine device = 'cuda' batch_size = 128 torch.manual_seed(0) model...
2,703
27.765957
77
py
pytorch
pytorch-main/functorch/benchmarks/operator_authoring.py
from functools import partial import numpy as np import pandas as pd import timeit import torch from functorch.compile import pointwise_operator WRITE_CSV = False CUDA = False SIZES = [1, 512, 8192] NUMBER = [100, 10, 1, 1] REPEAT = 20 @pointwise_operator def nnc_add(a, b): return a + b @pointwise_operator def...
7,616
28.183908
88
py
pytorch
pytorch-main/functorch/examples/compilation/eager_fusion.py
from functorch.compile import aot_function, tvm_compile import torch import time import torch.utils a = torch.randn(2000, 1, 4, requires_grad=True) b = torch.randn(1, 2000, 4) def f(a): return (a * b).sum(dim=0) fw_compiler = tvm_compile(target='llvm', tuning_logfile='fw_keops') bw_compiler = tvm_compile(targe...
1,164
20.181818
67
py
pytorch
pytorch-main/functorch/examples/compilation/simple_function.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functorch import grad, make_fx from functorch.compile import nnc_jit import torch import time def f(x): ...
760
20.742857
71
py
pytorch
pytorch-main/functorch/examples/compilation/fuse_module.py
import timeit from functorch.compile import compiled_module, tvm_compile import torch.nn as nn import torch def nop(f, _): return f fw_compiler = tvm_compile(target='llvm', tuning_logfile='fw_keops') bw_compiler = tvm_compile(target='llvm', tuning_logfile='bw_keops') fw_compiler = nop bw_compiler = nop def ru...
1,438
24.696429
76
py
pytorch
pytorch-main/functorch/examples/compilation/linear_train.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functorch import make_functional from functorch.compile import nnc_jit import torch import torch.nn as nn im...
2,147
22.604396
93
py
pytorch
pytorch-main/functorch/examples/dp_cifar10/cifar10_transforms.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Runs CIFAR10 training with differential privacy. """ import argparse import logging import shutil import sys from datetime import datetime, timedelta import numpy as np import torch import torch.nn as nn import torch.op...
14,965
29.356998
155
py
pytorch
pytorch-main/functorch/examples/dp_cifar10/cifar10_opacus.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Runs CIFAR10 training with differential privacy. """ import argparse import logging import shutil import sys from datetime import datetime, timedelta import numpy as np import torch import torch.nn as nn import torch.op...
13,432
27.580851
155
py
pytorch
pytorch-main/functorch/examples/lennard_jones/lennard_jones.py
# This example was adapated from https://github.com/muhrin/milad # It is licensed under the GLPv3 license. You can find a copy of it # here: https://www.gnu.org/licenses/gpl-3.0.en.html . import torch from torch import nn from torch.nn.functional import mse_loss from torch.func import jacrev, vmap sigma = 0.5 epsilon...
2,016
27.408451
102
py
pytorch
pytorch-main/functorch/examples/maml_omniglot/maml-omniglot-transforms.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
8,801
33.249027
109
py
pytorch
pytorch-main/functorch/examples/maml_omniglot/maml-omniglot-ptonly.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
9,262
34.087121
109
py
pytorch
pytorch-main/functorch/examples/maml_omniglot/maml-omniglot-higher.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
9,516
34.248148
109
py
pytorch
pytorch-main/functorch/examples/maml_omniglot/support/omniglot_loaders.py
# Copyright (c) Facebook, Inc. and its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
11,730
37.716172
116
py
pytorch
pytorch-main/functorch/examples/ensembling/parallel_train.py
import argparse import math import torch import torch.nn as nn import torch.nn.functional as F from torch.func import functional_call, grad_and_value, vmap, stack_module_state # Adapted from http://willwhitney.com/parallel-training-jax.html , which is a # tutorial on Model Ensembling with JAX by Will Whitney. # # The ...
4,727
32.295775
91
py
pytorch
pytorch-main/functorch/examples/maml_regression/evjang_transforms.py
# Eric Jang originally wrote an implementation of MAML in JAX # (https://github.com/ericjang/maml-jax). # We translated his implementation from JAX to PyTorch. from torch.func import grad, vmap import matplotlib.pyplot as plt import math import torch import numpy as np from torch.nn import functional as F import matpl...
3,494
25.884615
92
py
pytorch
pytorch-main/functorch/examples/maml_regression/evjang_transforms_module.py
# Eric Jang originally wrote an implementation of MAML in JAX # (https://github.com/ericjang/maml-jax). # We translated his implementation from JAX to PyTorch. from functorch import grad, vmap, make_functional import matplotlib.pyplot as plt import math import torch import numpy as np from torch import nn from torch.n...
3,394
25.732283
87
py
pytorch
pytorch-main/functorch/examples/maml_regression/evjang.py
# Eric Jang originally wrote an implementation of MAML in JAX # (https://github.com/ericjang/maml-jax). # We translated his implementation from JAX to PyTorch. import matplotlib.pyplot as plt import math import torch import numpy as np from torch.nn import functional as F import matplotlib as mpl mpl.use('Agg') def ...
3,571
28.04065
112
py
pytorch
pytorch-main/functorch/op_analysis/gen_data.py
import yaml import csv import torch from collections import defaultdict def get_ops_for_key(key): # Needs modified PyTorch C++ code to work if key is None: ops = torch._C._dispatch_get_registrations_for_dispatch_key() else: ops = torch._C._dispatch_get_registrations_for_dispatch_key(key) ...
5,536
34.044304
122
py
pytorch
pytorch-main/functorch/docs/source/conf.py
# -*- coding: utf-8 -*- # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensi...
10,837
31.449102
92
py
pytorch
pytorch-main/functorch/compile/__init__.py
from torch._functorch.python_key import pythonkey_decompose from torch._functorch.fx_minifier import minifier from torch._functorch.aot_autograd import ( aot_function, aot_module, compiled_function, compiled_module, aot_module_simplified, get_graph_being_compiled, get_aot_graph_name, get...
776
23.28125
59
py
pytorch
pytorch-main/functorch/einops/rearrange.py
from __future__ import annotations import functools from typing import Callable, Dict, List, Sequence, Tuple, Union import torch from functorch._C import dim as _C from ._parsing import AnonymousAxis, _ellipsis, comma_separate, parse_pattern, validate_rearrange_expressions __all__ = ["rearrange"] dims = _C.dims @...
7,811
41.227027
120
py
pytorch
pytorch-main/functorch/experimental/_cond.py
from dataclasses import dataclass import torch from torch.multiprocessing.reductions import StorageWeakRef import torch.utils._pytree as pytree from torch._C import DispatchKey, DispatchKeySet, _ExcludeDispatchKeyGuard from torch._functorch.eager_transforms import _unwrap_all_tensors_from_functional, _wrap_all_tensor...
13,088
39.903125
129
py
pytorch
pytorch-main/functorch/experimental/_map.py
import torch import torch.utils._pytree as pytree from torch._C import DispatchKey, DispatchKeySet, _ExcludeDispatchKeyGuard from torch._functorch.eager_transforms import _unwrap_all_tensors_from_functional, _wrap_all_tensors_to_functional, functionalize from torch._functorch.aot_autograd import create_joint, AOTConfig...
14,049
42.63354
129
py
pytorch
pytorch-main/functorch/experimental/__init__.py
# PyTorch forward-mode is not mature yet from torch._functorch.eager_transforms import hessian, jacfwd, jvp from torch._functorch.vmap import chunk_vmap from torch._functorch.batch_norm_replacement import replace_all_batch_norm_modules_ from functorch import functionalize
273
44.666667
83
py
pytorch
pytorch-main/functorch/experimental/ops.py
from torch._ops import HigherOrderOperator # noqa: F401
57
28
56
py
pytorch
pytorch-main/functorch/notebooks/_src/plot_ensembling.py
""" ========================== Model ensembling ========================== This example illustrates how to vectorize model ensembling using vmap. What is model ensembling? -------------------------------------------------------------------- Model ensembling combines the predictions from multiple models together. Tradi...
4,767
41.954955
89
py
pytorch
pytorch-main/functorch/notebooks/_src/plot_per_sample_gradients.py
""" ========================== Per-sample-gradients ========================== What is it? -------------------------------------------------------------------- Per-sample-gradient computation is computing the gradient for each and every sample in a batch of data. It is a useful quantity in differential privacy and opt...
5,052
39.424
86
py
pytorch
pytorch-main/functorch/notebooks/_src/plot_jacobians_and_hessians.py
""" ============================= Jacobians, hessians, and more ============================= Computing jacobians or hessians are useful in a number of non-traditional deep learning models. It is difficult (or annoying) to compute these quantities efficiently using a standard autodiff system like PyTorch Autograd; fun...
7,950
44.434286
88
py
pytorch
pytorch-main/binaries/bench_gen/bench_gen.py
#!/usr/bin/env python3 import argparse import ast from caffe2.python.model_helper import ModelHelper from caffe2.python.predictor import mobile_exporter from caffe2.python import workspace, brew def parse_kwarg(kwarg_str): key, value = kwarg_str.split('=') try: value = ast.literal_eval(value) ex...
3,438
36.791209
90
py
pytorch
pytorch-main/ios/TestApp/custom_build/custom_build.py
import torch import torchvision import yaml model = torchvision.models.mobilenet_v2(pretrained=True) model.eval() example = torch.rand(1, 3, 224, 224) traced_script_module = torch.jit.trace(model, example) ops = torch.jit.export_opnames(traced_script_module) with open('mobilenetv2.yaml', 'w') as output: yaml.dump(...
333
26.833333
56
py
pytorch
pytorch-main/ios/TestApp/benchmark/trace_model.py
import torch import torchvision from torch.utils.mobile_optimizer import optimize_for_mobile model = torchvision.models.mobilenet_v2(pretrained=True) model.eval() example = torch.rand(1, 3, 224, 224) traced_script_module = torch.jit.trace(model, example) optimized_scripted_module = optimize_for_mobile(traced_script_mo...
508
41.416667
117
py
pytorch
pytorch-main/ios/TestApp/benchmark/coreml_backend.py
import torch import torchvision from torch.backends._coreml.preprocess import ( CompileSpec, TensorSpec, CoreMLComputeUnit, ) def mobilenetv2_spec(): return { "forward": CompileSpec( inputs=( TensorSpec( shape=[1, 3, 224, 224], ),...
1,000
22.833333
69
py
pytorch
pytorch-main/torchgen/gen_lazy_tensor.py
import argparse import os import pathlib import re from collections import Counter, namedtuple from typing import ( Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, Tuple, Type, Union, ) import yaml import torchgen.dest as dest from torchgen.api.lazy impo...
23,240
37.351485
118
py
pytorch
pytorch-main/torchgen/gen_functionalization_type.py
from dataclasses import dataclass from typing import Callable, List, Optional, Tuple, Union from torchgen.api import cpp, dispatcher from torchgen.api.translate import translate from torchgen.api.types import ( BaseCType, Binding, CType, DispatcherSignature, FunctionalizationLambda, iTensorList...
34,259
42.587786
129
py
pytorch
pytorch-main/torchgen/gen_backend_stubs.py
import argparse import os import pathlib import re from collections import Counter, defaultdict, namedtuple from typing import Dict, List, Optional, Sequence, Set, Union import yaml import torchgen.api.dispatcher as dispatcher import torchgen.dest as dest from torchgen.api.types import DispatcherSignature from torchg...
22,374
35.680328
124
py
pytorch
pytorch-main/torchgen/context.py
import contextlib import functools from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union import torchgen.local as local from torchgen.model import ( BackendIndex, DispatchKey, NativeFunction, NativeFunctionsGroup, NativeFunctionsViewGroup, ) from torchgen.utils im...
3,974
29.813953
90
py
pytorch
pytorch-main/torchgen/native_function_generation.py
from collections import defaultdict from typing import Dict, List, Optional, Sequence, Tuple, Union import torchgen.api.dispatcher as dispatcher from torchgen.api.translate import translate from torchgen.api.types import Binding, DispatcherSignature, Expr from torchgen.context import with_native_function from torchge...
29,113
44.993681
388
py
pytorch
pytorch-main/torchgen/utils.py
import contextlib import functools import hashlib import os import re import sys import textwrap from argparse import Namespace from dataclasses import fields, is_dataclass from enum import auto, Enum from typing import ( Any, Callable, Dict, Generic, Iterable, Iterator, List, Literal, ...
15,887
30.903614
110
py
pytorch
pytorch-main/torchgen/model.py
import dataclasses import itertools import re from dataclasses import dataclass from enum import auto, Enum from typing import Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Union from torchgen.utils import assert_never, NamespaceHelper, OrderedSet # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
109,621
39.037253
438
py
pytorch
pytorch-main/torchgen/gen.py
import argparse import functools import json import os import pathlib from collections import defaultdict, namedtuple, OrderedDict from dataclasses import dataclass from typing import ( Any, Callable, Dict, List, Literal, Optional, Sequence, Set, Tuple, TypeVar, Union, ) imp...
108,268
36.69812
130
py
pytorch
pytorch-main/torchgen/__init__.py
"""torchgen This module contains codegeneration utilities for PyTorch. It is used to build PyTorch from source, but may also be used for out-of-tree projects that extend PyTorch. Note well that we provide no BC guarantees for torchgen. If you're interested in using torchgen and want the PyTorch team to be aware, plea...
348
30.727273
77
py
pytorch
pytorch-main/torchgen/gen_vmap_plumbing.py
import textwrap from dataclasses import dataclass from typing import List, Optional, Sequence, Tuple from torchgen.api.translate import translate from torchgen.api.types import DispatcherSignature from torchgen.context import method_with_native_function from torchgen.model import ( Argument, BaseTy, BaseTy...
9,188
33.545113
119
py
pytorch
pytorch-main/torchgen/gen_executorch.py
import argparse import os import pathlib from collections import defaultdict from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Sequence, TextIO, Tuple, Union import yaml # Parse native_functions.yaml into a sequence of NativeFunctions and Backend Indices. from torchgen import d...
33,659
35.31068
121
py
pytorch
pytorch-main/torchgen/executorch/model.py
# Represents all kernels used by an Executorch model. # It maintains a Dict[OperatorName, Dict[ETKernelKey, BackendMetadata]] structure. import itertools from collections import defaultdict, namedtuple from dataclasses import dataclass from enum import IntEnum from typing import Dict, List, Tuple, Union from torchgen...
7,710
33.891403
119
py
pytorch
pytorch-main/torchgen/executorch/parse.py
from collections import defaultdict, namedtuple from typing import Any, Dict, List, Optional, Set, Tuple import yaml from torchgen.executorch.model import ETKernelIndex, ETKernelKey from torchgen.gen import LineLoader, parse_native_yaml from torchgen.model import ( BackendMetadata, DispatchKey, FunctionS...
5,423
34.684211
107
py
pytorch
pytorch-main/torchgen/executorch/api/custom_ops.py
from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Tuple from torchgen import dest # disable import sorting to avoid circular dependency. from torchgen.api.types import DispatcherSignature # isort:skip from torchgen.context import method_with_nat...
4,846
35.719697
113
py
pytorch
pytorch-main/torchgen/executorch/api/et_cpp.py
from typing import List, Optional, Sequence, Set, Union from torchgen import local from torchgen.api.types import ( ArgName, ArrayCType, BaseCType, Binding, ConstRefCType, CType, MutRefCType, NamedCType, SpecialArgName, TupleCType, VectorCType, voidT, ) from torchgen.mod...
12,960
34.124661
117
py
pytorch
pytorch-main/torchgen/executorch/api/unboxing.py
from dataclasses import dataclass from typing import Callable, List, Sequence, Tuple from torchgen.api.types import Binding, CType, NamedCType from torchgen.model import ( Argument, BaseTy, BaseType, ListType, NativeFunction, OptionalType, Type, ) connector = "\n\t" # Return unboxing fun...
7,764
35.285047
125
py
pytorch
pytorch-main/torchgen/executorch/api/types/types.py
from dataclasses import dataclass from typing import Dict from torchgen.api.types import ( BaseCppType, BaseCType, Binding, boolT, CType, doubleT, Expr, longT, MutRefCType, NamedCType, ) from torchgen.model import BaseTy halfT = BaseCppType("torch::executor", "Half") bfloat16T ...
2,432
28.670732
93
py
pytorch
pytorch-main/torchgen/executorch/api/types/signatures.py
from dataclasses import dataclass from typing import List, Optional, Set import torchgen.api.cpp as aten_cpp from torchgen.api.types import Binding, CType from torchgen.model import FunctionSchema, NativeFunction from .types import contextArg @dataclass(frozen=True) class ExecutorchCppSignature: """ This s...
2,490
32.662162
87
py
pytorch
pytorch-main/torchgen/api/structured.py
from typing import List, Union from torchgen.api import cpp from torchgen.api.types import ( ArgName, ArrayRefCType, BaseCType, Binding, ConstRefCType, dimnameListT, intArrayRefT, iOptTensorListRefT, iTensorListRefT, NamedCType, OptionalCType, optionalIntArrayRefT, ...
6,166
37.786164
88
py
pytorch
pytorch-main/torchgen/api/autograd.py
import re from dataclasses import dataclass from typing import cast, Dict, List, Match, Optional, Sequence, Set, Tuple from torchgen import local from torchgen.api import cpp from torchgen.api.types import BaseCType, Binding, NamedCType, tensorListT from torchgen.model import ( FunctionSchema, ListType, N...
34,665
43.67268
118
py
pytorch
pytorch-main/torchgen/api/python.py
from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Set, Tuple, Union from torchgen.api import cpp from torchgen.api.types import Binding, CppSignature, CppSignatureGroup from torchgen.gen import pythonify_default from torchgen.model import ( Argument, BaseTy, BaseType, ...
57,070
37.587559
150
py
pytorch
pytorch-main/torchgen/api/translate.py
from typing import Dict, List, NoReturn, Sequence, Union from torchgen.api.types import ( ArrayRefCType, BaseCType, Binding, boolT, ConstRefCType, deviceT, Expr, intArrayRefT, iOptTensorListRefT, layoutT, ListCType, longT, memoryFormatT, MutRefCType, NamedCTy...
19,140
43.410673
129
py
pytorch
pytorch-main/torchgen/api/dispatcher.py
import itertools from typing import List, Sequence, Union from torchgen.api import cpp from torchgen.api.types import ArgName, Binding, CType, NamedCType from torchgen.model import ( Argument, FunctionSchema, Return, SelfArgument, TensorOptionsArguments, Type, ) from torchgen.utils import asse...
3,365
27.285714
88
py
pytorch
pytorch-main/torchgen/api/functionalization.py
from typing import List, Optional from torchgen.api import dispatcher from torchgen.api.types import ( BaseCType, Binding, boolT, ConstRefCType, CType, longT, NamedCType, tensorT, ) from torchgen.model import ( Argument, BaseTy, BaseType, FunctionSchema, NativeFuncti...
6,931
38.163842
128
py
pytorch
pytorch-main/torchgen/api/unboxing.py
from typing import List, Tuple from torchgen.api import cpp from torchgen.api.types import Binding, CppSignatureGroup, CType from torchgen.model import ( Argument, BaseTy, BaseType, ListType, NativeFunction, OptionalType, Type, ) # This file generates the code for unboxing wrappers, i.e., ...
9,474
37.052209
118
py
pytorch
pytorch-main/torchgen/api/meta.py
from torchgen.model import NativeFunctionsGroup # Follows dispatcher calling convention, but: # - Mutable arguments not allowed. Meta functions are always # written in functional form. Look at FunctionSchema.signature() # - No tensor returns; instead we return a TensorMeta describing # the tensor in ques...
482
36.153846
69
py
pytorch
pytorch-main/torchgen/api/native.py
from typing import List, Optional, Sequence, Union from torchgen import local from torchgen.api import cpp from torchgen.api.types import ( ArgName, BaseCType, Binding, boolT, ConstRefCType, CType, deviceT, layoutT, ListCType, MutRefCType, NamedCType, OptionalCType, ...
5,136
32.357143
88
py
pytorch
pytorch-main/torchgen/api/lazy.py
from typing import Any, Dict, List, Optional, Tuple, Union from torchgen.api.types import ( BaseCppType, BaseCType, boolT, CType, deviceT, doubleT, layoutT, ListCType, longT, memoryFormatT, NamedCType, OptionalCType, scalarT, scalarTypeT, stringT, SymIntT...
17,393
35.773784
109
py
pytorch
pytorch-main/torchgen/api/cpp.py
from typing import List, Optional, Sequence, Set, Union from torchgen import local from torchgen.api.types import ( ArgName, ArrayCType, ArrayRefCType, BaseCType, BaseTypeToCppMapping, Binding, boolT, ConstRefCType, CType, dimnameListT, intArrayRefT, iTensorListRefT, ...
16,286
34.101293
116
py
pytorch
pytorch-main/torchgen/api/ufunc.py
from dataclasses import dataclass from typing import List, Optional import torchgen.api.types as api_types from torchgen.api import cpp, structured from torchgen.api.types import ( ArgName, BaseCppType, BaseCType, Binding, ConstRefCType, CType, NamedCType, scalarT, ) from torchgen.mode...
6,698
30.9
91
py
pytorch
pytorch-main/torchgen/api/types/types.py
""" Where should I add a new type? `types_base.py` vs `types.py` This file defines data model classes for torchgen typing system, as well as some base types such as int32_t. `types.py` defines ATen Tensor type and some c10 types, along with signatures that use these types. The difference between these two files, is ...
6,098
32.327869
114
py
pytorch
pytorch-main/torchgen/api/types/signatures.py
from dataclasses import dataclass from typing import Iterator, List, Optional, Sequence, Set, Tuple, Union from torchgen.model import ( BackendIndex, FunctionSchema, NativeFunction, NativeFunctionsGroup, NativeFunctionsViewGroup, ) from .types_base import Binding, CType, Expr @dataclass(frozen=...
15,713
35.974118
124
py