From 724eba0b78ecda4cb2ccd841b569bc0084f42638 Mon Sep 17 00:00:00 2001 From: Josh Fromm Date: Sun, 5 Jul 2020 09:41:05 -0700 Subject: [PATCH 1/3] Fix autopad bug in onnx importer for conv1d. --- python/tvm/relay/op/nn/nn.py | 3 +-- tests/python/frontend/onnx/test_forward.py | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/python/tvm/relay/op/nn/nn.py b/python/tvm/relay/op/nn/nn.py index e5009d34d66f..6ede0beec861 100644 --- a/python/tvm/relay/op/nn/nn.py +++ b/python/tvm/relay/op/nn/nn.py @@ -108,8 +108,7 @@ def conv1d(data, strides = (strides, ) if isinstance(dilation, int): dilation = (dilation, ) - if isinstance(padding, int): - padding = (padding, padding) + padding = get_pad_tuple1d(padding) return _make.conv1d(data, weight, strides, padding, dilation, groups, channels, kernel_size, data_layout, kernel_layout, out_layout, out_dtype) diff --git a/tests/python/frontend/onnx/test_forward.py b/tests/python/frontend/onnx/test_forward.py index d9c481a20805..5559a8a2e4a7 100644 --- a/tests/python/frontend/onnx/test_forward.py +++ b/tests/python/frontend/onnx/test_forward.py @@ -2180,6 +2180,15 @@ def repeat(N, D): repeat(1, D), repeat(1, D), auto_pad="SAME_UPPER") + # Convolution with valid autopadding + verify_conv((1, 1) + repeat(5, D), + (1, 1) + repeat(3, D), + (1, 1) + repeat(5, D), + None, + repeat(3, D), + repeat(1, D), + repeat(1, D), + auto_pad="VALID") # Convolution with unset padding verify_conv((1, 1) + repeat(5, D), (1, 1) + repeat(3, D), From 318903174cf85329270593fbf0120cd6270b6d18 Mon Sep 17 00:00:00 2001 From: Josh Fromm Date: Sun, 5 Jul 2020 13:49:36 -0700 Subject: [PATCH 2/3] Fix output shape in test. --- tests/python/frontend/onnx/test_forward.py | 142 ++++++++++----------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/tests/python/frontend/onnx/test_forward.py b/tests/python/frontend/onnx/test_forward.py index 5559a8a2e4a7..87e97b9a18fd 100644 --- a/tests/python/frontend/onnx/test_forward.py +++ b/tests/python/frontend/onnx/test_forward.py @@ -2183,7 +2183,7 @@ def repeat(N, D): # Convolution with valid autopadding verify_conv((1, 1) + repeat(5, D), (1, 1) + repeat(3, D), - (1, 1) + repeat(5, D), + (1, 1) + repeat(3, D), None, repeat(3, D), repeat(1, D), @@ -2928,74 +2928,74 @@ def verify_roi_align(input_dims, num_roi, output_height, output_width, sampling_ if __name__ == '__main__': - test_flatten() - test_reshape() - test_shape() - test_expand() - test_power() - test_squeeze() - test_unsqueeze() - test_slice() - test_floor() - test_ceil() - test_round() - test_isinf() - test_isnan() - test_clip() - test_onehot() - test_matmul() - test_batch_matmul() - test_gather() - test_gather_nd() - test_scatter() - test_lrn() - test_instance_norm() - test_upsample() - test_forward_min() - test_forward_max() - test_forward_mean() - test_forward_hardsigmoid() - test_forward_arg_min_max() - test_softmax() - test_constantofshape() - test_all_reduce_funcs() - test_pad() - test_split() - test_binary_ops() - test_single_ops() - test_leaky_relu() - test_elu() - test_selu() - test_prelu() - test_ThresholdedRelu() - test_ScaledTanh() - test_ParametricSoftplus() - test_Scale() - test_LogSoftmax() - test_resnet() - test_inception() - test_densenet() - test_sign() - test_not() - test_and() - test_tile() - test_erf() - test_where() - test_or() - test_depth_to_space() - test_space_to_depth() - test_batch_norm() - test_batch_norm_dynamic_subgraph() + #test_flatten() + #test_reshape() + #test_shape() + #test_expand() + #test_power() + #test_squeeze() + #test_unsqueeze() + #test_slice() + #test_floor() + #test_ceil() + #test_round() + #test_isinf() + #test_isnan() + #test_clip() + #test_onehot() + #test_matmul() + #test_batch_matmul() + #test_gather() + #test_gather_nd() + #test_scatter() + #test_lrn() + #test_instance_norm() + #test_upsample() + #test_forward_min() + #test_forward_max() + #test_forward_mean() + #test_forward_hardsigmoid() + #test_forward_arg_min_max() + #test_softmax() + #test_constantofshape() + #test_all_reduce_funcs() + #test_pad() + #test_split() + #test_binary_ops() + #test_single_ops() + #test_leaky_relu() + #test_elu() + #test_selu() + #test_prelu() + #test_ThresholdedRelu() + #test_ScaledTanh() + #test_ParametricSoftplus() + #test_Scale() + #test_LogSoftmax() + #test_resnet() + #test_inception() + #test_densenet() + #test_sign() + #test_not() + #test_and() + #test_tile() + #test_erf() + #test_where() + #test_or() + #test_depth_to_space() + #test_space_to_depth() + #test_batch_norm() + #test_batch_norm_dynamic_subgraph() test_conv() - test_convtranspose() - test_unsqueeze_constant() - test_pooling() - test_lppool() - test_lstm() - test_resize() - test_nonzero() - test_topk() - test_mod() - test_xor() - test_max_roi_pool() - test_roi_align() + #test_convtranspose() + #test_unsqueeze_constant() + #test_pooling() + #test_lppool() + #test_lstm() + #test_resize() + #test_nonzero() + #test_topk() + #test_mod() + #test_xor() + #test_max_roi_pool() + #test_roi_align() From 9d90b4a7bf59c28c5b6547b939bafe89d2734e80 Mon Sep 17 00:00:00 2001 From: Josh Fromm Date: Sun, 5 Jul 2020 13:50:34 -0700 Subject: [PATCH 3/3] Undo commented out lines oops. --- tests/python/frontend/onnx/test_forward.py | 140 ++++++++++----------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/tests/python/frontend/onnx/test_forward.py b/tests/python/frontend/onnx/test_forward.py index 87e97b9a18fd..5c472beed456 100644 --- a/tests/python/frontend/onnx/test_forward.py +++ b/tests/python/frontend/onnx/test_forward.py @@ -2928,74 +2928,74 @@ def verify_roi_align(input_dims, num_roi, output_height, output_width, sampling_ if __name__ == '__main__': - #test_flatten() - #test_reshape() - #test_shape() - #test_expand() - #test_power() - #test_squeeze() - #test_unsqueeze() - #test_slice() - #test_floor() - #test_ceil() - #test_round() - #test_isinf() - #test_isnan() - #test_clip() - #test_onehot() - #test_matmul() - #test_batch_matmul() - #test_gather() - #test_gather_nd() - #test_scatter() - #test_lrn() - #test_instance_norm() - #test_upsample() - #test_forward_min() - #test_forward_max() - #test_forward_mean() - #test_forward_hardsigmoid() - #test_forward_arg_min_max() - #test_softmax() - #test_constantofshape() - #test_all_reduce_funcs() - #test_pad() - #test_split() - #test_binary_ops() - #test_single_ops() - #test_leaky_relu() - #test_elu() - #test_selu() - #test_prelu() - #test_ThresholdedRelu() - #test_ScaledTanh() - #test_ParametricSoftplus() - #test_Scale() - #test_LogSoftmax() - #test_resnet() - #test_inception() - #test_densenet() - #test_sign() - #test_not() - #test_and() - #test_tile() - #test_erf() - #test_where() - #test_or() - #test_depth_to_space() - #test_space_to_depth() - #test_batch_norm() - #test_batch_norm_dynamic_subgraph() + test_flatten() + test_reshape() + test_shape() + test_expand() + test_power() + test_squeeze() + test_unsqueeze() + test_slice() + test_floor() + test_ceil() + test_round() + test_isinf() + test_isnan() + test_clip() + test_onehot() + test_matmul() + test_batch_matmul() + test_gather() + test_gather_nd() + test_scatter() + test_lrn() + test_instance_norm() + test_upsample() + test_forward_min() + test_forward_max() + test_forward_mean() + test_forward_hardsigmoid() + test_forward_arg_min_max() + test_softmax() + test_constantofshape() + test_all_reduce_funcs() + test_pad() + test_split() + test_binary_ops() + test_single_ops() + test_leaky_relu() + test_elu() + test_selu() + test_prelu() + test_ThresholdedRelu() + test_ScaledTanh() + test_ParametricSoftplus() + test_Scale() + test_LogSoftmax() + test_resnet() + test_inception() + test_densenet() + test_sign() + test_not() + test_and() + test_tile() + test_erf() + test_where() + test_or() + test_depth_to_space() + test_space_to_depth() + test_batch_norm() + test_batch_norm_dynamic_subgraph() test_conv() - #test_convtranspose() - #test_unsqueeze_constant() - #test_pooling() - #test_lppool() - #test_lstm() - #test_resize() - #test_nonzero() - #test_topk() - #test_mod() - #test_xor() - #test_max_roi_pool() - #test_roi_align() + test_convtranspose() + test_unsqueeze_constant() + test_pooling() + test_lppool() + test_lstm() + test_resize() + test_nonzero() + test_topk() + test_mod() + test_xor() + test_max_roi_pool() + test_roi_align()