python_code stringlengths 0 1.02M | repo_name stringlengths 9 48 | file_path stringlengths 5 114 |
|---|---|---|
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
from hypothesis import given, settings
import hypothesis.strategies as st
import numpy as np
class TestBatchSparseToDense(serial.SerializedTestCase):
@given(
... | pytorch-master | caffe2/python/operator_test/batch_sparse_to_dense_op_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
from hypothesis import given, settings
import hypothesis.strategies as st
import numpy as np
class TestAffineChannelOp(serial.SerializedTestCase):
def affine_chann... | pytorch-master | caffe2/python/operator_test/affine_channel_op_test.py |
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
class ChannelShuffleOpsTest(serial.SerializedTestCase):
def _channel_shuffle_nchw_ref(self, X, group):
... | pytorch-master | caffe2/python/operator_test/channel_shuffle_test.py |
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
class TestPairWiseLossOps(serial.SerializedTestCase):
@given(X=hu.ar... | pytorch-master | caffe2/python/operator_test/rank_loss_operator_test.py |
try:
import cv2
except ImportError:
pass # skip if opencv is not available
import numpy as np
# === copied from utils/keypoints.py as reference ===
_NUM_KEYPOINTS = -1 # cfg.KRCNN.NUM_KEYPOINTS
_INFERENCE_MIN_SIZE = 0 # cfg.KRCNN.INFERENCE_MIN_SIZE
def heatmaps_to_keypoints(maps, rois):
"""Extra... | pytorch-master | caffe2/python/operator_test/detectron_keypoints.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/python/operator_test/unique_ops_test.py |
import unittest
try:
import cv2
import lmdb
except ImportError:
pass # Handled below
from PIL import Image
import numpy as np
import shutil
import io
import sys
import tempfile
# TODO: This test does not test scaling because
# the algorithms used by OpenCV in the C and Python
# version seem to diffe... | pytorch-master | caffe2/python/operator_test/image_input_op_test.py |
import numpy as np
from caffe2.python import core, workspace
from caffe2.python.test_util import TestCase, rand_array
class TestPartitionOps(TestCase):
def test_configs(self):
# (main dims, partitions, main type, [list of (extra dims, type)])
configs = [
((10, ), 3),
... | pytorch-master | caffe2/python/operator_test/partition_ops_test.py |
from caffe2.python import core
from hypothesis import given, settings
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
# Reference implementation from detectron/lib/utils/boxes.py
def bbox_tra... | pytorch-master | caffe2/python/operator_test/bbox_transform_test.py |
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
from hypothesis import given, settings
import hypothesis.strategies as st
class LpnormTest(hu.HypothesisTestCase):
def _test_Lp_Norm(self, inputs, gc, dc):
X = inputs[0]
# avoid kinks ... | pytorch-master | caffe2/python/operator_test/lpnorm_op_test.py |
import numpy as np
import torch
import sys
import unittest
from scipy import interpolate
import caffe2.python.hypothesis_test_util as hu
from caffe2.python import core, utils
from caffe2.proto import caffe2_pb2
import caffe2.python.operator_test.detectron_keypoints as keypoint_utils
NUM_TEST_ROI = 14
NUM_KEYPOI... | pytorch-master | caffe2/python/operator_test/heatmap_max_keypoint_op_test.py |
import hypothesis
from hypothesis import given, settings, HealthCheck
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
class TestSparseLpNorm(hu.HypothesisTestCase):
@staticmethod
def ref_lpnorm(param_in, p, reg_lambda)... | pytorch-master | caffe2/python/operator_test/sparse_lp_regularizer_test.py |
import numpy as np
from hypothesis import given, assume
import hypothesis.strategies as st
from caffe2.python import core, model_helper, utils
import caffe2.python.hypothesis_test_util as hu
class TestLeakyRelu(hu.HypothesisTestCase):
def _get_inputs(self, N, C, H, W, order):
input_data = np.random.... | pytorch-master | caffe2/python/operator_test/leaky_relu_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
from hypothesis import given, settings
import hypothesis.strategies as st
import numpy as np
import unittest
class TestChannelStatsOp(serial.SerializedTestCase):
... | pytorch-master | caffe2/python/operator_test/channel_stats_op_test.py |
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
class TestCosineEmbeddingCriterion(serial.SerializedTestCase):
@serial.given(N=st.integers(min_value=10, ma... | pytorch-master | caffe2/python/operator_test/cosine_embedding_criterion_op_test.py |
from caffe2.python import core
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
def calculate_ap(predictions, labels):
N, D = predictions.shape
ap = np.zeros(D)
num_range = np.arange((N), dtype=np.float32) + 1
for k... | pytorch-master | caffe2/python/operator_test/apmeter_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
class TestLengthsTileOp(serial.SerializedTestCase):
@serial.given(
inputs=st.integers(min_value=1, ... | pytorch-master | caffe2/python/operator_test/lengths_tile_op_test.py |
import numpy as np
from hypothesis import assume, given, settings
import hypothesis.strategies as st
from caffe2.proto import caffe2_pb2
from caffe2.python import core, utils
import caffe2.python.hip_test_util as hiputl
import caffe2.python.hypothesis_test_util as hu
import unittest
class TestGroupConvolution(hu... | pytorch-master | caffe2/python/operator_test/group_conv_test.py |
from caffe2.python import core
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu
import numpy as np
class SparseDropoutWithReplacementTest(hu.HypothesisTestCase):
@given(**hu.gcs_cpu_only)
def test_no_dropout(self, gc, dc):
X = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).... | pytorch-master | caffe2/python/operator_test/sparse_dropout_with_replacement_op_test.py |
import math
import struct
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core, workspace
from caffe2.python.operator_test.fused_nbit_rowwise_test_helper import (
_compress_uniform_simplified,
param_search_greedy,
)
from hypothes... | pytorch-master | caffe2/python/operator_test/fused_nbit_rowwise_conversion_ops_test.py |
from caffe2.python import core
from collections import defaultdict, Counter
from hypothesis import given, settings
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import unittest
DEFAULT_BEAM... | pytorch-master | caffe2/python/operator_test/ctc_beam_search_decoder_op_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
class TestLossOps(serial.SerializedTestCase):
@serial.given(n=st.integers(1, 8), **hu.gcs)
def test_ave... | pytorch-master | caffe2/python/operator_test/loss_ops_test.py |
from caffe2.python import core, workspace
from caffe2.python.test_util import TestCase
import tempfile
class TestCounterOps(TestCase):
def test_counter_ops(self):
workspace.RunOperatorOnce(core.CreateOperator(
'CreateCounter', [], ['c'], init_count=1))
workspace.RunOperatorOnce(... | pytorch-master | caffe2/python/operator_test/counter_ops_test.py |
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
from hypothesis import given
import numpy as np
class TestCastOp(hu.HypothesisTestCase):
@given(**hu.gcs)
def test_cast_int_float(self, gc, dc):
data = np.random.rand(5, 5).astype(np.int32)
# from... | pytorch-master | caffe2/python/operator_test/cast_op_test.py |
from caffe2.python import model_helper, workspace, core, rnn_cell
from future.utils import viewitems
import numpy as np
import unittest
@unittest.skipIf(not workspace.has_gpu_support, "No gpu support.")
class TestLSTMs(unittest.TestCase):
def testEqualToCudnn(self):
with core.DeviceScope(core.Devic... | pytorch-master | caffe2/python/operator_test/cudnn_recurrent_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
class TestLengthsPadOp(serial.SerializedTestCase):
@serial.given(
inputs=hu.lengths_tensor(
... | pytorch-master | caffe2/python/operator_test/lengths_pad_op_test.py |
import numpy as np
from hypothesis import given, settings
import hypothesis.strategies as st
import unittest
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
class TestTile(serial.SerializedTestCase):
... | pytorch-master | caffe2/python/operator_test/tile_op_test.py |
from caffe2.python import core, workspace
from hypothesis import assume, given, settings
from caffe2.proto import caffe2_pb2
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import random
clas... | pytorch-master | caffe2/python/operator_test/utility_ops_test.py |
import numpy as np
from caffe2.python import core, workspace
from caffe2.python.test_util import TestCase
class TestDuplicateOperands(TestCase):
def test_duplicate_operands(self):
net = core.Net('net')
shape = (2, 4)
x_in = np.random.uniform(size=shape)
x = net.GivenTensorFil... | pytorch-master | caffe2/python/operator_test/duplicate_operands_test.py |
import functools
import operator
import string
import hypothesis.strategies as st
import numpy as np
import numpy.testing as npt
from caffe2.python import core, dataset, workspace
from caffe2.python.dataset import Const
from caffe2.python.schema import (
FeedRecord,
FetchRecord,
Field,
List,
Map,
... | pytorch-master | caffe2/python/operator_test/dataset_ops_test.py |
import hypothesis.strategies as st
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu
import numpy as np
class TestNGramOps(hu.HypothesisTestCase):
@given(
seed=st.integers(0, 2**32 - 1),
N=st.integers(min_value=10, max_val... | pytorch-master | caffe2/python/operator_test/ngram_ops_test.py |
import numpy as np
import unittest
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace, test_util, model_helper, brew, build
@unittest.skipIf(build.CAFFE2_NO_OPERATOR_SCHEMA,
'Built with CAFFE2_NO_OPERATOR_SCHEMA')
class TestShapeInference(test_util.TestCase):
def... | pytorch-master | caffe2/python/operator_test/shape_inference_test.py |
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core, workspace
from hypothesis import given
class TestMarginLossL2rOps(hu.HypothesisTestCase):
def ref_margin_loss(self, y, r, margin):
n = len(y)
dy = np.zeros(n)
... | pytorch-master | caffe2/python/operator_test/margin_loss_l2r_operator_test.py |
from caffe2.python import core, workspace
from hypothesis import given, settings
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import unittest
class TestSoftmaxOps(serial.SerializedTestCas... | pytorch-master | caffe2/python/operator_test/softmax_ops_test.py |
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
import copy
class RoIAlignRotatedOp(hu.HypothesisTestCase):
def bbox_xywh_to_xyxy(self, boxes):
"""
Convert from [center... | pytorch-master | caffe2/python/operator_test/roi_align_rotated_op_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
from hypothesis import given, settings
import hypothesis.strategies as st
import numpy as np
import unittest
@st.composite
def _glu_old_input(draw):
dims = draw(... | pytorch-master | caffe2/python/operator_test/glu_op_test.py |
import struct
import unittest
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
import torch
from caffe2.python import core, workspace
from hypothesis import given, settings
from scipy.stats import norm
def generate_rois(roi_counts, im_dims):
assert len(roi_c... | pytorch-master | caffe2/python/operator_test/torch_integration_test.py |
from typing import List
import hypothesis.strategies as st
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu
import bisect
import numpy as np
class TestBisectPercentileOp(hu.HypothesisTestCase):
def compare_reference(
self,
... | pytorch-master | caffe2/python/operator_test/bisect_percentile_op_test.py |
from caffe2.python import core, workspace
from hypothesis import given, assume, settings
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
import unittest
class TestElementwiseOps(hu.HypothesisTestCase):
@given(X=hu.tensor(dtype=np.float32), **hu.gcs)
... | pytorch-master | caffe2/python/operator_test/elementwise_ops_test.py |
import unittest
import caffe2.python.hypothesis_test_util as hu
import numpy as np
from caffe2.python import core, workspace
def update_counter_ref(prev_iter, update_counter, indices, curr_iter, counter_halflife):
prev_iter_out = prev_iter.copy()
update_counter_out = update_counter.copy()
counter_neg_... | pytorch-master | caffe2/python/operator_test/rowwise_counter_test.py |
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
class TestEnforceFinite(hu.HypothesisTestCase):
@given(
X=hu.tensor(
# allow empty
min_value=0,
elements=hu.floats(a... | pytorch-master | caffe2/python/operator_test/enforce_finite_op_test.py |
from caffe2.python import brew, core, workspace
from caffe2.python.model_helper import ModelHelper
from functools import partial
from hypothesis import given, settings
from typing import Optional, Tuple
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as se... | pytorch-master | caffe2/python/operator_test/layer_norm_op_test.py |
from caffe2.proto import caffe2_pb2
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
from hypothesis import given, settings
import hypothesis.strategies as st
import numpy as np
import unittest
class TestONNXWhile(se... | pytorch-master | caffe2/python/operator_test/onnx_while_test.py |
import numpy as np
import unittest
from hypothesis import given, settings
import hypothesis.strategies as st
from caffe2.python import core, utils
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
#
# Should match original Detectron code at
# htt... | pytorch-master | caffe2/python/operator_test/collect_and_distribute_fpn_rpn_proposals_op_test.py |
import time
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core, workspace
from hypothesis import given, settings
np.set_printoptions(precision=6)
class TestSpeedFloatToFusedRandRowwiseQuantized(hu.HypothesisTestCase):
@given(
... | pytorch-master | caffe2/python/operator_test/rand_quantization_op_speed_test.py |
#!/usr/bin/env python3
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
from hypothesis import given
class TestAsyncNetBarrierOp(hu.HypothesisTestCase):
@given(
n=st.integers(1, 5),
shape=st.lists(st.integers(0, 5... | pytorch-master | caffe2/python/operator_test/async_net_barrier_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
class TestIntegralImageOps(serial.SerializedTestCase):
@given(batch_s... | pytorch-master | caffe2/python/operator_test/integral_image_ops_test.py |
import hypothesis.strategies as st
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu
import numpy as np
class TestKeySplitOps(hu.HypothesisTestCase):
@given(
X=hu.arrays(
dims=[1000],
dtype=np.int64,
... | pytorch-master | caffe2/python/operator_test/key_split_ops_test.py |
import functools
import numpy as np
from hypothesis import given, settings
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import copy
class TestNormalizeOp(hu.HypothesisTestCase):
@given(
X=hu.tensor(
min_dim=1, max_dim=5, elements=hu.floats(min_value=0.5, ... | pytorch-master | caffe2/python/operator_test/normalize_op_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
from hypothesis import given, settings
import hypothesis.strategies as st
import numpy as np
class TestMarginRankingCriterion(serial.SerializedTestCase):
@given(... | pytorch-master | caffe2/python/operator_test/margin_ranking_criterion_op_test.py |
from caffe2.python import core, workspace
from caffe2.python.test_util import TestCase
import numpy as np
class TestFeatureMapsOps(TestCase):
def test_merge_dense_feature_tensors(self):
op = core.CreateOperator(
"MergeDenseFeatureTensors",
[
"in1", "in1_presenc... | pytorch-master | caffe2/python/operator_test/feature_maps_ops_test.py |
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
from hypothesis import given, settings
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import unittest
class TestCeil(serial.SerializedTestCase):
@given(X... | pytorch-master | caffe2/python/operator_test/ceil_op_test.py |
import numpy as np
import caffe2.python.models.shufflenet as shufflenet
import hypothesis.strategies as st
from hypothesis import given, settings
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.models.imagenet_trainer_test_utils as utils
class ShufflenetMemongerTest(hu.HypothesisTestCase):
... | pytorch-master | caffe2/python/models/shufflenet_test.py |
import numpy as np
import time
from caffe2.python import workspace, cnn, memonger, core
def has_blob(proto, needle):
for op in proto.op:
for inp in op.input:
if inp == needle:
return True
for outp in op.output:
if outp == needle:
return ... | pytorch-master | caffe2/python/models/imagenet_trainer_test_utils.py |
## @package download
# Module caffe2.python.models.download
import argparse
import os
import sys
import signal
import re
import json
from caffe2.proto import caffe2_pb2
# Import urllib
from urllib.error import HTTPError, URLError
import urllib.request as urllib
# urllib requires more work to deal with a redirect... | pytorch-master | caffe2/python/models/download.py |
pytorch-master | caffe2/python/models/__init__.py | |
# Module caffe2.python.models.shufflenet
from caffe2.python import brew
"""
Utilitiy for creating ShuffleNet
"ShuffleNet V2: Practical Guidelines for EfficientCNN Architecture Design" by Ma et. al. 2018
"""
OUTPUT_CHANNELS = {
'0.5x': [24, 48, 96, 192, 1024],
'1.0x': [24, 116, 232, 464, 1024],
'1.5x... | pytorch-master | caffe2/python/models/shufflenet.py |
## @package resnet
# Module caffe2.python.models.resnet
from caffe2.python import brew
import logging
'''
Utility for creating ResNe(X)t
"Deep Residual Learning for Image Recognition" by He, Zhang et. al. 2015
"Aggregated Residual Transformations for Deep Neural Networks" by Xie et. al. 2016
'''
class ResNetBui... | pytorch-master | caffe2/python/models/resnet.py |
import os
from caffe2.proto import caffe2_pb2
def _parseFile(filename):
out_net = caffe2_pb2.NetDef()
# TODO(bwasti): A more robust handler for pathnames.
dir_path = os.path.dirname(__file__)
with open('{dir_path}/{filename}'.format(dir_path=dir_path,
f... | pytorch-master | caffe2/python/models/__sym_init__.py |
import numpy as np
import caffe2.python.models.resnet as resnet
import hypothesis.strategies as st
from hypothesis import given, settings
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.models.imagenet_trainer_test_utils as utils
class ResnetMemongerTest(hu.HypothesisTestCase):
@given(w... | pytorch-master | caffe2/python/models/resnet_test.py |
## @package translate
# Module caffe2.python.models.seq2seq.translate
from abc import ABCMeta, abstractmethod
import argparse
from future.utils import viewitems
import logging
import numpy as np
import sys
from caffe2.python import core, rnn_cell, workspace
from caffe2.python.models.seq2seq.beam_search import Bea... | pytorch-master | caffe2/python/models/seq2seq/translate.py |
import numpy as np
import os
import tempfile
from caffe2.python import test_util, workspace
import caffe2.python.models.seq2seq.seq2seq_util as seq2seq_util
from caffe2.python.models.seq2seq.train import Seq2SeqModelCaffe2
from caffe2.python.models.seq2seq.translate import (
Seq2SeqModelCaffe2EnsembleDecoder,... | pytorch-master | caffe2/python/models/seq2seq/seq2seq_beam_search_test.py |
## @package seq2seq_model_helper
# Module caffe2.python.models.seq2seq.seq2seq_model_helper
from caffe2.python import scope
from caffe2.python.model_helper import ModelHelper
class Seq2SeqModelHelper(ModelHelper):
def __init__(self, init_params=True, **kwargs):
arg_scope = {
'use_cudnn':... | pytorch-master | caffe2/python/models/seq2seq/seq2seq_model_helper.py |
## @package seq2seq_util
# Module caffe2.python.examples.seq2seq_util
""" A bunch of util functions to build Seq2Seq models with Caffe2."""
import collections
from future.utils import viewitems
import caffe2.proto.caffe2_pb2 as caffe2_pb2
from caffe2.python import attention, core, rnn_cell, brew
PAD_ID = 0
PAD... | pytorch-master | caffe2/python/models/seq2seq/seq2seq_util.py |
pytorch-master | caffe2/python/models/seq2seq/__init__.py | |
from caffe2.python.models.seq2seq import seq2seq_model_helper
from caffe2.python import scope, test_util
class Seq2SeqModelHelperTest(test_util.TestCase):
def testConstuctor(self):
model_name = 'TestModel'
m = seq2seq_model_helper.Seq2SeqModelHelper(name=model_name)
self.assertEqual(... | pytorch-master | caffe2/python/models/seq2seq/seq2seq_model_helper_test.py |
## @package beam_search
# Module caffe2.python.models.seq2seq.beam_search
from collections import namedtuple
from caffe2.python import core
import caffe2.python.models.seq2seq.seq2seq_util as seq2seq_util
from caffe2.python.models.seq2seq.seq2seq_model_helper import Seq2SeqModelHelper
class BeamSearchForwardOnly... | pytorch-master | caffe2/python/models/seq2seq/beam_search.py |
## @package train
# Module caffe2.python.models.seq2seq.train
import argparse
import collections
import logging
import math
import numpy as np
import random
import time
import sys
import os
import caffe2.proto.caffe2_pb2 as caffe2_pb2
from caffe2.python import core, workspace, data_parallel_model
import caffe2.py... | pytorch-master | caffe2/python/models/seq2seq/train.py |
## @package formatter
# Module caffe2.python.docs.formatter
from caffe2.python.docs.parser import Parser
class Formatter(object):
def __init__(self):
self.content = ""
def clone(self):
return self.__class__()
def dump(self):
return self.content
def parseAndAdd(self, text... | pytorch-master | caffe2/python/docs/formatter.py |
pytorch-master | caffe2/python/docs/__init__.py | |
## @package parser
# Module caffe2.python.docs.parser
import re
class Parser(object):
# List of tuples (regex_str, lambda(regex_match, formatter))
# If a lambda returns True it will be called repeatedly with replacement
# otherwise it will only be called on text that hasn't been parsed yet.
regexe... | pytorch-master | caffe2/python/docs/parser.py |
## @package generator
# Module caffe2.python.docs.generator
import argparse
import os
from caffe2.python import core, workspace
from caffe2.python.docs.formatter import Markdown
from future.utils import viewitems, viewvalues
OpSchema = workspace.C.OpSchema
class DocUploader(object):
def __init__(self):
... | pytorch-master | caffe2/python/docs/generator.py |
## @package github
# Module caffe2.python.docs.github
import argparse
import os
from caffe2.python.docs.formatter import Markdown
from caffe2.python.docs.generator import OpDocGenerator, DocUploader
from caffe2.python.docs.generator import OperatorDoc, OperatorEngine
class GHOpDocUploader(DocUploader):
def __... | pytorch-master | caffe2/python/docs/github.py |
import ctypes
import os
if 'OSS_ONNXIFI_LIB' in os.environ:
lib = os.environ['OSS_ONNXIFI_LIB']
print("Loading ONNXIFI lib: ".format(lib))
ctypes.CDLL(lib, ctypes.RTLD_GLOBAL)
| pytorch-master | caffe2/python/fakelowp/init_shared_libs.py |
import sys
import numpy as np
def print_test_debug_info(testname, items_dict):
filename = "debug_operator_onnxifi_" + testname + ".txt"
np.set_printoptions(threshold=sys.maxsize)
with open(filename, 'w') as f:
for key, value in items_dict.items():
print(key, value)
f.wr... | pytorch-master | caffe2/python/fakelowp/test_utils.py |
pytorch-master | caffe2/python/fakelowp/__init__.py | |
from caffe2.python import core, schema, muji
from caffe2.python.modeling.net_modifier import NetModifier
import numpy as np
class ComputeNormForBlobs(NetModifier):
"""
This class modifies the net passed in by adding ops to compute norms for
certain blobs.
Args:
blobs: list of blobs to ... | pytorch-master | caffe2/python/modeling/compute_norm_for_blobs.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/python/modeling/gradient_clipping_test.py |
import unittest
from caffe2.python import brew, model_helper, workspace
from caffe2.python.modeling.initializers import (
Initializer, PseudoFP16Initializer)
class InitializerTest(unittest.TestCase):
def test_fc_initializer(self):
model = model_helper.ModelHelper(name="test")
data = m... | pytorch-master | caffe2/python/modeling/initializers_test.py |
pytorch-master | caffe2/python/modeling/__init__.py | |
from caffe2.python import core, schema
from caffe2.python.modeling.net_modifier import NetModifier
import numpy as np
class ComputeHistogramForBlobs(NetModifier):
"""
This class modifies the net passed in by adding ops to compute histogram for
certain blobs.
Args:
blobs: list of blobs t... | pytorch-master | caffe2/python/modeling/compute_histogram_for_blobs.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/python/modeling/get_entry_from_blobs.py |
from caffe2.python import brew, model_helper, scope
from caffe2.python.modeling.parameter_sharing import (
ParameterSharing,
parameter_sharing_context,
)
from caffe2.python.modeling.initializers import (
Initializer
)
import unittest
class ParameterSharingTest(unittest.TestCase):
def test_parame... | pytorch-master | caffe2/python/modeling/parameter_sharing_test.py |
from caffe2.python import core, schema
from caffe2.python.modeling.net_modifier import NetModifier
import numpy as np
class ComputeStatisticsForBlobs(NetModifier):
"""
This class modifies the net passed in by adding ops to compute statistics
for certain blobs. For each blob in the list, its min, max... | pytorch-master | caffe2/python/modeling/compute_statistics_for_blobs.py |
from caffe2.python.core import DataType, BlobReference, ScopedBlobReference
from caffe2.python.modeling.parameter_info import ParameterInfo
class Initializer(object):
'''
This class abstracts out parameter creation. One can come up with a new
Initializer in order to implement more complex parameter i... | pytorch-master | caffe2/python/modeling/initializers.py |
from caffe2.python import core
from caffe2.proto import caffe2_pb2
from caffe2.python.optimizer import get_param_device
from caffe2.python.modeling.net_modifier import NetModifier
import logging
logger = logging.getLogger(__name__)
class GradientClipping(NetModifier):
L1_NORM = 'l1_norm'
L2_NORM = 'l2... | pytorch-master | caffe2/python/modeling/gradient_clipping.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/python/modeling/get_entry_from_blobs_test.py |
import abc
class NetModifier(metaclass=abc.ABCMeta):
"""
An abstraction class for supporting modifying a generated net.
Inherited classes should implement the modify_net method where
related operators are added to the net.
Example usage:
modifier = SomeNetModifier(opts)
modif... | pytorch-master | caffe2/python/modeling/net_modifier.py |
import unittest
from caffe2.python import workspace, brew, model_helper
from caffe2.python.modeling.compute_statistics_for_blobs import (
ComputeStatisticsForBlobs
)
import numpy as np
class ComputeStatisticsForBlobsTest(unittest.TestCase):
def test_compute_statistics_for_blobs(self):
model = mo... | pytorch-master | caffe2/python/modeling/compute_statistics_for_blobs_test.py |
import unittest
from caffe2.python import workspace, brew, model_helper
from caffe2.python.modeling.compute_histogram_for_blobs import (
ComputeHistogramForBlobs
)
import numpy as np
class ComputeHistogramForBlobsTest(unittest.TestCase):
def histogram(self, X, lower_bound=0.0, upper_bound=1.0, num_buck... | pytorch-master | caffe2/python/modeling/compute_histogram_for_blobs_test.py |
from caffe2.python import scope
import contextlib
import logging
logger = logging.getLogger(__name__)
class ParameterSharingContext(object):
"""
This class manages scope driven way of parameter sharing across different
NameScopes.
"""
def __init__(self):
self._scope_overrides = {}
... | pytorch-master | caffe2/python/modeling/parameter_sharing.py |
from caffe2.python import core
import numpy as np
class ParameterTags(object):
BIAS = 'BIAS'
WEIGHT = 'WEIGHT'
COMPUTED_PARAM = 'COMPUTED_PARAM'
class ParameterInfo(object):
def __init__(
self, param_id, param, key=None, shape=None, length=None,
grad=None, blob_copy=No... | pytorch-master | caffe2/python/modeling/parameter_info.py |
import unittest
from caffe2.python import workspace, brew, model_helper
from caffe2.python.modeling.compute_norm_for_blobs import ComputeNormForBlobs
import numpy as np
class ComputeNormForBlobsTest(unittest.TestCase):
def test_compute_norm_for_blobs(self):
model = model_helper.ModelHelper(name="tes... | pytorch-master | caffe2/python/modeling/compute_norm_for_blobs_test.py |
import copy
from caffe2.proto import caffe2_pb2
from caffe2.python import core
def rewrite_init_net_simple(net):
for op in net.op:
op.device_option.device_type = caffe2_pb2.IDEEP
def last_producer(ops, blob):
for (i, op) in reversed(list(enumerate(ops))):
if blob in op.output:
... | pytorch-master | caffe2/python/mkl/rewrite_graph.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_concat_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_relu_op_test.py |
import unittest
import numpy as np
import copy
from hypothesis import given
import hypothesis.strategies as st
from caffe2.python.model_helper import ModelHelper
from caffe2.python.models import resnet
from caffe2.python import workspace, brew
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.m... | pytorch-master | caffe2/python/mkl/rewrite_graph_test.py |
pytorch-master | caffe2/python/mkl/__init__.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_conv_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_elementwise_add_op_test.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.