python_code
stringlengths
0
1.02M
repo_name
stringlengths
9
48
file_path
stringlengths
5
114
from .prepare import prepare from .convert import convert from .fuse import fuse
pytorch-master
torch/ao/quantization/fx/__init__.py
import copy import re import torch import torch.nn as nn from torch.ao.quantization import QuantType from torch.ao.quantization.utils import is_per_tensor, is_per_channel from torch.ao.quantization.quantize import is_activation_post_process from torch.fx import GraphModule, map_arg from torch.fx.graph import ( Gr...
pytorch-master
torch/ao/quantization/fx/utils.py
from .quantization_patterns import ( QuantizeHandler, ) # TODO: remove class CommonQuantizeHandler(QuantizeHandler): """ Common quantized op, first input and first output will be quantized """ pass
pytorch-master
torch/ao/quantization/fx/common_quantization_patterns.py
import torch from torch.ao.quantization.fx.pattern_utils import get_default_quant_patterns, sorted_patterns_dict from torch.ao.quantization.backend_config import get_native_backend_config from torch.ao.quantization.backend_config.observation_type import ObservationType from torch.ao.quantization.quantization_types impo...
pytorch-master
torch/ao/quantization/fx/backend_config_utils.py
from collections import OrderedDict from typing import Dict, Any from torch.ao.quantization.quantization_types import Pattern from ..fake_quantize import FixedQParamsFakeQuantize # from .quantization_patterns import BinaryOpQuantizeHandler from ..observer import ObserverBase import copy # TODO(future PR): fix the typi...
pytorch-master
torch/ao/quantization/fx/pattern_utils.py
import torch from torch.fx import map_arg, Node from torch.fx.graph import Graph import torch.nn as nn import torch.nn.functional as F import torch.nn.intrinsic as nni import torch.nn.intrinsic.quantized as nniq import torch.nn.intrinsic.quantized.dynamic as nniqd import torch.nn.quantized as nnq import torch.nn.quanti...
pytorch-master
torch/ao/quantization/fx/_lower_to_native_backend.py
from __future__ import annotations from dataclasses import dataclass from typing import Any, Dict, List, Optional, Tuple, Type from torch.ao.quantization import QConfigMapping from torch.ao.quantization.backend_config import BackendConfig from torch.ao.quantization.quant_type import QuantType, _quant_type_from_str, qu...
pytorch-master
torch/ao/quantization/fx/custom_config.py
from torch.fx import ( GraphModule, Node, map_arg ) from torch.fx.graph import Graph from .graph_module import ( FusedGraphModule ) from .match_utils import ( is_match, MatchAllNode, ) from .pattern_utils import ( sorted_patterns_dict, ) from ..backend_config import ( BackendConfig, ...
pytorch-master
torch/ao/quantization/fx/fuse.py
import sys import torch from torch.fx.graph import ( Graph, Node, ) from torch.ao.quantization.quantization_types import Pattern from .quantization_patterns import ( QuantizeHandler, ) from ..qconfig import ( QConfigAny, ) from ..utils import ( MatchAllNode ) from .graph_module import ( is_obser...
pytorch-master
torch/ao/quantization/fx/match_utils.py
import copy import torch import operator import warnings from torch.fx import ( GraphModule, ) from torch.fx.graph import ( Graph, Node, ) from torch.fx.node import Argument from ..quantize import ( propagate_qconfig_, ) from ..observer import ( ObserverBase, ) from ..qconfig import ( obs_or_fq...
pytorch-master
torch/ao/quantization/fx/prepare.py
import torch from torch.fx._symbolic_trace import Tracer from torch.fx.node import Target, Node, Argument from torch.nn.intrinsic import _FusedModule from typing import List, Callable, Tuple, Any, Dict, Optional __all__ = [ "QuantizationTracer", ] class Scope(object): """ Scope object that records the module ...
pytorch-master
torch/ao/quantization/fx/tracer.py
import torch from torch.fx.graph import ( Node, ) from .utils import ( all_node_args_have_no_tensors, ) from torch.ao.quantization.quantization_types import ( Pattern, NodePattern, ) from abc import ABC from typing import Any, Callable, Dict, Optional def _default_root_node_getter(node_pattern): ...
pytorch-master
torch/ao/quantization/fx/quantization_patterns.py
from typing import Any, Dict, Set, Tuple, Callable, List import torch import torch.nn as nn import torch.nn.qat as nnqat from abc import ABC, abstractmethod from torch.ao.quantization.fake_quantize import FakeQuantize from torch.ao.quantization.fx.graph_module import GraphModule from torch.ao.quantization.observer imp...
pytorch-master
torch/ao/quantization/fx/_model_report/detector.py
import torch from typing import Any, Set, Dict, List, Tuple, OrderedDict from collections import OrderedDict as OrdDict # try to import tablate got_tabulate = True try: from tabulate import tabulate except ImportError: got_tabulate = False # var to see if we could import matplotlib got_matplotlib = True try:...
pytorch-master
torch/ao/quantization/fx/_model_report/model_report_visualizer.py
import torch from torch.ao.quantization.observer import ObserverBase class ModelReportObserver(ObserverBase): r"""This observer is used to record additional information regarding keeping track of S = average_batch_activation_range/epoch_activation_range. The purpose of this information is to prepare a re...
pytorch-master
torch/ao/quantization/fx/_model_report/model_report_observer.py
pytorch-master
torch/ao/quantization/fx/_model_report/__init__.py
from typing import Any, Dict, Set, Tuple from collections import OrderedDict import torch from torch.ao.quantization.fx._model_report.detector import ( DetectorBase, DETECTOR_OBS_ARGS_KEY, DETECTOR_OBS_TO_INSERT_KEY, DETECTOR_IS_POST_OBS_KEY, DETECTOR_TARGET_NODE_KEY ) from torch.ao.quantization.fx....
pytorch-master
torch/ao/quantization/fx/_model_report/model_report.py
""" Contains model level utilities which can be aware of the AutoQuantizationState type. """ import torch import torch.nn.functional as F toq = torch.ops.quantized from .mappings import conv_ops, conv_prepack_fns from .quantization_state import AutoQuantizationState from torch.quantization import ( ObserverBase, ...
pytorch-master
torch/ao/quantization/_dbr/model_utils.py
import copy import math import operator from types import ModuleType from typing import Callable, Any, Tuple, Dict import torch import torch.fx from .mappings import conv_ops from .quantization_state import AutoQuantizationState from .utils import ( get_packable_arg_idxs, AutoQuantizationStateModuleDict, ) cl...
pytorch-master
torch/ao/quantization/_dbr/auto_trace_rewriter.py
from typing import Dict, Tuple, Callable, Optional from .mappings import known_function_fusion_patterns_and_replacements from .utils import ( FusionInfo, SeenQOpInfo, get_users_of_seen_q_op_info, get_producer_of_seen_q_op_info, ) def _identity(x): return x def pattern_is_match( fusion_pattern...
pytorch-master
torch/ao/quantization/_dbr/function_fusion.py
import torch from torch.jit._recursive import wrap_cpp_module def remove_redundant_aliases(scripted_module: torch.nn.Module): """ Running torch.jit.trace on a model with DBR quantization introduces extra alias ops, because we use `torch.Tensor.as_subclass` and tracing through this results in an `aten::...
pytorch-master
torch/ao/quantization/_dbr/torchscript_utils.py
pytorch-master
torch/ao/quantization/_dbr/__init__.py
import logging from typing import Tuple, Any, List, Dict import torch from torch.fx.node import map_aggregate from .quantization_state import ( AutoQuantizationState, ) from .utils import ( trace_with_inputs, is_leaf, HookType, get_torch_function_hook_type, get_module_hook_type, OpQuantize...
pytorch-master
torch/ao/quantization/_dbr/auto_trace.py
from typing import Dict, Callable, Any, Optional import torch from torch.nn.intrinsic import _FusedModule from ..utils import ( activation_is_int8_quantized, activation_is_int32_quantized, op_is_int8_dynamically_quantized, ) from torch.ao.quantization import swap_module from torch.ao.quantization.quantiza...
pytorch-master
torch/ao/quantization/_dbr/module_swap_utils.py
import dataclasses import enum from typing import Callable, Tuple, Any, List, Optional, Dict import torch import torch.nn.functional as F toq = torch.ops.quantized from .mappings import ( functions_supported_by_quantization, module_types_supported_by_quantization, module_types_supported_by_quantization_pr...
pytorch-master
torch/ao/quantization/_dbr/utils.py
from typing import List import torch from .function_fusion import pattern_is_match from .utils import ( get_users_of_seen_q_op_info, ) from .mappings import ( known_module_fusion_patterns, ) def get_module_fusion_fqns( module: torch.nn.Module, ) -> List[List[str]]: """ Input: a module with auto...
pytorch-master
torch/ao/quantization/_dbr/fusion.py
from typing import Callable, List, Tuple, Any, Optional, Dict import torch import torch.nn.functional as F from .mappings import ( conv_ops, ops_are_related, ) from .utils import ( _raise_obs_not_found_error, _raise_obs_op_mismatch, op_needs_quantization, SeenQOpInfo, SeenNonQOpInfo, ...
pytorch-master
torch/ao/quantization/_dbr/quantization_state.py
import torch from typing import Callable, Dict from ..qconfig_mapping import QConfigMapping TYPE_TO_REPLACEMENT_TYPE: Dict[Callable, Callable] = { torch.add: torch.Tensor.add, torch.Tensor.add_: torch.Tensor.add, torch.mul: torch.Tensor.mul, torch.Tensor.mul_: torch.Tensor.mul, } def normalize_object_...
pytorch-master
torch/ao/quantization/_dbr/qconfig_mapping_utils.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.quantized as nnq toq = torch.ops.quantized from torch.ao.quantization.quantization_mappings import ( DEFAULT_STATIC_QUANT_MODULE_MAPPINGS, DEFAULT_DYNAMIC_QUANT_MODULE_MAPPINGS, DEFAULT_REFERENCE_STATIC_QUANT_MODULE_MAPPINGS,...
pytorch-master
torch/ao/quantization/_dbr/mappings.py
import builtins import collections import math import operator import warnings from collections.abc import Iterable from enum import Enum from functools import partial, reduce, wraps from typing import Callable, List, Optional, overload, Sequence, Tuple, Union import torch import torch._prims as prims import torch._...
pytorch-master
torch/_refs/__init__.py
import math from typing import Iterable, List, NamedTuple, Optional, Sequence, Tuple, Union from typing_extensions import Literal import torch import torch._prims as prims import torch._prims_common as utils from torch._decomp import register_decomposition from torch._prims_common import check, DimsType, ShapeType, ...
pytorch-master
torch/_refs/fft.py
from functools import partial from typing import List, Optional, Tuple, Union import torch import torch._prims as prims import torch._prims_common as utils import torch._refs as refs import torch._refs.linalg as linalg from torch import Tensor from torch._prims_common import ( check, check_fp_or_complex, ...
pytorch-master
torch/_refs/linalg/__init__.py
from typing import List __all__: List[str] = []
pytorch-master
torch/_refs/nn/__init__.py
from typing import Optional, Union import torch import torch._prims as prims import torch._prims_common as utils import torch._refs as refs from torch._decomp import register_decomposition from torch._prims_common import ( check, ELEMENTWISE_TYPE_PROMOTION_KIND, NumberType, ShapeType, TensorLike, ...
pytorch-master
torch/_refs/nn/functional/__init__.py
from typing import Optional import torch import torch._prims as prims import torch._prims_common as utils import torch._refs as refs from torch import Tensor from torch._decomp import register_decomposition from torch._prims_common import ELEMENTWISE_TYPE_PROMOTION_KIND, TensorLikeType from torch._prims_common.wrappe...
pytorch-master
torch/_refs/special/__init__.py
import sys import torch from torch._C import _add_docstr, _fft # type: ignore[attr-defined] from torch._torch_docs import factory_common_args, common_args __all__ = ['fft', 'ifft', 'fft2', 'ifft2', 'fftn', 'ifftn', 'rfft', 'irfft', 'rfft2', 'irfft2', 'rfftn', 'irfftn', 'hfft', 'ihfft', 'fftfreq...
pytorch-master
torch/fft/__init__.py
from contextlib import contextmanager try: from torch._C import _itt except ImportError: class _ITTStub(object): @staticmethod def _fail(*args, **kwargs): raise RuntimeError("ITT functions not installed. Are you sure you have a ITT build?") rangePush = _fail rangePo...
pytorch-master
torch/profiler/itt.py
from collections import deque import json import math import os import re from typing import Dict, List, Set import torch from torch.profiler import profile import torch.utils.benchmark as benchmark from torch.profiler._utils import index_of_first_match from torch._C._autograd import (_ProfilerEvent, _ExtraFields_Torc...
pytorch-master
torch/profiler/_pattern_matcher.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...
pytorch-master
torch/profiler/__init__.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._autograd import ( _ExperimentalConfig, _add_...
pytorch-master
torch/profiler/profiler.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...
pytorch-master
torch/profiler/python_tracer.py
from collections import deque from dataclasses import dataclass import re from typing import Dict, List from torch.profiler import DeviceType from torch.autograd.profiler import profile from torch.autograd import _KinetoEvent @dataclass class EventMetrics: duration_time_ns: int = 0 self_time_ns: int = 0 ...
pytorch-master
torch/profiler/_utils.py
# The Tensor classes are added to this module by python_tensor.cpp from typing import Optional, Tuple, List, Union import torch from torch._C import _add_docstr, _sparse # type: ignore[attr-defined] from torch import Tensor # A workaround to support both TorchScript and MyPy: from typing import TYPE_CHECKING if TYPE...
pytorch-master
torch/sparse/__init__.py
pytorch-master
torch/nested/__init__.py
from numbers import Number import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import broadcast_all __all__ = ['Laplace'] class Laplace(Distribution): r""" Creates a Laplace distribution parameterized by :attr:`loc` ...
pytorch-master
torch/distributions/laplace.py
import torch from numbers import Number from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.transformed_distribution import TransformedDistribution from torch.distributions.transforms import SigmoidTransform from torch.distributions.utils import...
pytorch-master
torch/distributions/relaxed_bernoulli.py
import torch from torch._six import nan from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import probs_to_logits, logits_to_probs, lazy_property __all__ = ['Categorical'] class Categorical(Distribution): r""" Creates a categori...
pytorch-master
torch/distributions/categorical.py
import functools import math import numbers import operator import weakref from typing import List import torch import torch.nn.functional as F from torch.distributions import constraints from torch.distributions.utils import (_sum_rightmost, broadcast_all, lazy_property, tril_ma...
pytorch-master
torch/distributions/transforms.py
import torch from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily __all__ = ['Dirichlet'] # This helper is exposed for testing. def _Dirichlet_backward(x, concentration, grad...
pytorch-master
torch/distributions/dirichlet.py
from torch.distributions import constraints from torch.distributions.transforms import ExpTransform from torch.distributions.normal import Normal from torch.distributions.transformed_distribution import TransformedDistribution __all__ = ['LogNormal'] class LogNormal(TransformedDistribution): r""" Creates a lo...
pytorch-master
torch/distributions/log_normal.py
import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.independent import Independent from torch.distributions.transforms import ComposeTransform, Transform from torch.distributions.utils import _sum_rightmost from typing import Dict ...
pytorch-master
torch/distributions/transformed_distribution.py
from numbers import Number import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import broadcast_all, probs_to_logits, logits_to_probs, lazy_property from torch.nn.functional import binary_cross_entropy_with_logits __all__ = ...
pytorch-master
torch/distributions/geometric.py
import torch from torch.distributions import constraints from torch.distributions.exponential import Exponential from torch.distributions.transformed_distribution import TransformedDistribution from torch.distributions.transforms import AffineTransform, PowerTransform from torch.distributions.utils import broadcast_all...
pytorch-master
torch/distributions/weibull.py
import math import torch from torch._six import inf, nan from torch.distributions import Chi2, constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import _standard_normal, broadcast_all __all__ = ['StudentT'] class StudentT(Distribution): r""" Creates a Studen...
pytorch-master
torch/distributions/studentT.py
import math import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import _standard_normal, lazy_property __all__ = ['MultivariateNormal'] def _batch_mv(bmat, bvec): r""" Performs a batched matrix-vector product, with ...
pytorch-master
torch/distributions/multivariate_normal.py
import math from numbers import Real from numbers import Number import torch from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import _standard_normal, broadcast_all __all__ = ['Normal'] class Normal(ExponentialFamily): r""" ...
pytorch-master
torch/distributions/normal.py
from numbers import Number import torch from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import broadcast_all __all__ = ['Poisson'] class Poisson(ExponentialFamily): r""" Creates a Poisson distribution parameterized by :at...
pytorch-master
torch/distributions/poisson.py
from numbers import Real, Number import torch from torch.distributions import constraints from torch.distributions.dirichlet import Dirichlet from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import broadcast_all __all__ = ['Beta'] class Beta(ExponentialFamily): r""" ...
pytorch-master
torch/distributions/beta.py
import torch from torch._six import nan from torch.distributions import constraints from torch.distributions.uniform import Uniform from torch.distributions.transformed_distribution import TransformedDistribution from torch.distributions.transforms import AffineTransform, PowerTransform from torch.distributions.utils i...
pytorch-master
torch/distributions/kumaraswamy.py
import math import torch from torch._six import inf from torch.distributions import constraints from torch.distributions.transforms import AbsTransform from torch.distributions.normal import Normal from torch.distributions.transformed_distribution import TransformedDistribution __all__ = ['HalfNormal'] class HalfNor...
pytorch-master
torch/distributions/half_normal.py
import torch from torch.distributions import constraints from torch.distributions.categorical import Categorical from torch.distributions.utils import clamp_probs, broadcast_all from torch.distributions.distribution import Distribution from torch.distributions.transformed_distribution import TransformedDistribution fro...
pytorch-master
torch/distributions/relaxed_categorical.py
import math import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.multivariate_normal import _batch_mahalanobis, _batch_mv from torch.distributions.utils import _standard_normal, lazy_property __all__ = ['LowRankMultivariateNormal']...
pytorch-master
torch/distributions/lowrank_multivariate_normal.py
import math import torch from torch._six import inf from torch.distributions import constraints from torch.distributions.transforms import AbsTransform from torch.distributions.cauchy import Cauchy from torch.distributions.transformed_distribution import TransformedDistribution __all__ = ['HalfCauchy'] class HalfCau...
pytorch-master
torch/distributions/half_cauchy.py
r""" The ``distributions`` package contains parameterizable probability distributions and sampling functions. This allows the construction of stochastic computation graphs and stochastic gradient estimators for optimization. This package generally follows the design of the `TensorFlow Distributions`_ package. .. _`Ten...
pytorch-master
torch/distributions/__init__.py
""" This closely follows the implementation in NumPyro (https://github.com/pyro-ppl/numpyro). Original copyright notice: # Copyright: Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 """ import math import torch from torch.distributions import constraints, Beta from torch.distributions.distri...
pytorch-master
torch/distributions/lkj_cholesky.py
import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import _sum_rightmost from typing import Dict __all__ = ['Independent'] class Independent(Distribution): r""" Reinterprets some of the batch dims of a distribution ...
pytorch-master
torch/distributions/independent.py
import torch from torch._six import inf from torch.distributions.binomial import Binomial from torch.distributions.distribution import Distribution from torch.distributions import Categorical from torch.distributions import constraints from torch.distributions.utils import broadcast_all __all__ = ['Multinomial'] clas...
pytorch-master
torch/distributions/multinomial.py
from numbers import Number import torch from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import broadcast_all __all__ = ['Exponential'] class Exponential(ExponentialFamily): r""" Creates a Exponential distribution paramete...
pytorch-master
torch/distributions/exponential.py
from torch.distributions import constraints from torch.distributions.exponential import Exponential from torch.distributions.transformed_distribution import TransformedDistribution from torch.distributions.transforms import AffineTransform, ExpTransform from torch.distributions.utils import broadcast_all __all__ = ['P...
pytorch-master
torch/distributions/pareto.py
import torch import torch.nn.functional as F from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import broadcast_all, probs_to_logits, lazy_property, logits_to_probs __all__ = ['NegativeBinomial'] class NegativeBinomial(Distribution): ...
pytorch-master
torch/distributions/negative_binomial.py
import math from torch._six import inf, nan from numbers import Number import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import broadcast_all __all__ = ['Cauchy'] class Cauchy(Distribution): r""" Samples from a Ca...
pytorch-master
torch/distributions/cauchy.py
import math import torch import torch.jit from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import broadcast_all, lazy_property __all__ = ['VonMises'] def _eval_poly(y, coef): coef = list(coef) result = coef.pop() while co...
pytorch-master
torch/distributions/von_mises.py
import torch import warnings from torch.distributions import constraints from torch.distributions.utils import lazy_property from typing import Dict, Optional, Any __all__ = ['Distribution'] class Distribution(object): r""" Distribution is the abstract base class for probability distributions. """ ha...
pytorch-master
torch/distributions/distribution.py
from numbers import Number import math import torch from torch.distributions import constraints from torch.distributions.uniform import Uniform from torch.distributions.transformed_distribution import TransformedDistribution from torch.distributions.transforms import AffineTransform, ExpTransform from torch.distributio...
pytorch-master
torch/distributions/gumbel.py
r""" PyTorch provides two global :class:`ConstraintRegistry` objects that link :class:`~torch.distributions.constraints.Constraint` objects to :class:`~torch.distributions.transforms.Transform` objects. These objects both input constraints and return transforms, but they have different guarantees on bijectivity. 1. ``...
pytorch-master
torch/distributions/constraint_registry.py
from functools import update_wrapper from numbers import Number import torch import torch.nn.functional as F from typing import Dict, Any from torch.overrides import is_tensor_like euler_constant = 0.57721566490153286060 # Euler Mascheroni Constant def broadcast_all(*values): r""" Given a list of values (po...
pytorch-master
torch/distributions/utils.py
import math import warnings from functools import total_ordering from typing import Type, Dict, Callable, Tuple import torch from torch._six import inf from .bernoulli import Bernoulli from .beta import Beta from .binomial import Binomial from .categorical import Categorical from .cauchy import Cauchy from .continuou...
pytorch-master
torch/distributions/kl.py
import torch from torch.distributions.distribution import Distribution from torch.distributions import Categorical from torch.distributions import constraints from typing import Dict __all__ = ['MixtureSameFamily'] class MixtureSameFamily(Distribution): r""" The `MixtureSameFamily` distribution implements a (...
pytorch-master
torch/distributions/mixture_same_family.py
from numbers import Number import math import torch from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import broadcast_all, probs_to_logits, logits_to_probs, lazy_property, clamp_probs from torch.nn.functional import binary_cross_ent...
pytorch-master
torch/distributions/continuous_bernoulli.py
from numbers import Number import torch from torch._six import nan from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.gamma import Gamma from torch.distributions.utils import broadcast_all __all__ = ['FisherSnedecor'] class FisherSnedecor(Dis...
pytorch-master
torch/distributions/fishersnedecor.py
r""" The following constraints are implemented: - ``constraints.boolean`` - ``constraints.cat`` - ``constraints.corr_cholesky`` - ``constraints.dependent`` - ``constraints.greater_than(lower_bound)`` - ``constraints.greater_than_eq(lower_bound)`` - ``constraints.independent(constraint, reinterpreted_batch_ndims)`` - `...
pytorch-master
torch/distributions/constraints.py
from numbers import Number import torch from torch._six import nan from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import broadcast_all __all__ = ['Uniform'] class Uniform(Distribution): r""" Generates uniformly distributed ...
pytorch-master
torch/distributions/uniform.py
from numbers import Number import torch from torch._six import nan from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import broadcast_all, probs_to_logits, logits_to_probs, lazy_property from torch.nn.functional import binary_cross_e...
pytorch-master
torch/distributions/bernoulli.py
import torch from torch.distributions.distribution import Distribution __all__ = ['ExponentialFamily'] class ExponentialFamily(Distribution): r""" ExponentialFamily is the abstract base class for probability distributions belonging to an exponential family, whose probability mass/density function has the ...
pytorch-master
torch/distributions/exp_family.py
from torch.distributions import constraints from torch.distributions.normal import Normal from torch.distributions.transformed_distribution import TransformedDistribution from torch.distributions.transforms import StickBreakingTransform __all__ = ['LogisticNormal'] class LogisticNormal(TransformedDistribution): r...
pytorch-master
torch/distributions/logistic_normal.py
import torch from torch.distributions import constraints from torch.distributions.categorical import Categorical from torch.distributions.distribution import Distribution __all__ = ['OneHotCategorical', 'OneHotCategoricalStraightThrough'] class OneHotCategorical(Distribution): r""" Creates a one-hot categoric...
pytorch-master
torch/distributions/one_hot_categorical.py
import math import warnings from numbers import Number from typing import Union import torch from torch._six import nan from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import lazy_property from torch.distributions.multivariate_norm...
pytorch-master
torch/distributions/wishart.py
from numbers import Number import torch from torch.distributions import constraints from torch.distributions.exp_family import ExponentialFamily from torch.distributions.utils import broadcast_all __all__ = ['Gamma'] def _standard_gamma(concentration): return torch._standard_gamma(concentration) class Gamma(Ex...
pytorch-master
torch/distributions/gamma.py
from torch.distributions import constraints from torch.distributions.gamma import Gamma __all__ = ['Chi2'] class Chi2(Gamma): r""" Creates a Chi-squared distribution parameterized by shape parameter :attr:`df`. This is exactly equivalent to ``Gamma(alpha=0.5*df, beta=0.5)`` Example:: >>> # x...
pytorch-master
torch/distributions/chi2.py
import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.utils import broadcast_all, probs_to_logits, lazy_property, logits_to_probs __all__ = ['Binomial'] def _clamp_by_zero(x): # works like clamp(x, min=0) but has grad at 0 is 0....
pytorch-master
torch/distributions/binomial.py
import collections import importlib.machinery import io import linecache import pickletools import platform import types from collections import defaultdict, OrderedDict from dataclasses import dataclass from enum import Enum from pathlib import Path from typing import ( Any, BinaryIO, Callable, cast, ...
pytorch-master
torch/package/package_exporter.py
# -*- coding: utf-8 -*- from typing import Dict, List from .glob_group import GlobGroup, GlobPattern __all__ = ["Directory"] class Directory: """A file structure representation. Organized as Directory nodes that have lists of their Directory children. Directories for a package are created by calling :me...
pytorch-master
torch/package/file_structure_representation.py
_magic_methods = [ "__subclasscheck__", "__hex__", "__rmul__", "__float__", "__idiv__", "__setattr__", "__div__", "__invert__", "__nonzero__", "__rshift__", "__eq__", "__pos__", "__round__", "__rand__", "__or__", "__complex__", "__divmod__", "__len...
pytorch-master
torch/package/_mock.py
import importlib from abc import ABC, abstractmethod from pickle import ( # type: ignore[attr-defined] # type: ignore[attr-defined] _getattribute, _Pickler, whichmodule as _pickle_whichmodule, ) from types import ModuleType from typing import Any, Dict, List, Optional, Tuple from ._mangling import demang...
pytorch-master
torch/package/importer.py
"""List of Python standard library modules. Sadly, there is no reliable way to tell whether a module is part of the standard library except by comparing to a canonical list. This is taken from https://github.com/PyCQA/isort/tree/develop/isort/stdlibs, which itself is sourced from the Python documentation. """ import...
pytorch-master
torch/package/_stdlib.py
"""Import mangling. See mangling.md for details. """ import re _mangle_index = 0 class PackageMangler: """ Used on import, to ensure that all modules imported have a shared mangle parent. """ def __init__(self): global _mangle_index self._mangle_index = _mangle_index # Increm...
pytorch-master
torch/package/_mangling.py
from .analyze.is_from_package import is_from_package from .file_structure_representation import Directory from .glob_group import GlobGroup from .importer import ( Importer, ObjMismatchError, ObjNotFoundError, OrderedImporter, sys_importer, ) from .package_exporter import EmptyMatchError, PackageExp...
pytorch-master
torch/package/__init__.py
import builtins import importlib import importlib.machinery import inspect import io import linecache import os.path import types from contextlib import contextmanager from pathlib import Path from typing import Any, BinaryIO, Callable, cast, Dict, Iterable, List, Optional, Union from weakref import WeakValueDictionary...
pytorch-master
torch/package/package_importer.py
import _compat_pickle import pickle from .importer import Importer class PackageUnpickler(pickle._Unpickler): # type: ignore[name-defined] """Package-aware unpickler. This behaves the same as a normal unpickler, except it uses `importer` to find any global names that it encounters while unpickling. ...
pytorch-master
torch/package/_package_unpickler.py
import re from typing import Iterable, Union GlobPattern = Union[str, Iterable[str]] class GlobGroup: """A set of patterns that candidate strings will be matched against. A candidate is composed of a list of segments separated by ``separator``, e.g. "foo.bar.baz". A pattern contains one or more segment...
pytorch-master
torch/package/glob_group.py