python_code
stringlengths
0
1.02M
repo_name
stringlengths
9
48
file_path
stringlengths
5
114
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do no...
pytorch-master
caffe2/python/mkl/mkl_elementwise_sum_op_test.py
import unittest import numpy as np from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace, test_util @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.") class TestMKLBasic(test_util.TestCase): def testReLUSpeed(self): X = np.random.randn(128, 4096...
pytorch-master
caffe2/python/mkl/mkl_speed_test.py
import unittest import numpy as np from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace, test_util @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.") class TestMKLBasic(test_util.TestCase): def testSpatialBNTestingSpeed(self): input_channel = ...
pytorch-master
caffe2/python/mkl/mkl_sbn_speed_test.py
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu import caffe2.proto.caffe2_pb2 as pb2 @unittest.skipIf(not workspace.C.has_mkldnn, ...
pytorch-master
caffe2/python/mkl/mkl_copy_op_test.py
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do no...
pytorch-master
caffe2/python/mkl/mkl_LRN_op_test.py
import unittest import hypothesis.strategies as st from hypothesis import given, settings, assume import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Sk...
pytorch-master
caffe2/python/mkl/mkl_pool_op_test.py
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do no...
pytorch-master
caffe2/python/mkl/mkl_fc_op_test.py
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do no...
pytorch-master
caffe2/python/mkl/mkl_sigmoid_op_test.py
import unittest import numpy as np from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace, test_util @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.") class TestMKLBasic(test_util.TestCase): def testLRNSpeed(self): # We randomly select a shape t...
pytorch-master
caffe2/python/mkl/mkl_LRN_speed_test.py
import unittest import numpy as np from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace, test_util @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.") class TestMKLBasic(test_util.TestCase): def testMaxPoolingSpeed(self): # We randomly select a ...
pytorch-master
caffe2/python/mkl/mkl_pool_speed_test.py
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do no...
pytorch-master
caffe2/python/mkl/mkl_sbn_op_test.py
import unittest import numpy as np from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace, test_util @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.") class TestMKLBasic(test_util.TestCase): def testFCSpeed(self): # We randomly select a shape to...
pytorch-master
caffe2/python/mkl/mkl_fc_speed_test.py
import unittest import hypothesis.strategies as st from hypothesis import given from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping as we do not have mkldnn.") cl...
pytorch-master
caffe2/python/mkl/mkl_fill_op_test.py
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu @unittest.skipIf( not workspace.C.has_mkldnn, "Skipping as we do not have mkldn...
pytorch-master
caffe2/python/mkl/mkl_squeeze_op_test.py
## @package lmdb_create_example # Module caffe2.python.examples.lmdb_create_example import argparse import numpy as np import lmdb from caffe2.proto import caffe2_pb2 from caffe2.python import workspace, model_helper ''' Simple example to create an lmdb database of random image data and labels. This can be used ...
pytorch-master
caffe2/python/examples/lmdb_create_example.py
pytorch-master
caffe2/python/examples/__init__.py
imagenet_trainer.py
pytorch-master
caffe2/python/examples/resnet50_trainer.py
# Module caffe2.python.examples.resnet50_trainer import argparse import logging import numpy as np import time import os from caffe2.python import core, workspace, experiment_util, data_parallel_model from caffe2.python import dyndep, optimizer from caffe2.python import timeout_guard, model_helper, brew from caffe2.pr...
pytorch-master
caffe2/python/examples/imagenet_trainer.py
## @package char_rnn # Module caffe2.python.examples.char_rnn from caffe2.python import core, workspace, model_helper, utils, brew from caffe2.python.rnn_cell import LSTM from caffe2.proto import caffe2_pb2 from caffe2.python.optimizer import build_sgd import argparse import logging import numpy as np from datet...
pytorch-master
caffe2/python/examples/char_rnn.py
import argparse import numpy as np from caffe2.python import core, workspace def main(bit_rate): # uncomment for debugging # np.random.seed(0) batchsize = 10 * 1000 blocksize = 64 print(batchsize, blocksize) input_data = np.random.rand(batchsize, blocksize).astype(np.float32) workspace...
pytorch-master
caffe2/python/benchmarks/fused_rowwise_nbit_conversion_bench.py
import argparse import datetime import hypothesis.strategies as st import numpy as np from caffe2.python import core, workspace def benchmark_sparse_lengths_sum( categorical_limit, embedding_size, average_len, batch_size, iterations, flush_cache, bit_rate=st.sampled_from([2, 4]), ): ...
pytorch-master
caffe2/python/benchmarks/sparse_lengths_sum_nbit_benchmark.py
import argparse import numpy as np from caffe2.python import core, workspace def benchmark_concat(num_inputs, input_dim, axis, add_axis, iterations): input_names = [f"input{i}" for i in range(num_inputs)] for n in input_names: workspace.FeedBlob(n, np.random.randn(*input_dim).astype(np.float32)) ...
pytorch-master
caffe2/python/benchmarks/concat_benchmark.py
import argparse import datetime # import hypothesis.strategies as st import numpy as np from caffe2.python import core, workspace def benchmark_sparse_normalize( categorical_limit, embedding_size, average_len, batch_size, iterations, flush_cache, fp16, ): print("Preparing lookup table...
pytorch-master
caffe2/python/benchmarks/sparse_normalize_benchmark.py
## @package predictor_py_utils # Module caffe2.python.predictor.predictor_py_utils from caffe2.python import core, scope def create_predict_net(predictor_export_meta): """ Return the input prediction net. """ # Construct a new net to clear the existing settings. net = core.Net(predictor_export_m...
pytorch-master
caffe2/python/predictor/predictor_py_utils.py
## @package predictor_exporter # Module caffe2.python.predictor.predictor_exporter from caffe2.proto import caffe2_pb2 from caffe2.proto import metanet_pb2 from caffe2.python import workspace, core, scope from caffe2.python.predictor_constants import predictor_constants import caffe2.python.predictor.serde as serd...
pytorch-master
caffe2/python/predictor/predictor_exporter.py
## @package serde # Module caffe2.python.predictor.serde def serialize_protobuf_struct(protobuf_struct): return protobuf_struct.SerializeToString() def deserialize_protobuf_struct(serialized_protobuf, struct_type): deser = struct_type() deser.ParseFromString(serialized_protobuf) return deser
pytorch-master
caffe2/python/predictor/serde.py
from caffe2.python.test_util import TestCase from caffe2.python import workspace, brew from caffe2.python.model_helper import ModelHelper from caffe2.python.predictor import mobile_exporter import numpy as np class TestMobileExporter(TestCase): def test_mobile_exporter(self): model = ModelHelper(name=...
pytorch-master
caffe2/python/predictor/mobile_exporter_test.py
pytorch-master
caffe2/python/predictor/__init__.py
import tempfile import unittest import numpy as np from caffe2.python import cnn, workspace, core from future.utils import viewitems from caffe2.python.predictor_constants import predictor_constants as pc import caffe2.python.predictor.predictor_exporter as pe import caffe2.python.predictor.predictor_py_utils as ...
pytorch-master
caffe2/python/predictor/predictor_exporter_test.py
import unittest import numpy as np from caffe2.python import workspace, core from caffe2.proto import caffe2_pb2 class TestPredictor(unittest.TestCase): def setUp(self): np.random.seed(1) self.predict_net = self._predict_net self.init_net = self._init_net @property def _pred...
pytorch-master
caffe2/python/predictor/predictor_test.py
## @package mobile_exporter # Module caffe2.python.mobile_exporter from caffe2.python import core, utils from caffe2.proto import caffe2_pb2 import numpy as np def add_tensor(net, name, blob): ''' Create an operator to store the tensor 'blob', run the operator to put the blob to workspace. ui...
pytorch-master
caffe2/python/predictor/mobile_exporter.py
## @package elementwise_linear # Module caffe2.python.helpers.elementwise_linear from caffe2.python import core from caffe2.python.modeling.parameter_info import ParameterTags def _elementwise_linear( model, op_call, blob_in, blob_out, dim, weight_init=None, bias_init=None, **kwargs ): """Elementwise...
pytorch-master
caffe2/python/helpers/elementwise_linear.py
## @package fc # Module caffe2.python.helpers.fc from caffe2.python import core from caffe2.python.modeling import initializers from caffe2.python.modeling.parameter_info import ParameterTags def _FC_or_packed_FC( model, op_call, blob_in, blob_out, dim_in, dim_out, weight_init=None, bias_init=None, W...
pytorch-master
caffe2/python/helpers/fc.py
# @package quantization # Module caffe2.python.helpers.quantization def fused_8bit_rowwise_quantized_to_float( model, blob_in, blob_out ): """Fused8BitRowwiseQuantizedToFloat""" return model.net.Fused8BitRowwiseQuantizedToFloat(blob_in, blob_out)
pytorch-master
caffe2/python/helpers/quantization.py
## @package algebra # Module caffe2.python.helpers.algebra def transpose(model, blob_in, blob_out, use_cudnn=False, **kwargs): """Transpose.""" if use_cudnn: kwargs['engine'] = 'CUDNN' return model.net.Transpose(blob_in, blob_out, **kwargs) def sum(model, blob_in, blob_out, **kwargs): ""...
pytorch-master
caffe2/python/helpers/algebra.py
## @package tools # Module caffe2.python.helpers.tools def image_input( model, blob_in, blob_out, order="NCHW", use_gpu_transform=False, **kwargs ): assert 'is_test' in kwargs, "Argument 'is_test' is required" if order == "NCHW": if (use_gpu_transform): kwargs['use_gpu_transform'] ...
pytorch-master
caffe2/python/helpers/tools.py
## @package pooling # Module caffe2.python.helpers.pooling ## @package fc # Module caffe2.python.helpers.pooling def max_pool(model, blob_in, blob_out, use_cudnn=False, order="NCHW", **kwargs): """Max pooling""" if use_cudnn: kwargs['engine'] = 'CUDNN' return model.net.MaxPool(blob_in, blob_ou...
pytorch-master
caffe2/python/helpers/pooling.py
pytorch-master
caffe2/python/helpers/__init__.py
## @package arra_helpers # Module caffe2.python.helpers.array_helpers def concat(model, blobs_in, blob_out, **kwargs): """Depth Concat.""" if kwargs.get('order') and kwargs.get('axis'): # The backend throws an error if both are given kwargs.pop('order') return model.net.Concat( ...
pytorch-master
caffe2/python/helpers/array_helpers.py
## @package nonlinearity # Module caffe2.python.helpers.nonlinearity from caffe2.python import core def prelu(model, blob_in, blob_out, num_channels=1, slope_init=None, **kwargs): """PRelu""" slope_init = ( slope_init if slope_init else ('ConstantFill', {'value': 0.25})) if model.in...
pytorch-master
caffe2/python/helpers/nonlinearity.py
## @package train # Module caffe2.python.helpers.train from caffe2.python import core, scope from caffe2.proto import caffe2_pb2 def _get_weights(model, namescope=None): if namescope is None: namescope = scope.CurrentNameScope() if namescope == '': return model.weights[:] else: ...
pytorch-master
caffe2/python/helpers/train.py
## @package control_ops # Module caffe2.python.helpers.control_ops from caffe2.python.control_ops_util import add_if_op, add_while_op def cond(model, cond_blob, external_blobs, then_model, else_model=None): """Condition""" add_if_op( model.net, cond_blob, external_blobs, t...
pytorch-master
caffe2/python/helpers/control_ops.py
## @package dropout # Module caffe2.python.helpers.dropout def dropout(model, blob_in, blob_out, use_cudnn=False, **kwargs): """dropout""" if use_cudnn: kwargs['engine'] = 'CUDNN' else: kwargs['engine'] = 'DEFAULT' assert 'is_test' in kwargs, "Argument 'is_test' is required" re...
pytorch-master
caffe2/python/helpers/dropout.py
## @package conv # Module caffe2.python.helpers.conv from caffe2.python import core from caffe2.python.modeling import initializers from caffe2.python.modeling.parameter_info import ParameterTags def _ConvBase( model, is_nd, blob_in, blob_out, dim_in, dim_out, kernel, weight_init=N...
pytorch-master
caffe2/python/helpers/conv.py
import contextlib import copy import threading _threadlocal_scope = threading.local() @contextlib.contextmanager def arg_scope(single_helper_or_list, **kwargs): global _threadlocal_scope if not isinstance(single_helper_or_list, list): assert callable(single_helper_or_list), \ "arg_scop...
pytorch-master
caffe2/python/helpers/arg_scope.py
## @package normalization # Module caffe2.python.helpers.normalization from caffe2.python import scope from caffe2.python.modeling.parameter_info import ParameterTags from caffe2.proto import caffe2_pb2 from caffe2.python.modeling import initializers def lrn(model, blob_in, blob_out, order="NCHW", use_cudnn=Fals...
pytorch-master
caffe2/python/helpers/normalization.py
## @package db_input # Module caffe2.python.helpers.db_input def db_input(model, blobs_out, batch_size, db, db_type): dbreader_name = "dbreader_" + db dbreader = model.param_init_net.CreateDB( [], dbreader_name, db=db, db_type=db_type, ) return model.net.TensorProtos...
pytorch-master
caffe2/python/helpers/db_input.py
pytorch-master
caffe2/python/rnn/__init__.py
from caffe2.python import workspace, scope from caffe2.python.model_helper import ModelHelper import numpy as np def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) def tanh(x): return 2.0 * sigmoid(2.0 * x) - 1 def _prepare_rnn( t, n, dim_in, create_rnn, outputs_with_grads, forget_bias, memory_...
pytorch-master
caffe2/python/rnn/rnn_cell_test_util.py
from caffe2.python import workspace, core, lstm_benchmark, utils from copy import copy @utils.debug def Compare(args): results = [] num_iters = 1000 args.gpu = True with core.DeviceScope(core.DeviceOption(workspace.GpuDeviceType, 0)): for batch_size in [64, 128, 256]: for seq_le...
pytorch-master
caffe2/python/rnn/lstm_comparison.py
import os import uuid from caffe2.distributed.python import StoreHandlerTimeoutError from caffe2.distributed.store_ops_test_util import StoreOpsTests from caffe2.python import core, workspace, dyndep from caffe2.python.test_util import TestCase dyndep.InitOpsLibrary("@/caffe2/caffe2/distributed:redis_store_handl...
pytorch-master
caffe2/distributed/redis_store_handler_op_test.py
pytorch-master
caffe2/distributed/__init__.py
## @package store_ops_test_util # Module caffe2.distributed.store_ops_test_util from multiprocessing import Process, Queue import numpy as np from caffe2.python import core, workspace class StoreOpsTests(object): @classmethod def _test_set_get(cls, queue, create_store_handler_fn, index, num_procs): ...
pytorch-master
caffe2/distributed/store_ops_test_util.py
import errno import os import tempfile import shutil from caffe2.distributed.python import StoreHandlerTimeoutError from caffe2.distributed.store_ops_test_util import StoreOpsTests from caffe2.python import core, workspace, dyndep from caffe2.python.test_util import TestCase dyndep.InitOpsLibrary("@/caffe2/caffe...
pytorch-master
caffe2/distributed/file_store_handler_op_test.py
pytorch-master
caffe2/perfkernels/__init__.py
import argparse import sys sizeof = {"float": 4, "at::Half": 2, "uint8_t": 1} def unroll(uf, IndexType, InType, OutType, use_weights, isa, fused, use_offsets): def compute(regid, InType, use_weights, isa, prefetch): code = [] if InType == "float": code.append( " ...
pytorch-master
caffe2/perfkernels/hp_emblookup_codegen.py
pytorch-master
caffe2/experiments/__init__.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/sparse_funhash_op_test.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/tt_pad_op_test.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/funhash_op_test.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/sparse_reshape_op_test.py
pytorch-master
caffe2/experiments/python/__init__.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/convnet_benchmarks.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/device_reduce_sum_bench.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/tt_contraction_op_test.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/SparseTransformer.py
# Copyright (c) 2016-present, Facebook, Inc. # # 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 agreed...
pytorch-master
caffe2/experiments/python/net_construct_bench.py
pytorch-master
caffe2/contrib/__init__.py
pytorch-master
caffe2/contrib/nnpack/__init__.py
import unittest import hypothesis.strategies as st from hypothesis import given, assume, settings import numpy as np import time import os from caffe2.python import core, dyndep import caffe2.python.hypothesis_test_util as hu dyndep.InitOpsLibrary("@/caffe2/caffe2/contrib/nnpack:nnpack_ops") np.random.seed(1) ...
pytorch-master
caffe2/contrib/nnpack/nnpack_ops_test.py
import numpy as np from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace, dyndep, test_util dyndep.InitOpsLibrary('@/caffe2/caffe2/contrib/warpctc:ctc_ops') workspace.GlobalInit(["python"]) def softmax(w): maxes = np.amax(w, axis=-1, keepdims=True) e = np.exp(w - maxes) dist ...
pytorch-master
caffe2/contrib/warpctc/ctc_ops_test.py
pytorch-master
caffe2/contrib/warpctc/__init__.py
pytorch-master
caffe2/contrib/nccl/__init__.py
import unittest import hypothesis.strategies as st from hypothesis import given, assume import numpy as np import time import os from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace, muji, dyndep import caffe2.python.hypothesis_test_util as hu np.random.seed(1) dyndep.InitOpsLibrary('@/c...
pytorch-master
caffe2/contrib/nccl/nccl_ops_test.py
import numpy as np import pickle from collections import OrderedDict from caffe2.proto import caffe2_pb2 from caffe2.python import workspace, core, scope import logging logging.basicConfig() log = logging.getLogger("AnyExpOnTerm") log.setLevel(logging.DEBUG) def initialize_params_from_file( model, wei...
pytorch-master
caffe2/contrib/playground/checkpoint.py
from abc import abstractmethod class Meter(object): @abstractmethod def __init__(self, **kwargs): pass @abstractmethod def Reset(self): pass @abstractmethod def Add(self): pass @abstractmethod def Compute(self): pass
pytorch-master
caffe2/contrib/playground/meter.py
import caffe2.contrib.playground.meter as Meter from caffe2.python import workspace import numpy as np class ComputeTopKAccuracy(Meter.Meter): # Python default arguments are evaluated once when the function is # defined, not each time the function is called # This means that if you use a mutable defa...
pytorch-master
caffe2/contrib/playground/compute_topk_accuracy.py
pytorch-master
caffe2/contrib/playground/__init__.py
from abc import abstractmethod from caffe2.python import workspace from caffe2.python import timeout_guard from caffe2.python import data_parallel_model from . import checkpoint as checkpoint from . import ModuleRegister as ModuleRegister from . import module_map as module_map # instantiate logger outside of di...
pytorch-master
caffe2/contrib/playground/AnyExp.py
# Input import caffe2.contrib.playground.resnetdemo.\ gfs_IN1k as gfs_IN1k # noqa # model import caffe2.contrib.playground.resnetdemo.\ IN1k_resnet as IN1k_resnet # noqa import caffe2.contrib.playground.resnetdemo.\ IN1k_resnet_no_test_model as IN1k_resnet_no_test_model # noqa # Additional override...
pytorch-master
caffe2/contrib/playground/module_map.py
from caffe2.python import timeout_guard def fun_conclude_operator(self): # Ensure the program exists. This is to "fix" some unknown problems # causing the job sometimes get stuck. timeout_guard.EuthanizeIfNecessary(600.0) def assembleAllOutputs(self): output = {} output['train_model'] = self...
pytorch-master
caffe2/contrib/playground/output_generator.py
import argparse import json import os import caffe2.contrib.playground.AnyExp as AnyExp import caffe2.contrib.playground.checkpoint as checkpoint import logging logging.basicConfig() log = logging.getLogger("AnyExpOnTerm") log.setLevel(logging.DEBUG) def runShardedTrainLoop(opts, myTrainFun): start_epoch =...
pytorch-master
caffe2/contrib/playground/AnyExpOnTerm.py
import inspect import logging logging.basicConfig() log = logging.getLogger("ModuleRegister") log.setLevel(logging.DEBUG) MODULE_MAPS = [] def registerModuleMap(module_map): MODULE_MAPS.append(module_map) log.info("ModuleRegister get modules from ModuleMap content: {}". format(inspect.gets...
pytorch-master
caffe2/contrib/playground/ModuleRegister.py
import caffe2.contrib.playground.meter as Meter from caffe2.python import workspace class ComputeLoss(Meter.Meter): def __init__(self, opts=None, blob_name=''): self.blob_name = blob_name self.opts = opts self.iter = 0 self.value = 0 def Reset(self): self.iter = 0...
pytorch-master
caffe2/contrib/playground/compute_loss.py
def gen_param_update_builder_fun(self, model, dataset, is_train): if not is_train: return None else: def add_parameter_update_ops(model): model.AddWeightDecay(1e-4) ITER = model.Iter("ITER") stepsz = int(30 * self.opts['epoch_ite...
pytorch-master
caffe2/contrib/playground/resnetdemo/caffe2_resnet50_default_param_update.py
import logging logging.basicConfig() log = logging.getLogger("AnyExp") log.setLevel(logging.DEBUG) # For more depths, add the block config here BLOCK_CONFIG = { 18: (2, 2, 2, 2), 34: (3, 4, 6, 3), 50: (3, 4, 6, 3), 101: (3, 4, 23, 3), 152: (3, 8, 36, 3), 200: (3, 32, 36, 3), 264: (3, 6...
pytorch-master
caffe2/contrib/playground/resnetdemo/explicit_resnet_forward.py
import numpy as np from caffe2.python import workspace, cnn, core from caffe2.python import timeout_guard from caffe2.proto import caffe2_pb2 def init_model(self): train_model = cnn.CNNModelHelper( order="NCHW", name="resnet", use_cudnn=True, cudnn_exhaustive_search=False ...
pytorch-master
caffe2/contrib/playground/resnetdemo/IN1k_resnet.py
import numpy as np from caffe2.python import workspace, cnn, core from caffe2.python import timeout_guard from caffe2.proto import caffe2_pb2 def init_model(self): # if cudnn needs to be turned off, several other places # need to be modified: # 1. operators need to be constructed with engine option,...
pytorch-master
caffe2/contrib/playground/resnetdemo/IN1k_resnet_no_test_model.py
import caffe2.python.models.resnet as resnet def gen_forward_pass_builder_fun(self, model, dataset, is_train): def create_resnet50_model_ops(model, loss_scale): [softmax, loss] = resnet.create_resnet50( model, "data", num_input_channels=3, num_labels=10...
pytorch-master
caffe2/contrib/playground/resnetdemo/caffe2_resnet50_default_forward.py
# # example1 using gfs as input source. def gen_input_builder_fun(self, model, dataset, is_train): if is_train: input_path = self.opts['input']['train_input_path'] else: input_path = self.opts['input']['test_input_path'] reader = model.CreateDB("reader", db...
pytorch-master
caffe2/contrib/playground/resnetdemo/gfs_IN1k.py
pytorch-master
caffe2/contrib/playground/resnetdemo/__init__.py
def checkpoint(self, epoch): self.model_path = None pass def prep_data_parallel_models(self): # only do train_model no test needed here self.prep_a_data_parallel_model(self.train_model, self.train_dataset, True) def run_testing_net(self): pass
pytorch-master
caffe2/contrib/playground/resnetdemo/override_no_test_model_no_checkpoint.py
from caffe2.python import core, workspace from caffe2.python import dyndep dyndep.InitOpsLibrary('@/caffe2/caffe2/distributed:file_store_handler_ops') # rendezvous should NOT be unique for each operator. It should have # the same run_id on different operators. say we have two shards, # both shards created rend...
pytorch-master
caffe2/contrib/playground/resnetdemo/rendezvous_filestore.py
from caffe2.python import workspace, core from caffe2.proto import caffe2_pb2 def gen_param_update_builder_fun(self, model, dataset, is_train): if not is_train: return None else: # from sherlok for idx in range(self.opts['distributed']['first_xpu_id'], sel...
pytorch-master
caffe2/contrib/playground/resnetdemo/explicit_resnet_param_update.py
pytorch-master
caffe2/contrib/gloo/__init__.py
#!/usr/bin/env python3 from hypothesis import given, settings import hypothesis.strategies as st from multiprocessing import Process, Queue import numpy as np import os import pickle import tempfile import shutil from caffe2.python import core, workspace, dyndep import caffe2.python.hypothesis_test_util as hu f...
pytorch-master
caffe2/contrib/gloo/gloo_test.py
import numpy as np import unittest import caffe2.python.fakelowp.init_shared_libs # noqa from hypothesis import given, settings from hypothesis import strategies as st from caffe2.proto import caffe2_pb2 from caffe2.python import core from caffe2.python import workspace from caffe2.python.onnx.onnxifi import onnxifi_...
pytorch-master
caffe2/contrib/fakelowp/test/test_batchnorm_nnpi_fp16.py
import numpy as np import unittest import caffe2.python.fakelowp.init_shared_libs # noqa from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace from caffe2.python.onnx.onnxifi import onnxifi_caffe2_net from caffe2.python.fakelowp.test_utils import print_test_debug_info import datetime from hypo...
pytorch-master
caffe2/contrib/fakelowp/test/test_batchmatmul_nnpi_fp16.py
import numpy as np import unittest # Must happen before importing caffe2.python.* import caffe2.python.fakelowp.init_shared_libs # noqa from hypothesis import given, settings from hypothesis import strategies as st from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace from caffe2.python.onnx....
pytorch-master
caffe2/contrib/fakelowp/test/test_sls_4bit_nnpi_fp16.py
import numpy as np import caffe2.python.fakelowp.init_shared_libs # noqa from caffe2.proto import caffe2_pb2 from caffe2.python import core from caffe2.python import workspace from caffe2.python.onnx.onnxifi import onnxifi_caffe2_net from caffe2.python.fakelowp.test_utils import print_test_debug_info from hypothesis i...
pytorch-master
caffe2/contrib/fakelowp/test/test_layernorm_nnpi_fp16.py