Rewrite function tests using `testing.FunctionTestCase`
See original GitHub issueWe have introduced testing.FunctionTestCase
(#3499).
This tool enables writing a function test for various backends (including ChainerX) in much simpler way.
This tool also provides an option to automatically dodge non-differentiable inputs.
We should apply this to all the existing function tests, and assure ChainerX support in those functions.
~(Note: we should merge #6069 first to skip float16 in ChainerX backends.)~
To get started
Please declare your will to work on a function, by posting a comment in this issue. If you’re a collaborator, just write your name next to the function name.
Typical problems and workarounds for ChainerX support
NumPy-compatible functions are not yet implemented
Write tentative implementation that falls back to numpy/cupy, in chainerx/_fallback_workarounds.py
. For module-level functions (e.g. chainerx.hstack
), write in _populate_module_functions
. For ndarray
methods, write in _populate_ndarray
. Note that functions written in this way cannot support backprop in their own, but it’s sufficient for computations in FunctionNode.forward
, for example.
Array type mismatch
In FunctionNode
fallback (in which chainerx arrays are automatically converted to numpy/cupy and the corresponding FunctionNode.forward
method is called), array attributes are also automatically converted between numpy/cupy and chainerx arrays. This is not the case if the array attribute is wrapped in a tuple, dict, etc. In this case, the attribute must be converted manually, using backend.to_chainerx
and backend.from_chainerx
.
76 done of 165 tests, 46% complete!
- functions_tests/pooling_tests/test_roi_max_align_2d.py
- functions_tests/pooling_tests/test_pooling_nd_kernel.py
- functions_tests/pooling_tests/test_max_pooling_2d.py
- functions_tests/pooling_tests/test_unpooling_2d.py #6861
- functions_tests/pooling_tests/test_average_pooling_2d.py #6211
- functions_tests/pooling_tests/test_roi_average_align_2d.py
- functions_tests/pooling_tests/test_spatial_pyramid_pooling_2d.py
- functions_tests/pooling_tests/test_roi_pooling_2d.py
- functions_tests/pooling_tests/test_roi_max_pooling_2d.py
- functions_tests/pooling_tests/test_unpooling_nd.py #6861
- functions_tests/pooling_tests/test_roi_average_pooling_2d.py
- functions_tests/pooling_tests/test_max_pooling_nd.py #3499
- functions_tests/pooling_tests/test_upsampling_2d.py
- functions_tests/pooling_tests/test_average_pooling_nd.py #6332
- functions_tests/normalization_tests/test_batch_renormalization.py #5817
- functions_tests/normalization_tests/test_local_response_normalization.py
- functions_tests/normalization_tests/test_batch_normalization.py
- functions_tests/normalization_tests/test_layer_normalization.py #6871
- functions_tests/normalization_tests/test_group_normalization.py
- functions_tests/normalization_tests/test_l2_normalization.py
- functions_tests/evaluation_tests/test_accuracy.py #7007
- functions_tests/evaluation_tests/test_r2_score.py #7008
- functions_tests/evaluation_tests/test_binary_accuracy.py
- functions_tests/evaluation_tests/test_classification_summary.py
- functions_tests/loss_tests/test_mean_squared_error.py #5822
- functions_tests/loss_tests/test_hinge.py
- functions_tests/loss_tests/test_absolute_error.py #7281
- functions_tests/loss_tests/test_huber_loss.py
- functions_tests/loss_tests/test_negative_sampling.py
- functions_tests/loss_tests/test_contrastive.py
- functions_tests/loss_tests/test_triplet.py #5819
- functions_tests/loss_tests/test_decov.py
- functions_tests/loss_tests/test_mean_absolute_error.py #6253
- functions_tests/loss_tests/test_discriminative_margin_based_clustering_loss.py
- functions_tests/loss_tests/test_crf1d.py
- functions_tests/loss_tests/test_sigmoid_cross_entropy.py
- functions_tests/loss_tests/test_vae.py
- functions_tests/loss_tests/test_softmax_cross_entropy.py #6363
- functions_tests/loss_tests/test_cross_covariance.py
- functions_tests/loss_tests/test_black_out.py
- functions_tests/loss_tests/test_ctc.py
- functions_tests/loss_tests/test_squared_error.py
- functions_tests/activation_tests/test_hard_sigmoid.py #6192
- functions_tests/activation_tests/test_log_softmax.py #6320
- functions_tests/activation_tests/test_softplus.py #6298
- functions_tests/activation_tests/test_selu.py #6243
- functions_tests/activation_tests/test_rrelu.py
- functions_tests/activation_tests/test_prelu.py #6887
- functions_tests/activation_tests/test_maxout.py #6302
- functions_tests/activation_tests/test_relu.py #3499
- functions_tests/activation_tests/test_leaky_relu.py #6301
- functions_tests/activation_tests/test_elu.py #6070
- functions_tests/activation_tests/test_slstm.py
- functions_tests/activation_tests/test_sigmoid.py
- functions_tests/activation_tests/test_lstm.py
- functions_tests/activation_tests/test_softmax.py #6371
- functions_tests/activation_tests/test_swish.py
- functions_tests/activation_tests/test_clipped_relu.py #3499
- functions_tests/activation_tests/test_tanh.py #6173
- functions_tests/activation_tests/test_crelu.py #6070
- functions_tests/noise_tests/test_simplified_dropconnect.py
- functions_tests/noise_tests/test_zoneout.py
- functions_tests/noise_tests/test_dropout.py @niboshi
- functions_tests/noise_tests/test_gaussian.py
- functions_tests/noise_tests/test_gumbel_softmax.py
- functions_tests/math_tests/test_sign.py #6898
- functions_tests/math_tests/test_scale.py #6969
- functions_tests/math_tests/test_ceil.py #6900
- functions_tests/math_tests/test_det.py
- functions_tests/math_tests/test_polygamma.py #6970
- functions_tests/math_tests/test_logsumexp.py #7018
- functions_tests/math_tests/test_erf.py
- functions_tests/math_tests/test_log_ndtr.py
- functions_tests/math_tests/test_floor.py #6901
- functions_tests/math_tests/test_exponential_m1.py #6965
- functions_tests/math_tests/test_tensordot.py #6968
- functions_tests/math_tests/test_ndtri.py
- functions_tests/math_tests/test_prod.py #6479
- functions_tests/math_tests/test_fmod.py #6937
- functions_tests/math_tests/test_erfcinv.py
- functions_tests/math_tests/test_ndtr.py
- functions_tests/math_tests/test_erfcx.py
- functions_tests/math_tests/test_exponential.py #6963
- functions_tests/math_tests/test_linear_interpolate.py #6984
- functions_tests/math_tests/test_logarithm_1p.py #6981
- functions_tests/math_tests/test_maximum.py #6400
- functions_tests/math_tests/test_einsum.py
- functions_tests/math_tests/test_cumsum.py #6977
- functions_tests/math_tests/test_minmax.py #6962
- functions_tests/math_tests/test_lgamma.py
- functions_tests/math_tests/test_trigonometric.py
- functions_tests/math_tests/test_average.py #6995
- functions_tests/math_tests/test_cumprod.py #6978
- functions_tests/math_tests/test_sqrt.py
- functions_tests/math_tests/test_matmul.py #6987
- functions_tests/math_tests/test_erfc.py
- functions_tests/math_tests/test_batch_l2_norm_squared.py #6996
- functions_tests/math_tests/test_minimum.py #6396
- functions_tests/math_tests/test_hyperbolic.py #6980
- functions_tests/math_tests/test_fft.py #6985
- functions_tests/math_tests/test_squared_difference.py #6395
- functions_tests/math_tests/test_erfinv.py
- functions_tests/math_tests/test_digamma.py
- functions_tests/math_tests/test_clip.py
- functions_tests/math_tests/test_square.py
- functions_tests/math_tests/test_inv.py #6994
- functions_tests/math_tests/test_sparse_matmul.py
- functions_tests/math_tests/test_sum.py #6307
- functions_tests/math_tests/test_bias.py #6976
- functions_tests/math_tests/test_basic_math.py
- functions_tests/math_tests/test_fix.py #6938
- functions_tests/array_tests/test_broadcast.py
- functions_tests/array_tests/test_vstack.py #6410
- functions_tests/array_tests/test_repeat.py #6803
- functions_tests/array_tests/test_swapaxes.py #6460
- functions_tests/array_tests/test_expand_dims.py #6473
- functions_tests/array_tests/test_separate.py #7013
- functions_tests/array_tests/test_reshape.py #6868
- functions_tests/array_tests/test_where.py #6802
- functions_tests/array_tests/test_flipud.py #6390
- functions_tests/array_tests/test_spatial_transformer_grid.py
- functions_tests/array_tests/test_diagonal.py #6322
- functions_tests/array_tests/test_resize_images.py #6464
- functions_tests/array_tests/test_pad_sequence.py
- functions_tests/array_tests/test_rollaxis.py #6408
- functions_tests/array_tests/test_split_axis.py #3499
- functions_tests/array_tests/test_permutate.py #7010
- functions_tests/array_tests/test_transpose_sequence.py
- functions_tests/array_tests/test_transpose.py #6458
- functions_tests/array_tests/test_pad.py #6393
- functions_tests/array_tests/test_select_item.py
- functions_tests/array_tests/test_flatten.py #6888
- functions_tests/array_tests/test_squeeze.py #6487
- functions_tests/array_tests/test_hstack.py #3499
- functions_tests/array_tests/test_depth_2_space.py
- functions_tests/array_tests/test_space_2_depth.py
- functions_tests/array_tests/test_moveaxis.py #6392
- functions_tests/array_tests/test_scatter_add.py #7012
- functions_tests/array_tests/test_tile.py #6459
- functions_tests/array_tests/test_fliplr.py #6389
- functions_tests/array_tests/test_im2col.py
- functions_tests/array_tests/test_concat.py #5823
- functions_tests/array_tests/test_copy.py @niboshi
- functions_tests/array_tests/test_cast.py #7034
- functions_tests/array_tests/test_stack.py
- functions_tests/array_tests/test_spatial_transformer_sampler.py
- functions_tests/array_tests/test_flip.py #6801
- functions_tests/array_tests/test_dstack.py #6891
- functions_tests/array_tests/test_get_item.py #6990
- functions_tests/connection_tests/test_linear.py #6236
- functions_tests/connection_tests/test_deformable_convolution_2d_sampler.py
- functions_tests/connection_tests/test_embed_id.py
- functions_tests/connection_tests/test_convolution_nd.py #6406
- functions_tests/connection_tests/test_dilated_convolution_2d.py
- functions_tests/connection_tests/test_n_step_gru.py
- functions_tests/connection_tests/test_depthwise_convolution_2d.py
- functions_tests/connection_tests/test_n_step_rnn.py
- functions_tests/connection_tests/test_shift.py
- functions_tests/connection_tests/test_convolution_2d.py #6406
- functions_tests/connection_tests/test_deconvolution_2d.py #6498
- functions_tests/connection_tests/test_bilinear.py #6488
- functions_tests/connection_tests/test_n_step_lstm.py
- functions_tests/connection_tests/test_local_convolution_2d.py
- functions_tests/connection_tests/test_deconvolution_nd.py #6500
- functions_tests/util_tests/test_forget.py
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (13 by maintainers)
Top GitHub Comments
If this issue still needs work, I would love to take it up
I would like to work on squared error and sqrt tests. Could anyone give me a headstart, I am relatively new in chainer contribution community. Thanks!