python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse from tqdm import tqdm import numpy as np import cv2 import torch from src.main.config import Config impor...
assemblyhands-toolkit-main
src/main/test.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch import torch.nn as nn import torch.nn.functional as F from src.common.nets.module import BackboneNet, PoseNe...
assemblyhands-toolkit-main
src/main/model.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse # from config import cfg from src.main.config import Config import numpy as np import torch import torch...
assemblyhands-toolkit-main
src/main/train.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os.path import re import sys import setuptools sys.path.insert(0, os.path.join(os.path.dirname(__file__), "c...
CrypTen-main
setup.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Based on https://github.com/facebookresearch/CrypTen/blob/master/examples/multiprocess_launcher.py """ import log...
CrypTen-main
pycon-workshop-2020/multiprocess_launcher.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys import crypten import torch import torchvision from multiprocess_launcher import MultiProcessLauncher # ...
CrypTen-main
pycon-workshop-2020/training_across_parties.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys import unittest import crypten import torch from crypten.common.util import chebyshev_series from crypten....
CrypTen-main
test/test_common.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import crypten.mpc.primitives.ot.baseOT as baseOT from test.multiprocess_test_case import MultiProces...
CrypTen-main
test/test_baseOT.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import torch from crypten.config import cfg from crypten.debug import configure_logging, pdb from test....
CrypTen-main
test/test_debug.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import copy import itertools import logging import crypten import torch from crypten.common.tensor_types import is_fl...
CrypTen-main
test/test_privacy_models.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import queue import sys import threading import unittest from functools import wraps from threading import Thread im...
CrypTen-main
test/multithread_test_case.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import crypten import crypten.communicator as comm import numpy import torch import torch.distributed...
CrypTen-main
test/test_communicator.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .multiprocess_test_case import MultiProcessTestCase from .pytorch_backend import PyTorchTensor # expose classes ...
CrypTen-main
test/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import crypten import torch from crypten.common.tensor_types import is_float_tensor f...
CrypTen-main
test/test_optim.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import copy import itertools import logging import unittest import crypten import crypten.communicator as comm import...
CrypTen-main
test/test_nn.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import unittest import crypten import torch from crypten.common.tensor_types import i...
CrypTen-main
test/test_binary.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import math import os import unittest import crypten import crypten.communicator as ...
CrypTen-main
test/test_mpc.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import crypten try: from ..benchmarks import benchmark except ValueError: # ValueError is r...
CrypTen-main
test/test_benchmark.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import math import random import unittest from collections import defaultdict import...
CrypTen-main
test/test_crypten.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import crypten import crypten.nn.tensorboard as tensorboard from test.multiprocess_test_case import M...
CrypTen-main
test/test_tensorboard.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import collections import itertools import logging import unittest import crypten import torch import torch.nn as nn...
CrypTen-main
test/test_cuda.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import multiprocessing import os import sys import tempfile import traceback import unittest import warnings from func...
CrypTen-main
test/multiprocess_test_case.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest # from test.multiprocess_test_case import get_random_test_tensor import crypten import torch import...
CrypTen-main
test/test_models.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import crypten import torch from crypten.config import cfg from test.multiprocess_test_case import Multi...
CrypTen-main
test/test_distributions.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import crypten import crypten.communicator as comm import crypten.mpc as mpc import torch from crypt...
CrypTen-main
test/test_context.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import random import unittest import crypten import crypten.gradients as gradients import torch from c...
CrypTen-main
test/test_autograd.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import unittest import crypten import crypten.communicator as comm import torch impo...
CrypTen-main
test/test_arithmetic.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import collections import io import logging import os import unittest import crypten import torch from crypten.common...
CrypTen-main
test/test_onnx_converter.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import copy import itertools import logging import unittest from collections import namedtuple import crypten import...
CrypTen-main
test/test_gradients.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from crypten import CrypTensor, register_cryptensor @register_cryptensor("ptt") class PyTorchTensor(Cry...
CrypTen-main
test/pytorch_backend/pytorch_tensor.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .pytorch_tensor import PyTorchTensor __all__ = ["PyTorchTensor"]
CrypTen-main
test/pytorch_backend/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common ...
CrypTen-main
docs/conf.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import torch from .gradients import AutogradContext as _AutogradContext class AutogradContext(_Autog...
CrypTen-main
crypten/autograd_cryptensor.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import math from functools import reduce import crypten import torch from .common.util import _grad_i...
CrypTen-main
crypten/gradients.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. __version__ = "0.4.0" import builtins import copy import logging import os import warnings import crypten.common # ...
CrypTen-main
crypten/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import numpy as np import torch from .common.tensor_types import is_float_tensor, is_int_tensor from .co...
CrypTen-main
crypten/encoder.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from contextlib import contextmanager import torch from .debug import register_validation from .gradients import Aut...
CrypTen-main
crypten/cryptensor.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import copy import io import onnx import torch import torch.onnx.symbolic_helper as sym_help import torch.onnx.utils...
CrypTen-main
crypten/nn/onnx_converter.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .loss import _Loss from .module import Module class CosineSimilarity(Module): r"""Returns cosine similarit...
CrypTen-main
crypten/nn/distances.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .init import * # noqa: F403 from .distances import CosineSimilarity from .loss import _Loss, BCELoss, BCEWithLo...
CrypTen-main
crypten/nn/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import torch from .module import Module class _Loss(Module): """ Base criterion class that m...
CrypTen-main
crypten/nn/loss.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import warnings from collections import OrderedDict import crypten import torch import torch.onnx.symb...
CrypTen-main
crypten/nn/module.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch # Makes nn.init functions def make_crypten_compatible(initialization_function): def wrapper_func(te...
CrypTen-main
crypten/nn/init.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten.nn as nn from tensorboard.compat.proto.attr_value_pb2 import AttrValue from tensorboard.compat.proto.gr...
CrypTen-main
crypten/nn/tensorboard.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .dp_split import DPSplitModel, SkippedLoss __all__ = ["DPSplitModel", "SkippedLoss"]
CrypTen-main
crypten/nn/privacy/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import crypten.communicator as comm import torch import torch.nn as nn from crypten.config import cfg f...
CrypTen-main
crypten/nn/privacy/dp_split.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os from contextlib import contextmanager import yaml from omegaconf import OmegaConf class CrypTenConfig: ...
CrypTen-main
crypten/config/config.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .config import CrypTenConfig cfg = CrypTenConfig() __all__ = ["cfg"]
CrypTen-main
crypten/config/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import functools import math import operator import torch def implements(torch_function): """Register a torch f...
CrypTen-main
crypten/cuda/cuda_tensor.py
from .cuda_tensor import CUDALongTensor __all__ = ["CUDALongTensor"]
CrypTen-main
crypten/cuda/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import threading from operator import itemgetter from queue import Queue import torch from torch.distr...
CrypTen-main
crypten/communicator/in_process_communicator.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import pickle import random import string import numpy import torch import torch.distributed...
CrypTen-main
crypten/communicator/distributed_communicator.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .communicator import Communicator from .distributed_communicator import DistributedCommunicator from .in_process_...
CrypTen-main
crypten/communicator/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys import timeit from crypten.config import cfg class Communicator: """ Abstract class defining the...
CrypTen-main
crypten/communicator/communicator.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten from .optimizer import Optimizer class SGD(Optimizer): r"""Implements stochastic gradient descen...
CrypTen-main
crypten/optim/sgd.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .optimizer import Optimizer from .sgd import SGD __all__ = ["Optimizer", "SGD"]
CrypTen-main
crypten/optim/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import torch from torch.optim.optimizer import required class Optimizer(torch.optim.Optimizer): r...
CrypTen-main
crypten/optim/optimizer.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib.util import logging import sys import crypten.nn as cnn import torch # List of modules to import a...
CrypTen-main
crypten/models/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import torch from crypten.cuda import CUDALongTensor def generate_random_ring_element(size, ring_size=...
CrypTen-main
crypten/common/rng.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc import functools import numpy as np import torch from crypten.cuda import CUDALongTensor def count_wraps...
CrypTen-main
crypten/common/util.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. __all__ = ["functions", "rng", "tensor_types", "util", "serial"]
CrypTen-main
crypten/common/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from crypten.cuda import CUDALongTensor # helper functions that determine if input is float, int, or ba...
CrypTen-main
crypten/common/tensor_types.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import builtins # noqa import collections import inspect import io import logging import pickle import torch def _...
CrypTen-main
crypten/common/serial.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from ..tensor_types import is_tensor from ..util import torch_cat, torch_stack __all__ = [ # noqa: F8...
CrypTen-main
crypten/common/functions/regular.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch __all__ = [ "_max_pool2d_backward", "adaptive_max_pool2d", "adaptive_avg_pool2d...
CrypTen-main
crypten/common/functions/pooling.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import approximations, dropout, logic, maximum, pooling, power, regular, sampling __all__ = [ "approximati...
CrypTen-main
crypten/common/functions/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten from crypten.common.tensor_types import is_tensor __all__ = [ "__eq__", "__ge__", "__gt__...
CrypTen-main
crypten/common/functions/logic.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import crypten import torch from crypten.config import cfg __all__ = [ "argmax", "argmin", ...
CrypTen-main
crypten/common/functions/maximum.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import torch __all__ = [ "bernoulli", "randn", "weighted_index", "weighted_sample", ]...
CrypTen-main
crypten/common/functions/sampling.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import crypten __all__ = ["dropout"] def dropout(self, p=0.5, training=True, inplace=False): r"...
CrypTen-main
crypten/common/functions/dropout.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import torch from ..tensor_types import is_tensor __all__ = ["norm", "polynomial", "pos_pow", "pow"] ...
CrypTen-main
crypten/common/functions/power.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import crypten import torch from crypten.config import cfg __all__ = [ "exp", "log", "recip...
CrypTen-main
crypten/common/functions/approximations.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from enum import Enum from .primitives import ArithmeticSharedTensor, BinarySharedTensor class ptype(Enum): """...
CrypTen-main
crypten/mpc/ptype.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from crypten.config import cfg from crypten.mpc import primitives, provider # noqa: F401 from .context import run_mu...
CrypTen-main
crypten/mpc/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import functools import logging import multiprocessing import os import tempfile from operator import itemgetter impo...
CrypTen-main
crypten/mpc/context.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from crypten import communicator as comm from crypten.common.tensor_types import is_tensor from crypten.c...
CrypTen-main
crypten/mpc/mpc.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten.communicator as comm import torch from crypten.common.rng import generate_kbit_random_tensor, generate_...
CrypTen-main
crypten/mpc/provider/tfp_provider.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import crypten import crypten.communicator as comm import torch class TupleProvider: TRACEABLE_FUNCTI...
CrypTen-main
crypten/mpc/provider/provider.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import crypten import crypten.communicator as comm import torch import torch.distributed as dist from ...
CrypTen-main
crypten/mpc/provider/ttp_provider.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .provider import TupleProvider class HomomorphicProvider(TupleProvider): NAME = "HE" def generate_addi...
CrypTen-main
crypten/mpc/provider/homomorphic_provider.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .homomorphic_provider import HomomorphicProvider from .tfp_provider import TrustedFirstParty from .ttp_provider i...
CrypTen-main
crypten/mpc/provider/__init__.py
CrypTen-main
crypten/mpc/provider/tuple_cache/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten.communicator as comm # dependencies: import torch from crypten.common.functions import regular from cr...
CrypTen-main
crypten/mpc/primitives/arithmetic.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten.communicator as comm # dependencies: import torch from crypten.common.functions import regular from cr...
CrypTen-main
crypten/mpc/primitives/binary.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten import crypten.communicator as comm import torch from crypten.common.util import count_wraps from crypt...
CrypTen-main
crypten/mpc/primitives/beaver.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import functools import math import torch # Cache masks and constants to skip computation during each call __BITS = ...
CrypTen-main
crypten/mpc/primitives/circuit.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .arithmetic import ArithmeticSharedTensor from .binary import BinarySharedTensor __all__ = ["ArithmeticSharedTe...
CrypTen-main
crypten/mpc/primitives/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # # This file implements Replicated Secret Sharing protocols # from the CryptGPU repo import crypten.communicator as c...
CrypTen-main
crypten/mpc/primitives/replicated.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import crypten.communicator as comm import torch from crypten.encoder import FixedPointEncoder from ..ptype import pt...
CrypTen-main
crypten/mpc/primitives/converters.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random from hashlib import sha256 from typing import List import crypten.communicator as comm """ I dont...
CrypTen-main
crypten/mpc/primitives/ot/baseOT.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from functools import wraps from crypten.config import cfg from .debug import configure_logging, MultiprocessingPdb...
CrypTen-main
crypten/debug/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import pdb as pythondebugger import sys from crypten.config import cfg class MultiprocessingPdb(pyth...
CrypTen-main
crypten/debug/debug.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import multiprocessing import os import uuid import crypten class MultiProcessLauncher: # run_p...
CrypTen-main
examples/multiprocess_launcher.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch class AverageMeter: """Measures average of a value.""" def __init__(self): self.reset(...
CrypTen-main
examples/meters.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import numpy as np import numpy.linalg as nla import torch class NoopContextManager: "...
CrypTen-main
examples/util.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .meters import AccuracyMeter, AverageMeter from .multiprocess_launcher import MultiProcessLauncher from .util imp...
CrypTen-main
examples/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import random import shutil import tempfile import time import crypten import crypten.commun...
CrypTen-main
examples/mpc_cifar/mpc_cifar.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ To run mpc_cifar example in multiprocess mode: $ python3 examples/mpc_cifar/launcher.py \ --evaluate \ --...
CrypTen-main
examples/mpc_cifar/launcher.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random import time import crypten import torch from crypten.config import cfg def set_precision(bits): c...
CrypTen-main
examples/bandits/private_contextual_bandits.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random import time import torch def online_learner( sampler, dtype=torch.double, device="cpu", ...
CrypTen-main
examples/bandits/plain_contextual_bandits.py