pytorch/caffe2/python/operator_test
Ansha Yu 98aebed88e Refactor tests part 1 (#11350)
Summary:
Followup to [the serialized test framework](https://github.com/pytorch/pytorch/pull/10594)

Round 1 for refactoring tests, starting alphabetically. I added some functionality, so I wanted to send out some of these initial changes sooner.

I'm skipping all tests that don't explicitly call assertReferenceChecks. Some tests directly call np.allclose, and others are simply TestCase (rather than HypothesisTestCase).

1. Start alphabetically producing serialized outputs for test functions, annotating those we want to include with `serialized_test_util.given`. So far I've only added one test per operator, but this already does seem to add quite a few tests.
2. Add functionality to allow us to generate outputs using pytest by adding pytest argument options. This allows us to skip adding a `__main__` function to quite a few tests.
3. Catch any exceptions generating the gradient operator and skip serializing/reading it, since certain operators don't have gradients.
4. Add functionality to better handle jagged array inputs, which numpy doesn't handle very well. We simply explicitly do the conversion to dtype=object.
5. Make only one file per test function, rather than 4, to reduce the number of files in the github repo.

I also noticed that there is some hypothesis handling that makes `serialized_test_util.given` not compatible with adding more hypothesis decorators on top. For example, there are tests that do
```
settings(...)
given(...)
def test_my_stuff(...)
```
But there is a hypothesis handler that explicitly checks that `given` is called below `settings`, so we cannot refactor this to `serialized_test_util.given`. I've just avoided decorating these kinds of tests for now, I hope that's alright.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11350

Reviewed By: houseroad

Differential Revision: D9693857

Pulled By: ajyu

fbshipit-source-id: a9b4279afbe51c90cf2025c5ac6b2db2111f4af7
2018-09-18 10:42:10 -07:00
..
__init__.py framework for committed serialized tests (#10594) 2018-08-30 22:41:46 -07:00
activation_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
adadelta_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
adagrad_test_helper.py Update from facebook 1ee4edd286a3 (#8040) 2018-06-01 17:41:09 -04:00
adagrad_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
adam_test.py Support lr adaption for SparseAdam and RowWiseSparseAdam (#11162) 2018-09-17 10:29:03 -07:00
affine_channel_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
apmeter_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
arg_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
assert_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
atomic_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
basic_rnn_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
batch_box_cox_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
batch_bucketize_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
batch_moments_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
batch_sparse_to_dense_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
bbox_transform_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
bisect_percentile_op_test.py Add a bisect percentile operator (#10563) 2018-08-20 13:14:05 -07:00
blobs_queue_db_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
boolean_mask_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
boolean_unmask_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
box_with_nms_limit_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
cast_op_test.py cast op for empty batch 2017-11-16 12:20:20 -08:00
ceil_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
channel_backprop_stats_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
channel_shuffle_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
channel_stats_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
checkpoint_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
clip_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
clip_tensor_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
collect_and_distribute_fpn_rpn_proposals_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
concat_split_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
conditional_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
conftest.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
conv_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
conv_transpose_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
copy_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
cosine_embedding_criterion_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
counter_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
crf_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
cross_entropy_ops_test.py [Caffe2][fbcode=>GH sync] Update from facebook 4323b18ce13c (#7116) 2018-05-01 20:49:00 -07:00
ctc_beam_search_decoder_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
ctc_greedy_decoder_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
cudnn_recurrent_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
dataset_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
deform_conv_test.py Port all PyTorch and Caffe2 jobs to CircleCI (#11264) 2018-09-05 16:28:11 -07:00
depthwise_3x3_conv_test.py [caffe2] Open-source DEPTHWISE_3x3 engine (#6601) 2018-04-26 02:30:51 -04:00
detectron_keypoints.py move HeatmapMaxKeypointOp unittest to oss 2018-08-27 12:56:46 -07:00
distance_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
dropout_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
duplicate_operands_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
elementwise_linear_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
elementwise_logical_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
elementwise_op_broadcast_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
elementwise_ops_test.py Port all PyTorch and Caffe2 jobs to CircleCI (#11264) 2018-09-05 16:28:11 -07:00
emptysample_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
enforce_finite_op_test.py EnforceFinite test (#10143) 2018-08-03 10:31:29 -07:00
ensure_clipped_test.py Update from Facebook (#8887) 2018-06-26 14:55:48 -07:00
ensure_cpu_output_op_test.py Update from facebook (#7451) 2018-05-10 23:14:27 -07:00
expand_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
extend_tensor_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
fc_operator_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
feature_maps_ops_test.py [Caffe2][fbcode=>GH sync] Update from facebook 4323b18ce13c (#7116) 2018-05-01 20:49:00 -07:00
filler_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
find_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
flatten_op_test.py Enable Flatten operator to take an arbitrary axis arguemnt 2017-10-13 12:28:22 -07:00
flexible_top_k_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
floor_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
gather_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
gather_ranges_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
given_tensor_byte_string_to_uint8_fill_op_test.py Export uint8 tensors as byte string in mobile_exporter and add GivenTensorByteStringToUInt8FillOp (#10385) 2018-08-15 14:26:50 -07:00
given_tensor_fill_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
glu_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
group_conv_test.py Port all PyTorch and Caffe2 jobs to CircleCI (#11264) 2018-09-05 16:28:11 -07:00
group_norm_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
gru_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
heatmap_max_keypoint_op_test.py move HeatmapMaxKeypointOp unittest to oss 2018-08-27 12:56:46 -07:00
hsm_test.py [Caffe2] Fix gradient_check on in-place ops (#8828) 2018-06-25 15:25:56 -07:00
hyperbolic_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
im2col_col2im_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
image_input_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
index_hash_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
index_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
instance_norm_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
integral_image_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
jsd_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
key_split_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
lars_test.py Improve lars operator by applying clipping (#9905) 2018-08-02 11:54:28 -07:00
layer_norm_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
leaky_relu_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
learning_rate_adaption_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
learning_rate_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
length_split_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
lengths_pad_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
lengths_tile_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
lengths_top_k_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
listwise_l2r_operator_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
load_save_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
locally_connected_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
loss_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
lpnorm_op_test.py Update from Facebook (#8887) 2018-06-26 14:55:48 -07:00
map_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
margin_ranking_criterion_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
math_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
matmul_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
mean_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
merge_id_lists_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
mkl_conv_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
mkl_packed_fc_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
mkl_speed_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
mod_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
moments_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
momentum_sgd_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
mpi_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
negate_gradient_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
ngram_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
normalize_op_test.py Fix l2 normalization when handling zero vector (#9594) 2018-07-19 14:10:03 -07:00
numpy_tile_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
one_hot_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
onnx_while_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
order_switch_test.py Optimize order_swich_ops on GPU (#11404) 2018-09-12 16:56:15 -07:00
pack_ops_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
pack_rnn_sequence_op_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
pad_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
partition_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
percentile_op_test.py Update from facebook (#7855) 2018-05-29 11:38:02 -07:00
piecewise_linear_transform_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
pooling_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
prepend_dim_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
python_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
rand_quantization_op_speed_test.py Intergrating stochastic quantization to easgd to reduce communication + supporting quantization on both sides (split from D8849770) (#10644) 2018-08-22 17:10:03 -07:00
rand_quantization_op_test.py Port all PyTorch and Caffe2 jobs to CircleCI (#11264) 2018-09-05 16:28:11 -07:00
rank_loss_operator_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
rebatching_queue_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
record_queue_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
recurrent_net_executor_test.py Potential fix for RNN test on MKL (#7862) 2018-05-25 16:16:46 -07:00
recurrent_network_test.py Port all PyTorch and Caffe2 jobs to CircleCI (#11264) 2018-09-05 16:28:11 -07:00
reduce_ops_test.py Add support for .norm() pytorch onnx export and ReduceL1/ReduceL2 caffe2 operators (#9299) 2018-07-14 10:54:13 -07:00
reduction_ops_test.py Add SumElementsInt operator 2018-03-27 18:10:39 -07:00
reshape_ops_test.py Fix dividing by zero segfault in Reshape (#8302) 2018-06-09 09:48:22 -07:00
resize_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
rmac_regions_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
rnn_cell_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
roi_align_rotated_op_test.py Make roi_align_rotated_op_test not rely on 1.12.0 numpy.rot90 (#9267) 2018-07-09 11:55:39 -07:00
segment_ops_test.py Update from facebook (#7696) 2018-05-19 23:10:48 -07:00
selu_op_test.py selu op 2017-12-15 15:38:44 -08:00
sequence_ops_test.py Port all PyTorch and Caffe2 jobs to CircleCI (#11264) 2018-09-05 16:28:11 -07:00
shape_inference_test.py Add interface to provide blob types to shape&type inference (#9643) 2018-07-24 11:58:05 -07:00
sinusoid_position_encoding_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
softmax_ops_test.py fix expty batch for softmax (#9075) 2018-07-01 16:40:14 -07:00
softplus_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
sparse_gradient_checker_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
sparse_lengths_sum_benchmark.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
sparse_normalize_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
sparse_ops_test.py Eanble python tests on ROCM (#9616) 2018-07-24 11:37:58 -07:00
sparse_to_dense_mask_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
spatial_bn_op_test.py Add cuda version of SpatialBNOp also optimize SpatialBN on CPU (#10888) 2018-09-06 18:26:13 -07:00
specialized_segment_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
square_root_divide_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
stats_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
string_ops_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
text_file_reader_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
thresholded_relu_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
tile_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
top_k_test.py Update from facebook (#6871) 2018-04-23 15:01:56 -07:00
transpose_op_test.py [caffe2] Update math functions with params on host. (#6602) 2018-04-14 21:41:41 -07:00
trigonometric_op_test.py Fix trigonometric_op_test failures when running in python3.6 (#7831) 2018-05-24 19:09:35 -07:00
unique_ops_test.py [Caffe2] Changes done inside Facebook (#6378) 2018-04-10 21:11:43 -07:00
unique_uniform_fill_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
upsample_op_test.py bilinear upsample operator on CPU 2018-06-27 10:12:06 -07:00
utility_ops_test.py Update from facebook (#7855) 2018-05-29 11:38:02 -07:00
video_input_op_test.py Remove Apache headers from source. 2018-03-27 13:10:18 -07:00
weighted_multi_sample_test.py Only run WeightedMultiSample test on CPU and not GPU. 2018-03-20 13:34:22 -07:00
weighted_sample_test.py support non-normalized weights 2017-10-27 23:18:25 -07:00
weighted_sum_test.py Refactor tests part 1 (#11350) 2018-09-18 10:42:10 -07:00
wngrad_test.py Implementation and operator test for Wngrad optimizer (#8999) 2018-07-13 18:11:41 -07:00