repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
pytorch | pytorch-main/caffe2/python/test/python_protobuf_test.py |
# make sure we use cpp implementation of protobuf
import os
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "cpp"
# then import protobuf
from caffe2.proto import caffe2_pb2, metanet_pb2
import unittest
class TestCrossProtoCalls(unittest.TestCase):
def testSimple(self):
net = caffe2_pb2.NetDef(... | 624 | 27.409091 | 79 | py |
pytorch | pytorch-main/caffe2/python/test/blob_deallocation_test.py |
from caffe2.python import core, workspace
import unittest
core.GlobalInit(['python'])
class BlobDeallocationTest(unittest.TestCase):
def test(self):
net = core.Net('net')
x = net.GivenTensorStringFill([], ['x'], shape=[3], values=['a', 'b', 'c'])
y = net.GivenTensorStringFill([], ['y... | 632 | 20.827586 | 83 | py |
pytorch | pytorch-main/caffe2/python/layers/fc.py | ## @package fc
# Module caffe2.python.layers.fc
from caffe2.python.helpers.arg_scope import get_current_scope
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
from caffe2.python.layers.sampling_trainable_mixin import SamplingTrainableMixin
import math
import numpy as np
def get... | 9,288 | 39.212121 | 99 | py |
pytorch | pytorch-main/caffe2/python/layers/feature_sparse_to_dense.py | # @package sparse_to_dense
# Module caffe2.python.layers.sparse_to_dense
from collections import defaultdict
import numpy as np
from caffe2.python import schema
from caffe2.python.layers.layers import AccessedFeatures, ModelLayer
class FeatureSparseToDense(ModelLayer):
def __init__(
self,
model... | 14,335 | 42.311178 | 88 | py |
pytorch | pytorch-main/caffe2/python/layers/concat.py | ## @package concat
# Module caffe2.python.layers.concat
from caffe2.python import schema
from caffe2.python.layers.layers import (
ModelLayer,
)
import numpy as np
from collections import defaultdict
import logging
logger = logging.getLogger(__name__)
def get_concatenated_feature_to_index(blobs_to_concat):
... | 4,799 | 34.036496 | 98 | py |
pytorch | pytorch-main/caffe2/python/layers/batch_lr_loss.py | ## @package batch_lr_loss
# Module caffe2.python.layers.batch_lr_loss
from caffe2.python import core, schema
from caffe2.python.layers.layers import (
ModelLayer,
)
from caffe2.python.layers.tags import (
Tags
)
import numpy as np
class BatchLRLoss(ModelLayer):
def __init__(
self,
mod... | 11,560 | 33.717718 | 81 | py |
pytorch | pytorch-main/caffe2/python/layers/split.py | ## @package split
# Module caffe2.python.layers.split
from caffe2.python import schema
from caffe2.python.layers.layers import (
ModelLayer,
)
class Split(ModelLayer):
def __init__(self, model, input_record, num_splits=1, axis=1,
name='split', split=None, **kwargs):
super().__in... | 2,246 | 28.565789 | 74 | py |
pytorch | pytorch-main/caffe2/python/layers/last_n_window_collector.py | ## @package last_n_window_collector
# Module caffe2.python.layers.last_n_window_collector
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
class LastNWindowCollector(ModelLayer):
"""
Collect last-N samples from input record. If you have complex data,
use PackRecor... | 2,353 | 32.628571 | 74 | py |
pytorch | pytorch-main/caffe2/python/layers/random_fourier_features.py |
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
import numpy as np
class RandomFourierFeatures(ModelLayer):
"""
Implementation of random fourier feature map for feature processing.
Applies sqrt(2 / output_dims) * cos(wx+b), where:
output_dims is the outpu... | 3,108 | 33.164835 | 81 | py |
pytorch | pytorch-main/caffe2/python/layers/gather_record.py | ## @package gather_record
# Module caffe2.python.layers.gather_record
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
class GatherRecord(ModelLayer):
"""
Given 1-D `indices` tensor, gather elements at `i` in `indices` from all the
blobs in `record`. If a blob... | 3,242 | 35.033333 | 80 | py |
pytorch | pytorch-main/caffe2/python/layers/batch_sigmoid_cross_entropy_loss.py | ## @package batch_sigmoid_cross_entropy_loss
# Module caffe2.python.layers.batch_sigmoid_cross_entropy_loss
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
from caffe2.python.layers.tags import Tags
import numpy as np
class BatchSigmoidCrossEntropyLoss(ModelLayer):
def __i... | 1,436 | 28.326531 | 72 | py |
pytorch | pytorch-main/caffe2/python/layers/fc_without_bias.py | ## @package fc_without_bias
# Module caffe2.python.layers.fc_without_bias
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
from caffe2.python.layers.sampling_trainable_mixin import SamplingTrainableMixin
import math
import numpy as np
class FCWithoutBias(SamplingTrainableMixin... | 1,935 | 29.25 | 83 | py |
pytorch | pytorch-main/caffe2/python/layers/pairwise_similarity.py | ## @package dot_product
# Module caffe2.python.layers.dot_product
from caffe2.python import schema
from caffe2.python.layers.layers import (
ModelLayer,
)
class PairwiseSimilarity(ModelLayer):
def __init__(self, model, input_record, output_dim, pairwise_similarity_func='dot',
name='pair... | 3,525 | 35.350515 | 87 | py |
pytorch | pytorch-main/caffe2/python/layers/merge_id_lists.py |
from caffe2.python import schema
from caffe2.python.layers.layers import (
get_categorical_limit,
ModelLayer,
IdList
)
import numpy as np
class MergeIdLists(ModelLayer):
"""Merge multiple ID_LISTs into a single ID_LIST
Args:
model: A layer model instance
input_record: Tuple ... | 1,482 | 28.078431 | 76 | py |
pytorch | pytorch-main/caffe2/python/layers/arc_cosine_feature_map.py |
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
import numpy as np
class ArcCosineFeatureMap(ModelLayer):
"""
A general version of the arc-cosine kernel feature map (s = 1 restores
the original arc-cosine kernel feature map).
Applies H(x) * x^s, where H is the... | 7,270 | 39.620112 | 83 | py |
pytorch | pytorch-main/caffe2/python/layers/batch_huber_loss.py | # @package batch_huber_loss
# Module caffe2.python.layers.batch_huber_loss
from caffe2.python import core, schema
from caffe2.python.layers.layers import (
ModelLayer,
)
from caffe2.python.layers.tags import (
Tags
)
import numpy as np
class BatchHuberLoss(ModelLayer):
def __init__(self, model, inpu... | 3,503 | 28.2 | 90 | py |
pytorch | pytorch-main/caffe2/python/layers/reservoir_sampling.py | ## @package reservoir_sampling
# Module caffe2.python.layers.reservoir_sampling
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
class ReservoirSampling(ModelLayer):
"""
Collect samples from input record w/ reservoir sampling. If you have complex
data, use Pac... | 2,977 | 32.460674 | 80 | py |
pytorch | pytorch-main/caffe2/python/layers/sampling_trainable_mixin.py | ## @package sampling_trainable_mixin
# Module caffe2.python.layers.sampling_trainable_mixin
import abc
class SamplingTrainableMixin(metaclass=abc.ABCMeta):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._train_param_blobs = None
self._train_param_blobs_fr... | 1,338 | 23.796296 | 75 | py |
pytorch | pytorch-main/caffe2/python/layers/functional.py | # @package functional
# Module caffe2.python.layers.functional
from caffe2.python import core, schema, scope, workspace
from caffe2.python.layers.layers import (
ModelLayer,
)
import caffe2.proto.caffe2_pb2 as caffe2_pb2
import numpy as np
import logging
logger = logging.getLogger(__name__)
logger.setLevel(lo... | 4,859 | 38.193548 | 80 | py |
pytorch | pytorch-main/caffe2/python/layers/semi_random_features.py |
from caffe2.python import schema
from caffe2.python.layers.arc_cosine_feature_map import ArcCosineFeatureMap
import numpy as np
class SemiRandomFeatures(ArcCosineFeatureMap):
"""
Implementation of the semi-random kernel feature map.
Applies H(x_rand) * x_rand^s * x_learned, where
H is the He... | 5,785 | 38.903448 | 87 | py |
pytorch | pytorch-main/caffe2/python/layers/layer_normalization.py |
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
import numpy as np
class LayerNormalization(ModelLayer):
def __init__(
self,
model,
input_record,
name='layer_normalization',
scale_optim=None,
bias_optim=None,
epsilon... | 4,254 | 34.165289 | 97 | py |
pytorch | pytorch-main/caffe2/python/layers/tags.py | ## @package tags
# Module caffe2.python.layers.tags
import functools
from caffe2.python import context
class TagContext(context.DefaultManaged):
"""
Scope driven way to provide tags to the layers.
"""
def __init__(self, tags=None):
# Tags is expected to be list to keep order of adding/r... | 4,106 | 32.390244 | 85 | py |
pytorch | pytorch-main/caffe2/python/layers/adaptive_weight.py | # @package adaptive_weight
# Module caffe2.fb.python.layers.adaptive_weight
import numpy as np
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
from caffe2.python.regularizer import BoundedGradientProjection, LogBarrier
"""
Implementation of adaptive weighting: https://arxiv... | 5,667 | 34.204969 | 88 | py |
pytorch | pytorch-main/caffe2/python/layers/sparse_feature_hash.py | ## @package sparse_feature_hash
# Module caffe2.python.layers.sparse_feature_hash
from caffe2.python import schema, core
from caffe2.python.layers.layers import (
ModelLayer,
IdList,
IdScoreList,
)
from caffe2.python.layers.tags import (
Tags
)
import numpy as np
class SparseFeatureHash(ModelLay... | 4,595 | 38.965217 | 118 | py |
pytorch | pytorch-main/caffe2/python/layers/layers.py | ## @package layers
# Module caffe2.python.layers.layers
import logging
from collections import namedtuple
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, schema, scope, utils, workspace
from caffe2.python.layers.tags import TagContext
logger = logging.getLogger(__name__)
logg... | 17,388 | 33.987928 | 88 | py |
pytorch | pytorch-main/caffe2/python/layers/bucket_weighted.py | ## @package bucket_weighted
# Module caffe2.python.layers.bucket_weighted
import logging
import numpy as np
from caffe2.python import core, schema
from caffe2.python.layers.layers import (
get_categorical_limit,
ModelLayer,
)
from caffe2.python.layers.tags import Tags
logger = logging.getLogger(__name__... | 2,335 | 30.567568 | 84 | py |
pytorch | pytorch-main/caffe2/python/layers/dropout.py | # Module caffe2.python.layers.dropout
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
class Dropout(ModelLayer):
def __init__(
self,
model,
input_record,
name='dropout',
ratio=0.5,
dropout_for_eval=Fa... | 1,397 | 26.411765 | 78 | py |
pytorch | pytorch-main/caffe2/python/layers/batch_mse_loss.py | ## @package batch_mse_loss
# Module caffe2.python.layers.batch_mse_loss
from caffe2.python import core, schema
from caffe2.python.layers.layers import (
ModelLayer,
)
from caffe2.python.layers.tags import (
Tags
)
import numpy as np
class BatchMSELoss(ModelLayer):
def __init__(self, model, input_rec... | 2,315 | 27.95 | 77 | py |
pytorch | pytorch-main/caffe2/python/layers/sampling_train.py | ## @package sampling_train
# Module caffe2.python.layers.sampling_train
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer, get_layer_class
from caffe2.python.layers.sampling_trainable_mixin import SamplingTrainableMixin
class SamplingTrain(ModelLayer):
def __init__(
... | 2,169 | 30 | 80 | py |
pytorch | pytorch-main/caffe2/python/layers/sparse_dropout_with_replacement.py |
from caffe2.python import schema
from caffe2.python.layers.layers import (
IdList,
ModelLayer,
)
# Model layer for implementing probabilistic replacement of elements in
# IdLists. Takes probabilities for train, eval and predict nets as input, as
# well as the replacement value when dropout happens. For ... | 3,909 | 38.494949 | 82 | py |
pytorch | pytorch-main/caffe2/python/layers/select_record_by_context.py |
import logging
from caffe2.python import schema
from caffe2.python.layers.layers import (
InstantiationContext,
ModelLayer,
)
logger = logging.getLogger(__name__)
class SelectRecordByContext(ModelLayer):
"""
Allowing model to follow different paths for each instantiation context and
join l... | 2,302 | 28.909091 | 79 | py |
pytorch | pytorch-main/caffe2/python/layers/label_smooth.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... | 3,490 | 35.364583 | 78 | py |
pytorch | pytorch-main/caffe2/python/layers/bpr_loss.py | ## @package bpr_loss
# Module caffe2.python.layers.bpr_loss
from caffe2.python import schema
from caffe2.python.layers.layers import (
ModelLayer,
)
from caffe2.python.layers.tags import (
Tags
)
import numpy as np
# ref: https://arxiv.org/pdf/1205.2618.pdf
class BPRLoss(ModelLayer):
def __init__(se... | 1,486 | 28.74 | 74 | py |
pytorch | pytorch-main/caffe2/python/layers/uniform_sampling.py | ## @package uniform_sampling
# Module caffe2.python.layers.uniform_sampling
import numpy as np
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
class UniformSampling(ModelLayer):
"""
Uniform sampling `num_samples - len(input_record)` unique elements from the
... | 2,736 | 32.378049 | 79 | py |
pytorch | pytorch-main/caffe2/python/layers/add_bias.py | ## @package add_bias
# Module caffe2.python.layers.add_bias
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
import math
class AddBias(ModelLayer):
def __init__(self, model, input_record, bias_init=None,
bias_optim=None, name='add_bias'):
super()._... | 1,383 | 29.755556 | 78 | py |
pytorch | pytorch-main/caffe2/python/layers/conv.py | ## @package conv
# Module caffe2.python.layers.conv
from caffe2.python import schema
from caffe2.python.layers.layers import (
ModelLayer,
)
import numpy as np
class Conv(ModelLayer):
"""
Convolutional layer
Input:
- input_record: at least has the shape info of C (num_channels)
... | 5,040 | 36.066176 | 84 | py |
pytorch | pytorch-main/caffe2/python/layers/build_index.py |
import numpy as np
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
class MapToRange(ModelLayer):
"""
This layer aims to build a mapping from raw keys to indices within [0, max_index).
The mapping is continuously built during training. The mapping will be fro... | 1,921 | 26.070423 | 88 | py |
pytorch | pytorch-main/caffe2/python/layers/homotopy_weight.py | # @package homotopy_weight
# Module caffe2.fb.python.layers.homotopy_weight
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
import numpy as np
import logging
logger = logging.getLogger(__name__)
'''
Homotopy Weighting between two weights x, y by doing:
alpha x + beta ... | 4,306 | 33.456 | 80 | py |
pytorch | pytorch-main/caffe2/python/layers/batch_softmax_loss.py | ## @package batch_softmax_loss
# Module caffe2.python.layers.batch_softmax_loss
from caffe2.python import core, schema
from caffe2.python.layers.layers import ModelLayer
import numpy as np
class BatchSoftmaxLoss(ModelLayer):
def __init__(
self,
model,
input_record,
name='batch... | 4,545 | 34.515625 | 80 | py |
pytorch | pytorch-main/caffe2/python/layers/fc_with_bootstrap.py | ## @package fc_with_bootstrap
# Module caffe2.python.layers.fc_with_bootstrap
import math
import numpy as np
from caffe2.python import core, schema
from caffe2.python.helpers.arg_scope import get_current_scope
from caffe2.python.layers.layers import ModelLayer
from caffe2.python.layers.sampling_trainable_mixin impor... | 12,767 | 34.076923 | 88 | py |
pytorch | pytorch-main/caffe2/python/layers/constant_weight.py | # @package constant_weight
# Module caffe2.fb.python.layers.constant_weight
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
import numpy as np
class ConstantWeight(ModelLayer):
def __init__(
self,
model,
input_record,
weights=None,
n... | 1,208 | 25.866667 | 79 | py |
pytorch | pytorch-main/caffe2/python/layers/margin_rank_loss.py | ## @package random_neg_rank_loss
# Module caffe2.python.layers.random_neg_rank_loss
from caffe2.python import schema, core
from caffe2.python.layers.layers import (
ModelLayer,
)
from caffe2.python.layers.tags import (
Tags
)
import numpy as np
class MarginRankLoss(ModelLayer):
def __init__(self, mo... | 1,931 | 29.666667 | 79 | py |
pytorch | pytorch-main/caffe2/python/layers/sparse_itemwise_dropout_with_replacement.py |
from caffe2.python import schema
from caffe2.python.layers.layers import (
IdList,
ModelLayer,
)
# Model layer for implementing probabilistic replacement of individual elements in
# IdLists. Takes probabilities for train, eval and predict nets as input, as
# well as the replacement value when dropout hap... | 3,902 | 36.528846 | 83 | py |
pytorch | pytorch-main/caffe2/python/layers/position_weighted.py | ## @package position_weighted
# Module caffe2.python.layers.position_weighted
import logging
import numpy as np
from caffe2.python import schema
from caffe2.python.layers.layers import (
get_categorical_limit,
ModelLayer,
)
from caffe2.python.layers.tags import Tags
logger = logging.getLogger(__name__)
... | 2,044 | 30.461538 | 84 | py |
pytorch | pytorch-main/caffe2/python/layers/blob_weighted_sum.py | ## @package BlobWeightedSum
# Module caffe2.python.layers.blob_weighted_sum
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
class BlobWeightedSum(ModelLayer):
"""
This layer implements the weighted sum:
weighted element-wise sum of input blobs.
"""
def __in... | 2,198 | 28.716216 | 86 | py |
pytorch | pytorch-main/caffe2/python/layers/batch_normalization.py |
from caffe2.python import schema
from caffe2.python.layers.layers import ModelLayer
import numpy as np
class BatchNormalization(ModelLayer):
def __init__(
self,
model,
input_record,
name='batch_normalization',
scale_optim=None,
bias_optim=None,
momentu... | 3,786 | 34.064815 | 97 | py |
pytorch | pytorch-main/caffe2/python/layers/sparse_lookup.py | ## @package sparse_lookup
# Module caffe2.python.layers.sparse_lookup
from caffe2.python.optimizer import FP16_ENGINES, Optimizer
from caffe2.python.helpers.arg_scope import get_current_scope
from caffe2.python import schema
from caffe2.python.layers.layers import (
get_categorical_limit,
get_key,
IdLi... | 22,152 | 38.700717 | 107 | py |
pytorch | pytorch-main/caffe2/python/ideep/dropout_op_test.py |
import unittest
from hypothesis import given
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class DropoutT... | 2,075 | 33.6 | 76 | py |
pytorch | pytorch-main/caffe2/python/ideep/pre_convert_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import (
brew,
core,
model_helper,
workspace,
)
from caffe2.python.transformations import optimizeForMKLDNN
import caffe2.python.hypothesis_test_... | 4,115 | 41 | 104 | py |
pytorch | pytorch-main/caffe2/python/ideep/conv_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
from caffe2.python.transformations import optimizeForMKLDNN
import caffe2.python.hypothesis_test_util as hu
import caffe2.python... | 5,666 | 33.138554 | 85 | py |
pytorch | pytorch-main/caffe2/python/ideep/transform_ideep_net.py |
import argparse
import copy
import json
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace, utils
import caffe2.python._import_c_extension as C
def pairwise(iterable):
from itertools import tee
a, b = tee(iterable)
next(b, None)
return zip(a, b)
... | 11,683 | 33.26393 | 121 | py |
pytorch | pytorch-main/caffe2/python/ideep/softmax_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.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class SoftmaxTe... | 932 | 25.657143 | 78 | py |
pytorch | pytorch-main/caffe2/python/ideep/concat_split_op_test.py |
import numpy as np
import hypothesis.strategies as st
import unittest
import caffe2.python.hypothesis_test_util as hu
from caffe2.python import core, workspace
from hypothesis import given, settings
import caffe2.python.ideep_test_util as mu
@st.composite
def _tensor_splits(draw, add_axis=False):
"""Generates... | 5,532 | 32.533333 | 89 | py |
pytorch | pytorch-main/caffe2/python/ideep/sigmoid_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class SigmoidTest(hu.HypothesisTestCase):
@... | 775 | 22.515152 | 66 | py |
pytorch | pytorch-main/caffe2/python/ideep/expanddims_squeeze_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.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class ExpandDi... | 4,285 | 30.284672 | 73 | py |
pytorch | pytorch-main/caffe2/python/ideep/operator_fallback_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given
import numpy as np
from caffe2.python import core, workspace
from caffe2.proto import caffe2_pb2
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, ... | 3,450 | 33.51 | 77 | py |
pytorch | pytorch-main/caffe2/python/ideep/elementwise_sum_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, ... | 6,317 | 32.078534 | 76 | py |
pytorch | pytorch-main/caffe2/python/ideep/fc_op_test.py |
import unittest
from functools import reduce
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unitt... | 11,745 | 29.748691 | 109 | py |
pytorch | pytorch-main/caffe2/python/ideep/test_ideep_net.py |
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
from caffe2.python.models.download import ModelDownloader
import numpy as np
import argparse
import time
def GetArgumentParser():
parser = argparse.ArgumentParser(description="Caffe2 benchmark.")
parser.add_argument(
"-... | 4,094 | 30.259542 | 87 | py |
pytorch | pytorch-main/caffe2/python/ideep/moment_sgd_op_test.py |
import numpy as np
import hypothesis.strategies as st
import unittest
import caffe2.python.hypothesis_test_util as hu
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class TestMome... | 1,777 | 27.677419 | 66 | py |
pytorch | pytorch-main/caffe2/python/ideep/reshape_op_test.py |
from caffe2.python.test_util import TestCase
from caffe2.proto import caffe2_pb2
import unittest
import numpy as np
from caffe2.python import core, workspace
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class TestReShapeOps(TestCase):
def test_reshape_ops(self):
device_opt = cor... | 5,919 | 39.827586 | 111 | py |
pytorch | pytorch-main/caffe2/python/ideep/convfusion_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given
import numpy as np
import math
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
from caffe2.python.transformations import optimizeForMKLDNN
import caffe2.python.hypothesis_test_util as hu
import caffe2.pyth... | 31,919 | 36.030162 | 107 | py |
pytorch | pytorch-main/caffe2/python/ideep/spatial_bn_op_test.py |
from hypothesis import given, settings
import hypothesis.strategies as st
import numpy as np
import unittest
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
clas... | 5,237 | 38.089552 | 84 | py |
pytorch | pytorch-main/caffe2/python/ideep/weightedsum_op_test.py |
import numpy as np
import hypothesis.strategies as st
import unittest
import caffe2.python.hypothesis_test_util as hu
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class TestWeig... | 1,560 | 25.913793 | 66 | py |
pytorch | pytorch-main/caffe2/python/ideep/shape_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
clas... | 2,631 | 28.244444 | 68 | py |
pytorch | pytorch-main/caffe2/python/ideep/relu_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use... | 3,705 | 27.507692 | 80 | py |
pytorch | pytorch-main/caffe2/python/ideep/channel_shuffle_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
clas... | 1,286 | 26.978261 | 105 | py |
pytorch | pytorch-main/caffe2/python/ideep/adam_op_test.py |
import numpy as np
import hypothesis.strategies as st
import unittest
import caffe2.python.hypothesis_test_util as hu
from caffe2.python import core, workspace
from hypothesis import given
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class TestAdam... | 3,212 | 37.710843 | 85 | py |
pytorch | pytorch-main/caffe2/python/ideep/conv_transpose_test.py |
import unittest
import numpy as np
from hypothesis import assume, given, settings
import hypothesis.strategies as st
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support... | 2,595 | 32.714286 | 76 | py |
pytorch | pytorch-main/caffe2/python/ideep/LRN_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
clas... | 1,195 | 25 | 76 | py |
pytorch | pytorch-main/caffe2/python/ideep/transpose_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class... | 1,284 | 28.204545 | 94 | py |
pytorch | pytorch-main/caffe2/python/ideep/leaky_relu_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace, model_helper
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN s... | 2,854 | 29.698925 | 80 | py |
pytorch | pytorch-main/caffe2/python/ideep/order_switch_op_test.py |
import unittest
import numpy as np
import hypothesis.strategies as st
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
from hypothesis import given, settings
from caffe2.python import core, workspace
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
cla... | 2,299 | 27.04878 | 66 | py |
pytorch | pytorch-main/caffe2/python/ideep/copy_op_test.py |
import unittest
import numpy as np
from random import randint
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class CopyTest(unittest.TestCase):
def _get_deep_device(self):
return caffe2_pb2.DeviceOption(... | 3,074 | 29.75 | 68 | py |
pytorch | pytorch-main/caffe2/python/ideep/blobs_queue_db_test.py |
import unittest
import numpy as np
import caffe2.proto.caffe2_pb2 as caffe2_pb2
from caffe2.python import core, workspace, timeout_guard
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class BlobsQueueDBTest(unittest.TestCase):
def test_create_blobs_queue_db_string(self):
device_o... | 4,045 | 35.781818 | 82 | py |
pytorch | pytorch-main/caffe2/python/ideep/pool_op_test.py |
import unittest
import hypothesis.strategies as st
from hypothesis import assume, given, settings
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.ideep_test_util as mu
@unittest.skipIf(not workspa... | 4,296 | 27.269737 | 70 | py |
pytorch | pytorch-main/caffe2/python/docs/parser.py | ## @package parser
# Module caffe2.python.docs.parser
import re
class Parser:
# 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.
regexes = [
... | 2,912 | 29.030928 | 76 | py |
pytorch | pytorch-main/caffe2/python/docs/github.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 __... | 4,052 | 31.166667 | 83 | py |
pytorch | pytorch-main/caffe2/python/docs/formatter.py | ## @package formatter
# Module caffe2.python.docs.formatter
from caffe2.python.docs.parser import Parser
class Formatter:
def __init__(self):
self.content = ""
def clone(self):
return self.__class__()
def dump(self):
return self.content
def parseAndAdd(self, text):
... | 2,866 | 26.304762 | 80 | py |
pytorch | pytorch-main/caffe2/python/docs/generator.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
OpSchema = workspace.C.OpSchema
class DocUploader:
def __init__(self):
pass
def upload(self, text):
pass
cla... | 7,165 | 30.021645 | 82 | py |
pytorch | pytorch-main/caffe2/python/onnx/backend_cpp_rep.py | ## @package onnx
# Module caffe2.python.onnx.backend_rep_cpp
from onnx.backend.base import BackendRep, namedtupledict
# This is a wrapper around C++ Caffe2BackendRep,
# mainly to handle the different input and output types for convenience of Python
class Caffe2CppRep(BackendRep):
def __init__(self, cpp_rep):... | 1,844 | 34.480769 | 81 | py |
pytorch | pytorch-main/caffe2/python/onnx/onnxifi.py | ## @package onnx
#Module caffe2.python.onnx.onnxifi
"""
ONNXIFI a Caffe2 net
"""
from caffe2.proto import caffe2_pb2
import caffe2.python._import_c_extension as C
def onnxifi_set_option(option_name, option_value):
"""
Set onnxifi option
"""
return C.onnxifi_set_option(option_name, str(option_value))... | 2,241 | 31.492754 | 93 | py |
pytorch | pytorch-main/caffe2/python/onnx/error.py | ## @package onnx
# Module caffe2.python.onnx.error
class BaseException(Exception): pass
class Unsupported(BaseException): pass
| 131 | 13.666667 | 38 | py |
pytorch | pytorch-main/caffe2/python/onnx/backend_rep.py | # @package onnx
# Module caffe2.python.onnx.backend_rep
from caffe2.python import core
from caffe2.proto import caffe2_pb2
from onnx.backend.base import BackendRep, namedtupledict
class Caffe2Rep(BackendRep):
def __init__(self, init_net, predict_net, workspace, uninitialized):
super().__init__()
... | 2,800 | 41.439394 | 81 | py |
pytorch | pytorch-main/caffe2/python/onnx/workspace.py | ## @package onnx
# Module caffe2.python.onnx.workspace
import uuid
from caffe2.python import workspace
# Separating out the context manager part so that users won't
# (mis-)use Workspace instances as context managers
class _WorkspaceCtx:
def __init__(self, workspace_id):
self.workspace_id = workspac... | 2,987 | 40.5 | 80 | py |
pytorch | pytorch-main/caffe2/python/onnx/helper.py | ## @package onnx
# Module caffe2.python.onnx.helper
from caffe2.proto import caffe2_pb2
from onnx.backend.base import namedtupledict
from caffe2.python.onnx.workspace import Workspace
import logging
import time
log = logging.getLogger(__name__)
def c2_native_run_op(op_def, inputs):
ws = Workspace()
if... | 4,158 | 33.371901 | 101 | py |
pytorch | pytorch-main/caffe2/python/onnx/test_onnxifi.py |
import numpy as np
import time
import unittest
import onnx
import onnx.defs
from onnx.backend.base import namedtupledict
from onnx.helper import make_node, make_graph, make_tensor_value_info, make_model
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
from caffe2.python.models.downloa... | 7,728 | 37.645 | 114 | py |
pytorch | pytorch-main/caffe2/python/onnx/backend.py | ## @package onnx
# Module caffe2.python.onnx.backend
"""Backend for running ONNX on Caffe2
To run this, you will need to have Caffe2 installed as well.
"""
import collections
import sys
import zipfile
import itertools
# When onnx is built against a version of protobuf that is older than
# that which is vendored with... | 41,567 | 41.942149 | 346 | py |
pytorch | pytorch-main/caffe2/python/onnx/frontend.py | ## @package onnx
# Module caffe2.python.onnx.frontend
"""Caffe2 Protobuf to ONNX converter
To run this, you will need to have Caffe2 installed as well.
"""
import collections
import itertools
import logging
import re
from caffe2.python import core as caffe2_core
from onnx import (checker, helper, numpy_helper, ... | 12,830 | 34.840782 | 106 | py |
pytorch | pytorch-main/caffe2/python/onnx/bin/conversion.py | ## @package onnx
# Module caffe2.python.onnx.bin.conversion
import json
from caffe2.proto import caffe2_pb2
import click
from onnx import ModelProto
from caffe2.python.onnx.backend import Caffe2Backend as c2
import caffe2.python.onnx.frontend as c2_onnx
@click.command(
help='convert caffe2 net to onnx mode... | 2,847 | 31 | 73 | py |
pytorch | pytorch-main/caffe2/python/onnx/tests/helper_test.py | ## @package onnx
# Module caffe2.python.onnx.tests.helper_test
import unittest
from caffe2.python.onnx.tests.test_utils import TestCase
import caffe2.python._import_c_extension as C
class TestCaffe2Basic(TestCase):
def test_dummy_name(self):
g = C.DummyName()
g.reset()
names_1 = [g.... | 807 | 22.085714 | 56 | py |
pytorch | pytorch-main/caffe2/python/onnx/tests/c2_ref_test.py | # @package onnx
# Module caffe2.python.onnx.tests.c2_ref_test
import os
import unittest
from caffe2.python import core
from caffe2.proto import caffe2_pb2
import onnx
from onnx.helper import make_node, make_graph, make_tensor, make_tensor_value_info, make_model
from caffe2.python.onnx.helper import c2_native_ru... | 31,577 | 35.296552 | 113 | py |
pytorch | pytorch-main/caffe2/python/onnx/tests/conversion_test.py | ## @package onnx
# Module caffe2.python.onnx.tests.conversion_test
import json
import tempfile
import textwrap
import traceback
import unittest
import zipfile
from caffe2.proto import caffe2_pb2
from caffe2.python import brew, core
from caffe2.python.model_helper import ModelHelper
from click.testing import CliRu... | 15,159 | 40.534247 | 98 | py |
pytorch | pytorch-main/caffe2/python/onnx/tests/onnx_backend_test.py | # @package onnx
# Module caffe2.python.onnx.tests.onnx_backend_test
import os
import unittest
import onnx.backend.test
import caffe2.python.onnx.backend as c2
from caffe2.python import core
core.SetEnginePref({}, {})
# This is a pytest magic variable to load extra plugins
pytest_plugins = 'onnx.backend.test.r... | 10,862 | 51.990244 | 108 | py |
pytorch | pytorch-main/caffe2/python/onnx/tests/ssa_test.py | ## @package onnx
# Module caffe2.python.onnx.tests.ssa_test
import copy
import numpy as np
from caffe2.proto import caffe2_pb2
from caffe2.python import core
from onnx import TensorProto
import caffe2.python.onnx.frontend as c2_onnx
from caffe2.python.onnx.helper import c2_native_run_net
from caffe2.python.onnx.... | 4,016 | 28.755556 | 73 | py |
pytorch | pytorch-main/caffe2/python/onnx/tests/test_utils.py | ## @package onnx
# Module caffe2.python.onnx.tests.test_utils
import unittest
import numpy as np
class TestCase(unittest.TestCase):
def setUp(self):
np.random.seed(seed=0)
def assertSameOutputs(self, outputs1, outputs2, decimal=7):
self.assertEqual(len(outputs1), len(outputs2))
... | 787 | 25.266667 | 80 | py |
pytorch | pytorch-main/caffe2/python/modeling/initializers.py |
from caffe2.python.core import DataType, BlobReference, ScopedBlobReference
from caffe2.python.modeling.parameter_info import ParameterInfo
class Initializer:
'''
This class abstracts out parameter creation. One can come up with a new
Initializer in order to implement more complex parameter initializ... | 5,362 | 33.824675 | 81 | py |
pytorch | pytorch-main/caffe2/python/modeling/parameter_sharing_test.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... | 7,211 | 45.230769 | 80 | py |
pytorch | pytorch-main/caffe2/python/modeling/parameter_info.py |
from caffe2.python import core
import numpy as np
class ParameterTags:
BIAS = 'BIAS'
WEIGHT = 'WEIGHT'
COMPUTED_PARAM = 'COMPUTED_PARAM'
class ParameterInfo:
def __init__(
self, param_id, param, key=None, shape=None, length=None,
grad=None, blob_copy=None):
ass... | 1,422 | 24.872727 | 74 | py |
pytorch | pytorch-main/caffe2/python/modeling/initializers_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... | 2,106 | 35.964912 | 72 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.