python_code
stringlengths
0
1.02M
repo_name
stringlengths
9
48
file_path
stringlengths
5
114
import numpy as np import caffe2.proto.caffe2_pb2 as caffe2_pb2 from caffe2.python import core, workspace, timeout_guard, test_util class BlobsQueueDBTest(test_util.TestCase): def test_create_blobs_queue_db_string(self): def add_blobs(queue, num_samples): blob = core.BlobReference("blob"...
pytorch-master
caffe2/python/operator_test/blobs_queue_db_test.py
import hypothesis.strategies as st from hypothesis import given, assume, settings import io import math import numpy as np import os import struct import unittest from pathlib import Path from typing import Dict, Generator, List, NamedTuple, Optional, Tuple, Type from caffe2.proto import caffe2_pb2 from caffe2.proto.ca...
pytorch-master
caffe2/python/operator_test/load_save_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 copy from functools import partial import math import numpy as np class TestLearnin...
pytorch-master
caffe2/python/operator_test/learning_rate_op_test.py
import unittest from hypothesis import given, assume, settings import hypothesis.strategies as st import numpy as np import operator from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.serialized_test.serialized_test_u...
pytorch-master
caffe2/python/operator_test/elementwise_op_broadcast_test.py
from caffe2.python import recurrent, workspace from caffe2.python.model_helper import ModelHelper 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 class R...
pytorch-master
caffe2/python/operator_test/recurrent_network_test.py
from caffe2.python import core, workspace from caffe2.python.test_util import TestCase import unittest class TestAtomicOps(TestCase): @unittest.skip("Test is flaky: https://github.com/pytorch/pytorch/issues/28179") def test_atomic_ops(self): """ Test that both countdown and checksum are u...
pytorch-master
caffe2/python/operator_test/atomic_ops_test.py
from caffe2.python import core from hypothesis import given, settings import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st import numpy as np class RMACRegionsOpTest(hu.HypothesisTestCase): @given( n=st.integers(500, 500), h=st.integers(1, 10), w=st.integ...
pytorch-master
caffe2/python/operator_test/rmac_regions_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 TestPackRNNSequenceOperator(serial.SerializedTestCase): @serial.given(n=st.integers(0, 10), k=st.inte...
pytorch-master
caffe2/python/operator_test/pack_rnn_sequence_op_test.py
from caffe2.python import core 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 TestLengthsTopKOps(serial.SerializedTestCase): @serial.given(N=st.integer...
pytorch-master
caffe2/python/operator_test/lengths_top_k_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 import unittest class TestSelu(serial.SerializedTestCase): @serial....
pytorch-master
caffe2/python/operator_test/selu_op_test.py
import numpy as np import caffe2.python.hypothesis_test_util as hu from caffe2.python import core, utils from hypothesis import given, settings import hypothesis.strategies as st class Depthwise3x3ConvOpsTest(hu.HypothesisTestCase): @given(pad=st.integers(0, 1), kernel=st.integers(3, 3), ...
pytorch-master
caffe2/python/operator_test/depthwise_3x3_conv_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 class TestExpandOp(serial.SerializedTestCase): def _rand_shape(self,...
pytorch-master
caffe2/python/operator_test/expand_op_test.py
from caffe2.python import core, workspace 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 TestIndexHashOps(serial.SerializedTestCase): @given(...
pytorch-master
caffe2/python/operator_test/index_hash_ops_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 TestLengthsReducerOpsFusedNBitRowwise(hu.HypothesisTestCase): @given( num_rows=st.integers(1, 20), blocksize=st.sampl...
pytorch-master
caffe2/python/operator_test/lengths_reducer_fused_nbit_rowwise_ops_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 TestHyperbolicOps(serial.SerializedTestCase): def _test_hyperbolic_op(self, op_name, np_ref, X, in_pla...
pytorch-master
caffe2/python/operator_test/hyperbolic_ops_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 unittest import numpy as np def get_op(input_len, output_len, args): input_names ...
pytorch-master
caffe2/python/operator_test/box_with_nms_limit_op_test.py
import argparse import datetime import numpy as np from caffe2.python import core, workspace DTYPES = { "uint8": np.uint8, "uint8_fused": np.uint8, "float": np.float32, "float16": np.float16, } def benchmark_sparse_lengths_sum( dtype_str, categorical_limit, embedding_size, average...
pytorch-master
caffe2/python/operator_test/sparse_lengths_sum_benchmark.py
import functools 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 from caffe2.python.operator_test.adagrad_test_helper import ( adagrad_sparse_test_helper, ref...
pytorch-master
caffe2/python/operator_test/adagrad_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 import unittest class TestPad(serial.SerializedTestCase): @serial.given(pad_t=st.integers(-5, 0), ...
pytorch-master
caffe2/python/operator_test/pad_test.py
from caffe2.python import workspace, core, scope, gru_cell from caffe2.python.model_helper import ModelHelper from caffe2.python.rnn.rnn_cell_test_util import sigmoid, tanh, _prepare_rnn import caffe2.python.hypothesis_test_util as hu import caffe2.python.serialized_test.serialized_test_util as serial from caffe2....
pytorch-master
caffe2/python/operator_test/gru_test.py
import caffe2.python.hypothesis_test_util as hu import hypothesis import hypothesis.strategies as st import numpy as np from caffe2.python import core from hypothesis import HealthCheck, given, settings class TestSparseNormalize(hu.HypothesisTestCase): @staticmethod def ref_normalize(param_in, use_max_norm, n...
pytorch-master
caffe2/python/operator_test/sparse_normalize_test.py
import hypothesis.strategies as st import numpy as np 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 class TestArgOps(serial.SerializedTestCase): @given( X=hu.te...
pytorch-master
caffe2/python/operator_test/arg_ops_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 TestLearningRateAdaption(serial.SerializedTestCase): @given(in...
pytorch-master
caffe2/python/operator_test/learning_rate_adaption_op_test.py
import numpy as np 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 hypothesis.extra.numpy as hnp # Basic implementation of ...
pytorch-master
caffe2/python/operator_test/gather_ops_test.py
import collections import functools import unittest import caffe2.python._import_c_extension as C import caffe2.python.hip_test_util as hiputl 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...
pytorch-master
caffe2/python/operator_test/conv_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 def mux(select, left, right): return [np.vectorize(la...
pytorch-master
caffe2/python/operator_test/elementwise_logical_ops_test.py
import unittest import caffe2.python.hypothesis_test_util as hu import numpy as np from caffe2.python import core, workspace class TestQuantile(hu.HypothesisTestCase): def _test_quantile(self, inputs, quantile, abs, tol): net = core.Net("test_net") net.Proto().type = "dag" input_tensors...
pytorch-master
caffe2/python/operator_test/quantile_test.py
from functools import partial from hypothesis import given, settings import numpy as np import unittest import hypothesis.strategies as st from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.serialized_test.serialized_test_util as serial def sparse_leng...
pytorch-master
caffe2/python/operator_test/segment_ops_test.py
import unittest import hypothesis.strategies as st from hypothesis import given import numpy as np from caffe2.python import core import caffe2.python.hypothesis_test_util as hu @unittest.skipIf(not core.IsOperator("PackedFC"), "PackedFC is not supported in this caffe2 build.") class PackedFCTes...
pytorch-master
caffe2/python/operator_test/mkl_packed_fc_op_test.py
from caffe2.python import workspace, crf, brew from caffe2.python.model_helper import ModelHelper import numpy as np from scipy.special import logsumexp import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st from hypothesis import given, settings class TestCRFOp(hu.HypothesisTestCase):...
pytorch-master
caffe2/python/operator_test/crf_test.py
from functools import partial import caffe2.python.hypothesis_test_util as hu import numpy as np from caffe2.python import core def ref_adagrad( param_in, mom_in, grad, lr, epsilon, using_fp16=False, output_effective_lr=False, output_effective_lr_and_update=False, decay=1.0, r...
pytorch-master
caffe2/python/operator_test/adagrad_test_helper.py
import functools import hypothesis from hypothesis import given 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 class TestAdam(hu.HypothesisTestCase): @staticmethod def ref_adam(param, mom1,...
pytorch-master
caffe2/python/operator_test/adam_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/python/operator_test/weight_scale_test.py
from caffe2.python import ( core, gradient_checker, rnn_cell, workspace, scope, utils ) from caffe2.python.attention import AttentionType from caffe2.python.model_helper import ModelHelper, ExtractPredictorNet from caffe2.python.rnn.rnn_cell_test_util import sigmoid, tanh, _prepare_rnn from caffe2.proto import...
pytorch-master
caffe2/python/operator_test/rnn_cell_test.py
from caffe2.proto import caffe2_pb2 from caffe2.python import model_helper, workspace, core, rnn_cell, test_util from caffe2.python.attention import AttentionType import numpy as np import unittest import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st from hypothesis import given, se...
pytorch-master
caffe2/python/operator_test/recurrent_net_executor_test.py
import numpy as np import unittest from caffe2.proto import caffe2_pb2 from caffe2.python import workspace, core, model_helper, brew, test_util class CopyOpsTest(test_util.TestCase): def tearDown(self): # Reset workspace after each test # Otherwise, the multi-GPU test will use previously cr...
pytorch-master
caffe2/python/operator_test/copy_ops_test.py
pytorch-master
caffe2/python/operator_test/__init__.py
from caffe2.python import core, workspace from caffe2.python.dataset import Dataset from caffe2.python.schema import ( Struct, Map, Scalar, from_blob_list, NewRecord, FeedRecord) from caffe2.python.record_queue import RecordQueue from caffe2.python.test_util import TestCase import numpy as np class TestRecord...
pytorch-master
caffe2/python/operator_test/record_queue_test.py
from caffe2.python import core, workspace from caffe2.python.test_util import TestCase import numpy as np import tempfile class TestIndexOps(TestCase): def _test_index_ops(self, entries, dtype, index_create_op): workspace.RunOperatorOnce(core.CreateOperator( index_create_op, []...
pytorch-master
caffe2/python/operator_test/index_ops_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 TestElementwiseLinearOp(serial.SerializedTestCase): @serial.given(n=st.integers(2, 100), d=st.integer...
pytorch-master
caffe2/python/operator_test/elementwise_linear_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 import unittest class TestMean(serial.SerializedTestCase): @serial.given( k=st.integers(1, 5), ...
pytorch-master
caffe2/python/operator_test/mean_op_test.py
import unittest from caffe2.proto import caffe2_pb2 from caffe2.python import core import caffe2.python.hip_test_util as hiputl import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st import numpy as np from hypothesis import given, assume, settings class TestSpecializedSegmentOps(hu.Hyp...
pytorch-master
caffe2/python/operator_test/specialized_segment_ops_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 TestTransposeOp(serial.SerializedTestCa...
pytorch-master
caffe2/python/operator_test/transpose_op_test.py
import numpy as np from hypothesis import given import hypothesis.strategies as st from caffe2.python import core from caffe2.python import workspace import caffe2.python.hypothesis_test_util as hu class TestWeightedMultiSample(hu.HypothesisTestCase): @given( num_samples=st.integers(min_value=0, ma...
pytorch-master
caffe2/python/operator_test/weighted_multi_sample_test.py
import unittest 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 class TestSelfBinningHistogramBase(object): def __init__(self, bin_spacing, dtype, abs=False): self.bin_sp...
pytorch-master
caffe2/python/operator_test/self_binning_histogram_test.py
from caffe2.python import core from hypothesis import given import caffe2.python.hypothesis_test_util as hu import hypothesis.extra.numpy as hnp import hypothesis.strategies as st import numpy as np @st.composite def id_list_batch(draw): batch_size = draw(st.integers(2, 2)) values_dtype = np.float32 ...
pytorch-master
caffe2/python/operator_test/dense_vector_to_id_list_op_test.py
from caffe2.python import core from hypothesis import given import hypothesis.strategies as st import caffe2.python.hypothesis_test_util as hu import numpy as np import unittest class TestGivenTensorFillOps(hu.HypothesisTestCase): @given(X=hu.tensor(min_dim=1, max_dim=4, dtype=np.int32), t=st.sam...
pytorch-master
caffe2/python/operator_test/given_tensor_fill_op_test.py
from caffe2.python import core, workspace, test_util import os import shutil import tempfile import unittest class CheckpointTest(test_util.TestCase): """A simple test case to make sure that the checkpoint behavior is correct. """ @unittest.skipIf("LevelDB" not in core.C.registered_dbs(), "Need Leve...
pytorch-master
caffe2/python/operator_test/checkpoint_test.py
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 from hypothesis import given import hypothesis.strategies as st class TestBatchBucketize(serial.SerializedTestCase): @serial.given(**hu.gcs_cp...
pytorch-master
caffe2/python/operator_test/batch_bucketize_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 TestBatchMomentsOp(serial.SerializedTestCase): def batch_moments...
pytorch-master
caffe2/python/operator_test/batch_moments_op_test.py
from caffe2.python import core from hypothesis import given, settings import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st import numpy as np class TestFcOperator(hu.HypothesisTestCase): @given(n=st.integers(1, 10), k=st.integers(1, 5), use_length=st.booleans(), **hu...
pytorch-master
caffe2/python/operator_test/sparse_to_dense_mask_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.mkl_test_util as mu @unittest.skipIf(not workspace.C.has_mkldnn, "Skipping a...
pytorch-master
caffe2/python/operator_test/mkl_conv_op_test.py
import numpy as np from hypothesis import assume, given, settings import hypothesis.strategies as st import os import unittest from caffe2.python import core, utils, workspace import caffe2.python.hip_test_util as hiputl import caffe2.python.hypothesis_test_util as hu class TestPooling(hu.HypothesisTestCase): ...
pytorch-master
caffe2/python/operator_test/pooling_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 TestPiecewiseLinearTransform(serial.SerializedTest...
pytorch-master
caffe2/python/operator_test/piecewise_linear_transform_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 unittest class TestUniqueUniformFillOp(hu.HypothesisTestCase): @given( r=st.integers(1000, 10000), avoid=st.lists...
pytorch-master
caffe2/python/operator_test/unique_uniform_fill_op_test.py
#!/usr/bin/env python3 import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st import numpy as np import numpy.testing as npt from caffe2.python import core, workspace from hypothesis import given class TestUnsafeCoalesceOp(hu.HypothesisTestCase): @given( n=st.integers(1, 5), ...
pytorch-master
caffe2/python/operator_test/unsafe_coalesce_test.py
from caffe2.python import core from hypothesis import given import caffe2.python.hypothesis_test_util as hu import numpy as np import unittest class TestGivenTensorByteStringToUInt8FillOps(hu.HypothesisTestCase): @given(X=hu.tensor(min_dim=1, max_dim=4, dtype=np.int32), **hu.gcs) def test_giv...
pytorch-master
caffe2/python/operator_test/given_tensor_byte_string_to_uint8_fill_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 collections import OrderedDict from hypothesis import given, settings import numpy as np class TestFlexibleTopK(serial.SerializedTestCase): def flexible_top...
pytorch-master
caffe2/python/operator_test/flexible_top_k_test.py
import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st from caffe2.python import core, utils from hypothesis import given, settings class OrderSwitchOpsTest(hu.HypothesisTestCase): @given( X=hu.tensor(min_dim=3, max_dim=5, min_value=1, max_value=5), engine=st.sampled_...
pytorch-master
caffe2/python/operator_test/order_switch_test.py
import argparse import numpy as np from caffe2.python import core, workspace def benchmark_mul_gradient(args): workspace.FeedBlob("dC", np.random.rand(args.m, args.n).astype(np.float32)) workspace.FeedBlob("A", np.random.rand(args.m, args.n).astype(np.float32)) workspace.FeedBlob("B", np.random.rand...
pytorch-master
caffe2/python/operator_test/mul_gradient_benchmark.py
from hypothesis import given import hypothesis.strategies as st import numpy as np import unittest from caffe2.python import core, workspace, dyndep import caffe2.python.hypothesis_test_util as hu dyndep.InitOpsLibrary("@/caffe2/caffe2/mpi:mpi_ops") _has_mpi =False COMM = None RANK = 0 SIZE = 0 def SetupMPI()...
pytorch-master
caffe2/python/operator_test/mpi_test.py
from caffe2.python import core from caffe2.python.test_util import rand_array 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 TestScatterOps(serial...
pytorch-master
caffe2/python/operator_test/sparse_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 class TestWeightedSumOp(serial.SerializedTestCase): @given( ...
pytorch-master
caffe2/python/operator_test/weighted_sum_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 from caffe2.proto import caffe2_pb2 from hypothesis import assume, given, settings class TestResize(hu.HypothesisTestCase): @given(height_scale=st.floats(0.25, 4...
pytorch-master
caffe2/python/operator_test/resize_op_test.py
from caffe2.python import workspace, 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 TestNegateGradient(serial.SerializedTestCase): @giv...
pytorch-master
caffe2/python/operator_test/negate_gradient_op_test.py
from caffe2.python import core from hypothesis import given import caffe2.python.hypothesis_test_util as hu import numpy as np class SparseItemwiseDropoutWithReplacementTest(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, ...
pytorch-master
caffe2/python/operator_test/sparse_itemwise_dropout_with_replacement_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 def entropy(p): q = 1. - p return -p * np.log(p) - q * np.log(q) def jsd(p, q): return [entropy(p ...
pytorch-master
caffe2/python/operator_test/jsd_ops_test.py
import caffe2.python.hypothesis_test_util as hu import caffe2.python.serialized_test.serialized_test_util as serial import numpy as np from caffe2.python import core, workspace from hypothesis import given, settings, strategies as st def batched_boarders_and_data( data_min_size=5, data_max_size=10, exam...
pytorch-master
caffe2/python/operator_test/gather_ranges_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 _tensor_splits(draw, add_axis=False): ...
pytorch-master
caffe2/python/operator_test/concat_split_op_test.py
import numpy as np from hypothesis import given import hypothesis.strategies as st from caffe2.python import core from caffe2.python import workspace import caffe2.python.hypothesis_test_util as hu class TestWeightedSample(hu.HypothesisTestCase): @given( batch=st.integers(min_value=0, max_value=128...
pytorch-master
caffe2/python/operator_test/weighted_sample_test.py
from caffe2.proto import caffe2_pb2 from caffe2.python import core, workspace 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 def _fill_diagonal(shape,...
pytorch-master
caffe2/python/operator_test/filler_ops_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, utils from hypothesis import given class TestAliasWithNameOp(hu.HypothesisTestCase): @given( shape=st.lists(st.integers(0, 5), min_size=1, max_size=...
pytorch-master
caffe2/python/operator_test/alias_with_name_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 TestFindOperator(serial.SerializedTestCase): @given(n=st.samp...
pytorch-master
caffe2/python/operator_test/find_op_test.py
import numpy as np # Note we explicitly cast variables to np.float32 in a couple of places to avoid # the default casting in Python often resuling in double precision and to make # sure we're doing the same numerics as C++ code. def param_search_greedy(x, bit_rate, n_bins=200, ratio=0.16): xmin, xmax = np.min(x...
pytorch-master
caffe2/python/operator_test/fused_nbit_rowwise_test_helper.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 DistanceTest(serial.SerializedTestCase): @serial.given(n=st.integers(1, 3), dim=st.integers...
pytorch-master
caffe2/python/operator_test/distance_op_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 # The reference implementation is susceptible to numerical cancellation ...
pytorch-master
caffe2/python/operator_test/batch_box_cox_test.py
import numpy as np from hypothesis import given, assume, settings import hypothesis.strategies as st from caffe2.python import core, workspace import caffe2.python.hypothesis_test_util as hu import caffe2.python.mkl_test_util as mu import caffe2.python.serialized_test.serialized_test_util as serial from scipy.s...
pytorch-master
caffe2/python/operator_test/activation_ops_test.py
from caffe2.python import core from functools import partial 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 from caffe2.python import wor...
pytorch-master
caffe2/python/operator_test/sequence_ops_test.py
from caffe2.python import core from functools import partial from hypothesis import strategies as st import caffe2.python.hypothesis_test_util as hu import caffe2.python.serialized_test.serialized_test_util as serial import math import numpy as np def _data_and_scale( data_min_size=4, data_max_size=10, ...
pytorch-master
caffe2/python/operator_test/square_root_divide_op_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 def _string_lists(alphabet=None): return st.lists( elements=s...
pytorch-master
caffe2/python/operator_test/string_ops_test.py
import numpy as np from hypothesis import given, settings import hypothesis.strategies as st import unittest from caffe2.python import core import caffe2.python.hypothesis_test_util as hu import caffe2.python.serialized_test.serialized_test_util as serial class TestNumpyTile(serial.SerializedTestCase): @gi...
pytorch-master
caffe2/python/operator_test/numpy_tile_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 import unittest def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) def sigmoid_cross_entropy_with_logits(x, z): return np.maximum(x, 0) - x * z +...
pytorch-master
caffe2/python/operator_test/cross_entropy_ops_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 TestUnmaskOp(serial.SerializedTestCase): @serial.given(N=st.integers(min_value=2, max_value=20), ...
pytorch-master
caffe2/python/operator_test/boolean_unmask_test.py
import numpy as np from caffe2.python import core, workspace from caffe2.python.test_util import TestCase from caffe2.proto import caffe2_pb2 class TestPrependDim(TestCase): def _test_fwd_bwd(self): old_shape = (128, 2, 4) new_shape = (8, 16, 2, 4) X = np.random.rand(*old_shape).astyp...
pytorch-master
caffe2/python/operator_test/prepend_dim_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/python/operator_test/upsample_op_test.py
import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st import numpy as np import numpy.testing as npt from caffe2.python import core, workspace from hypothesis import given class TestEnsureClipped(hu.HypothesisTestCase): @given( X=hu.arrays(dims=[5, 10], elements=hu.floats(mi...
pytorch-master
caffe2/python/operator_test/ensure_clipped_test.py
import numpy as np from caffe2.python import core, workspace from caffe2.python.test_util import TestCase class TestSplitOpCost(TestCase): def _verify_cost(self, workspace, split_op): flops, bytes_written, bytes_read = workspace.GetOperatorCost( split_op, split_op.input ) self....
pytorch-master
caffe2/python/operator_test/split_op_cost_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 class TestLengthSplitOperator(serial.SerializedTestCase): def _lengt...
pytorch-master
caffe2/python/operator_test/length_split_op_test.py
from caffe2.python import core from hypothesis import given, settings import hypothesis.strategies as st import caffe2.python.hypothesis_test_util as hu import caffe2.python.serialized_test.serialized_test_util as serial import numpy as np import unittest class TestThresholdedRelu(serial.SerializedTestCase): ...
pytorch-master
caffe2/python/operator_test/thresholded_relu_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 class TestLars(hu.HypothesisTestCase): @given(offset=st.floats(min_value=0, max_value=100), lr_min=st.floats(min_value=1e-8, max_value=1e-6), ...
pytorch-master
caffe2/python/operator_test/lars_test.py
import math 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 numpy as np import unittest class TestErfOp(serial.SerializedTestCase): @given( X=hu.tensor(el...
pytorch-master
caffe2/python/operator_test/erf_op_test.py
from collections import namedtuple import numpy as np from caffe2.python import core, workspace from caffe2.python.test_util import TestCase class TestConcatOpCost(TestCase): def test_columnwise_concat(self): def _test_columnwise_concat_for_type(dtype): workspace.ResetWorkspace() ...
pytorch-master
caffe2/python/operator_test/concat_op_cost_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 TestChannelBackpropStats(serial.SerializedTestCase)...
pytorch-master
caffe2/python/operator_test/channel_backprop_stats_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.hypothesis_test_util as hu import caffe2.python.hip_test_util as hiputl class TestConvolutionTranspose(hu.HypothesisT...
pytorch-master
caffe2/python/operator_test/conv_transpose_test.py
import functools 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 import caffe2.python.serialized_test.serialized_test_util as serial class TestAdadelta(seri...
pytorch-master
caffe2/python/operator_test/adadelta_test.py
import numpy as np from numpy.testing import assert_array_equal from caffe2.python import core, workspace from caffe2.python.test_util import TestCase from caffe2.proto import caffe2_pb2 class TestLengthsToShapeOps(TestCase): def test_lengths_to_shape_ops(self): workspace.FeedBlob('l', np.array([200,...
pytorch-master
caffe2/python/operator_test/reshape_ops_test.py
import os import shutil import sys import tempfile import unittest import numpy as np from caffe2.proto import caffe2_pb2 from caffe2.python import model_helper, workspace try: import lmdb except ImportError: raise unittest.SkipTest("python-lmdb is not installed") class VideoInputOpTest(unittest.TestCase...
pytorch-master
caffe2/python/operator_test/video_input_op_test.py
import numpy from caffe2.python import core from hypothesis import given, settings import caffe2.python.hypothesis_test_util as hu import hypothesis.strategies as st import numpy as np @st.composite def _data(draw): return draw( hu.tensor( dtype=np.int64, elements=st.integers( ...
pytorch-master
caffe2/python/operator_test/mod_op_test.py
from caffe2.python import core, workspace from caffe2.python.test_util import TestCase import numpy as np class TestPutOps(TestCase): def test_default_value(self): magnitude_expand = int(1e12) stat_name = "stat".encode('ascii') sum_postfix = "/stat_value/sum".encode("ascii") c...
pytorch-master
caffe2/python/operator_test/stats_put_ops_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 assume, given, settings import hypothesis.strategies as st import numpy as np class TestBooleanMaskOp(serial.SerializedTestCase): @given(x=h...
pytorch-master
caffe2/python/operator_test/boolean_mask_test.py