diff --git a/modules/dnn/src/layers/shape_layer.cpp b/modules/dnn/src/layers/shape_layer.cpp index dcfcb35f0f..56df592ee4 100644 --- a/modules/dnn/src/layers/shape_layer.cpp +++ b/modules/dnn/src/layers/shape_layer.cpp @@ -45,6 +45,9 @@ public: int start_ = start < 0 ? start + outDims : start; int end_ = end >= outDims ? outDims : end < 0 ? end + outDims : end; + start_ = std::max(0, std::min(start_, outDims)); + end_ = std::max(0, std::min(end_, outDims)); + CV_Assert(0 <= start_); CV_Assert(start_ <= end_); CV_Assert(end_ <= outDims); @@ -108,7 +111,7 @@ public: shape_type_t shapeData[CV_MAX_DIM]; for (int i = r.start; i < r.end; i++) - shapeData[i] = (shape_type_t)inpShape[i]; + shapeData[i - r.start] = (shape_type_t)inpShape[i]; Mat shape({r.end - r.start}, shapeType, shapeData); diff --git a/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp b/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp index 7e26a56f4e..eda32d5c5b 100644 --- a/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp +++ b/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp @@ -595,9 +595,9 @@ CASE(test_exp) CASE(test_exp_example) // no filter CASE(test_expand_dim_changed) - // no filter + SKIP; CASE(test_expand_dim_unchanged) - // no filter + SKIP; CASE(test_eyelike_populate_off_main_diagonal) // no filter CASE(test_eyelike_with_dtype) @@ -677,27 +677,27 @@ CASE(test_gelu_tanh_2) CASE(test_gelu_tanh_2_expanded) // no filter CASE(test_gemm_all_attributes) - // no filter + SKIP; CASE(test_gemm_alpha) - // no filter + SKIP; CASE(test_gemm_beta) - // no filter + SKIP; CASE(test_gemm_default_matrix_bias) SKIP; // https://github.com/opencv/opencv/issues/25472 CASE(test_gemm_default_no_bias) - // no filter + SKIP; CASE(test_gemm_default_scalar_bias) - // no filter + SKIP; CASE(test_gemm_default_single_elem_vector_bias) - // no filter + SKIP; CASE(test_gemm_default_vector_bias) - // no filter + SKIP; CASE(test_gemm_default_zero_bias) - // no filter + SKIP; CASE(test_gemm_transposeA) - // no filter + SKIP; CASE(test_gemm_transposeB) - // no filter + SKIP; CASE(test_globalaveragepool) // no filter CASE(test_globalaveragepool_precomputed) @@ -1302,11 +1302,11 @@ CASE(test_quantizelinear_axis) CASE(test_quantizelinear_blocked) SKIP; CASE(test_range_float_type_positive_delta) - // no filter + SKIP; CASE(test_range_float_type_positive_delta_expanded) // no filter CASE(test_range_int32_type_negative_delta) - // no filter + SKIP; CASE(test_range_int32_type_negative_delta_expanded) // no filter CASE(test_reciprocal) @@ -1566,23 +1566,23 @@ CASE(test_relu) CASE(test_reshape_allowzero_reordered) // no filter CASE(test_reshape_extended_dims) - // no filter + SKIP; CASE(test_reshape_negative_dim) - // no filter + SKIP; CASE(test_reshape_negative_extended_dims) - // no filter + SKIP; CASE(test_reshape_one_dim) - // no filter + SKIP; CASE(test_reshape_reduced_dims) - // no filter + SKIP; CASE(test_reshape_reordered_all_dims) - // no filter + SKIP; CASE(test_reshape_reordered_last_dims) - // no filter + SKIP; CASE(test_reshape_zero_and_negative_dim) - // no filter + SKIP; CASE(test_reshape_zero_dim) - // no filter + SKIP; CASE(test_resize_downsample_scales_cubic) // no filter CASE(test_resize_downsample_scales_cubic_A_n0p5_exclude_outside) @@ -1824,25 +1824,25 @@ CASE(test_sequence_insert_at_back) CASE(test_sequence_insert_at_front) // no filter CASE(test_shape) - // no filter + SKIP; CASE(test_shape_clip_end) - // no filter + SKIP; CASE(test_shape_clip_start) - // no filter + SKIP; CASE(test_shape_end_1) - // no filter + SKIP; CASE(test_shape_end_negative_1) - // no filter + SKIP; CASE(test_shape_example) - // no filter + SKIP; CASE(test_shape_start_1) - // no filter + SKIP; CASE(test_shape_start_1_end_2) - // no filter + SKIP; CASE(test_shape_start_1_end_negative_1) - // no filter + SKIP; CASE(test_shape_start_negative_1) - // no filter + SKIP; CASE(test_shrink_hard) // no filter CASE(test_shrink_soft) @@ -1872,19 +1872,19 @@ CASE(test_size) CASE(test_size_example) // no filter CASE(test_slice) - // no filter + SKIP; CASE(test_slice_default_axes) - // no filter + SKIP; CASE(test_slice_default_steps) - // no filter + SKIP; CASE(test_slice_end_out_of_bounds) - // no filter + SKIP; CASE(test_slice_neg) - // no filter + SKIP; CASE(test_slice_neg_steps) - // no filter + SKIP; CASE(test_slice_negative_axes) - // no filter + SKIP; CASE(test_slice_start_out_of_bounds) // no filter CASE(test_softmax_axis_0) @@ -1942,17 +1942,17 @@ CASE(test_spacetodepth) CASE(test_spacetodepth_example) // no filter CASE(test_split_equal_parts_1d) - // no filter + SKIP; CASE(test_split_equal_parts_2d) - // no filter + SKIP; CASE(test_split_equal_parts_default_axis) - // no filter + SKIP; CASE(test_split_variable_parts_1d) - // no filter + SKIP; CASE(test_split_variable_parts_2d) - // no filter + SKIP; CASE(test_split_variable_parts_default_axis) - // no filter + SKIP; CASE(test_split_zero_size_splits) // no filter CASE(test_sqrt) @@ -1960,9 +1960,9 @@ CASE(test_sqrt) CASE(test_sqrt_example) // no filter CASE(test_squeeze) - // no filter + SKIP; CASE(test_squeeze_negative_axes) - // no filter + SKIP; CASE(test_strnormalizer_export_monday_casesensintive_lower) // no filter CASE(test_strnormalizer_export_monday_casesensintive_nochangecase) @@ -2022,9 +2022,9 @@ CASE(test_thresholdedrelu_default) CASE(test_thresholdedrelu_example) // no filter CASE(test_tile) - // no filter + SKIP; CASE(test_tile_precomputed) - // no filter + SKIP; CASE(test_top_k) SKIP; CASE(test_top_k_negative_axis) @@ -2104,21 +2104,21 @@ CASE(test_unique_sorted_with_negative_axis) CASE(test_unique_sorted_without_axis) // no filter CASE(test_unsqueeze_axis_0) - // no filter + SKIP; CASE(test_unsqueeze_axis_1) - // no filter + SKIP; CASE(test_unsqueeze_axis_2) - // no filter + SKIP; CASE(test_unsqueeze_axis_3) - // no filter + SKIP; CASE(test_unsqueeze_negative_axes) - // no filter + SKIP; CASE(test_unsqueeze_three_axes) - // no filter + SKIP; CASE(test_unsqueeze_two_axes) - // no filter + SKIP; CASE(test_unsqueeze_unsorted_axes) - // no filter + SKIP; CASE(test_upsample_nearest) #if SKIP_SET_1 SKIP; diff --git a/modules/dnn/test/test_onnx_conformance_layer_filter_opencv_classic_denylist.inl.hpp b/modules/dnn/test/test_onnx_conformance_layer_filter_opencv_classic_denylist.inl.hpp index 3235da210d..c78c22b3fc 100644 --- a/modules/dnn/test/test_onnx_conformance_layer_filter_opencv_classic_denylist.inl.hpp +++ b/modules/dnn/test/test_onnx_conformance_layer_filter_opencv_classic_denylist.inl.hpp @@ -1,4 +1,57 @@ "test_if", "test_top_k", // Issue:: K being input is not compatible with the current engine -"test_top_k_negative_axis", // ---- same as above --- -"test_top_k_smallest", // ---- same as above --- +"test_top_k_negative_axis", // same as above +"test_top_k_smallest", // same as above +"test_expand_dim_changed", +"test_expand_dim_unchanged", +"test_gemm_all_attributes", +"test_gemm_alpha", +"test_gemm_beta", +"test_gemm_default_scalar_bias", +"test_gemm_default_single_elem_vector_bias", +"test_gemm_default_vector_bias", +"test_gemm_default_zero_bias", +"test_gemm_transposeA", +"test_gemm_transposeB", +"test_range_float_type_positive_delta", +"test_range_int32_type_negative_delta", +"test_reshape_extended_dims", +"test_reshape_negative_dim", +"test_reshape_negative_extended_dims", +"test_reshape_one_dim", +"test_reshape_reduced_dims", +"test_reshape_reordered_all_dims", +"test_reshape_reordered_last_dims", +"test_reshape_zero_and_negative_dim", +"test_reshape_zero_dim", +"test_shape", +"test_shape_clip_end", +"test_shape_clip_start", +"test_shape_end_1", +"test_shape_end_negative_1", +"test_shape_example", +"test_shape_start_1", +"test_shape_start_1_end_2", +"test_shape_start_1_end_negative_1", +"test_shape_start_negative_1", +"test_slice", +"test_slice_default_axes", +"test_slice_default_steps", +"test_slice_end_out_of_bounds", +"test_slice_neg", +"test_slice_neg_steps", +"test_slice_negative_axes", +"test_split_variable_parts_1d", +"test_split_variable_parts_2d", +"test_split_variable_parts_default_axis", +"test_squeeze", +"test_squeeze_negative_axes", +"test_tile", +"test_tile_precomputed", +"test_unsqueeze_axis_0", +"test_unsqueeze_axis_1", +"test_unsqueeze_axis_2", +"test_unsqueeze_negative_axes", +"test_unsqueeze_three_axes", +"test_unsqueeze_two_axes", +"test_unsqueeze_unsorted_axes", diff --git a/modules/dnn/test/test_onnx_conformance_layer_parser_denylist.inl.hpp b/modules/dnn/test/test_onnx_conformance_layer_parser_denylist.inl.hpp index 0d391aab6c..6d951cc184 100644 --- a/modules/dnn/test/test_onnx_conformance_layer_parser_denylist.inl.hpp +++ b/modules/dnn/test/test_onnx_conformance_layer_parser_denylist.inl.hpp @@ -95,8 +95,6 @@ "test_elu_default_expanded_ver18", "test_elu_example_expanded_ver18", "test_elu_expanded_ver18", -"test_expand_dim_changed", // Issue:: Unkonwn error -"test_expand_dim_unchanged", // Issue:: Unkonwn error "test_eyelike_populate_off_main_diagonal", // Issues::Layer::Can't create layer::Can't create layer "onnx_node_output_0!y" of type "EyeLike" in function 'getLayerInstance' "test_eyelike_with_dtype", // ---- same as above --- "test_eyelike_without_dtype", // ---- same as above --- @@ -104,15 +102,6 @@ "test_gelu_default_2_expanded", // parser: no corresponding layer for CastLike "test_gelu_tanh_1_expanded", // parser: no corresponding layer for CastLike "test_gelu_tanh_2_expanded", // parser: no corresponding layer for CastLike -"test_gemm_all_attributes", // Issue::Wrong output -"test_gemm_alpha", // Issue::Wrong output -"test_gemm_beta", // Issue::Wrong output -"test_gemm_default_scalar_bias", // Issue::Wrong output -"test_gemm_default_single_elem_vector_bias", // Issue::Wrong output -"test_gemm_default_vector_bias", // Issue::Wrong output -"test_gemm_default_zero_bias", // Issue::Wrong output -"test_gemm_transposeA", // Issue::Wrong output -"test_gemm_transposeB", // Issue::Wrong output "test_gridsample", // Issues::Layer::Can't create layer "onnx_node_output_0!Y" of type "GridSample" in function 'getLayerInstance' "test_gridsample_aligncorners_true", // ---- same as above --- "test_gridsample_bicubic", // ---- same as above --- @@ -222,9 +211,7 @@ "test_qlinearconv", // Issue::Parser: Blob x_scale not found in const blobs in function 'getBlob' (weights are required as inputs) "test_qlinearmatmul_2D", // Issue:: Parser: Variable weights is not supported in function 'parseQMatMul' "test_qlinearmatmul_3D", // ---- same as above --- -"test_range_float_type_positive_delta", // Issue:: Unsupported data type in function. Unsupported type in function 'parseCast' -"test_range_float_type_positive_delta_expanded", // ---- same as above --- -"test_range_int32_type_negative_delta", // Issue:: Unsupported data type: INT32 in function. Unsupported type in function 'parseCast' +"test_range_float_type_positive_delta_expanded", // ---- Unsupported operations: Loop --- "test_range_int32_type_negative_delta_expanded", // ---- same as above --- "test_reduce_sum_default_axes_keepdims_example", // Issue:: Parser: Reduce layer doesn't support non contant axes: 'constBlobs.find(node_proto.input(1)) != constBlobs.end()' must be 'true' (layer does not support dynamic parameters) "test_reduce_sum_default_axes_keepdims_random", // ---- same as above --- @@ -237,16 +224,7 @@ "test_reduce_sum_negative_axes_keepdims_example", "test_reduce_sum_negative_axes_keepdims_random", // ---- same as above --- "test_reflect_pad", // Issue:: Parser: Blob shape not found in const blobs in function 'getBlob' (weights are required as inputs) -"test_reshape_allowzero_reordered", -"test_reshape_extended_dims", // ---- same as above --- -"test_reshape_negative_dim", // ---- same as above --- -"test_reshape_negative_extended_dims", // ---- same as above --- -"test_reshape_one_dim", // ---- same as above --- -"test_reshape_reduced_dims", // ---- same as above --- -"test_reshape_reordered_all_dims", // ---- same as above --- -"test_reshape_reordered_last_dims", // ---- same as above --- -"test_reshape_zero_and_negative_dim", // ---- same as above --- -"test_reshape_zero_dim", // ---- same as above --- +"test_reshape_allowzero_reordered", // incompatible type of input tensor #0 'data': CV_8UC1 given, CV_32FC1 expected in function 'setGraphInput' "test_resize_downsample_scales_cubic", // Issue:: Parser: layer_id.find(node_proto.input(i)) == layer_id.end() in function 'parseResize' "test_resize_downsample_scales_cubic_A_n0p5_exclude_outside", // ---- same as above --- "test_resize_downsample_scales_cubic_align_corners", // ---- same as above --- @@ -350,35 +328,13 @@ "test_selu_expanded_ver18", "test_sequence_insert_at_back", // Issue:: Parser: typeProto.has_tensor_type() in function 'populateNet' "test_sequence_insert_at_front", // ---- same as above --- -"test_shape", // Issue:: Parser: DNN/ONNX: can't find layer for output name: 'y'. Does model imported properly? -"test_shape_clip_end", // ---- same as above --- -"test_shape_clip_start", // ---- same as above --- -"test_shape_end_1", // ---- same as above --- -"test_shape_end_negative_1", // ---- same as above --- -"test_shape_example", // ---- same as above --- -"test_shape_start_1", // ---- same as above --- -"test_shape_start_1_end_2", // ---- same as above --- -"test_shape_start_1_end_negative_1", // ---- same as above --- -"test_shape_start_negative_1", // ---- same as above --- "test_simple_rnn_batchwise", // Issue:: Parser: Can't create layer "onnx_node_output_1!Y_h" of type "RNN" in function 'getLayerInstance' "test_simple_rnn_defaults", // ---- same as above --- "test_simple_rnn_with_initial_bias", // ---- same as above --- "test_size", // Issue:: Parser: Can't create layer "onnx_node_output_0!y" of type "Size" in function 'getLayerInstance' "test_size_example", // ---- same as above --- -"test_slice", // Issue:: Parser: constBlobs.find(node_proto.input(i)) != constBlobs.end() in function 'parseSlice' -"test_slice_default_axes", // ---- same as above --- -"test_slice_default_steps", // ---- same as above --- -"test_slice_end_out_of_bounds", // ---- same as above --- -"test_slice_neg", // ---- same as above --- -"test_slice_neg_steps", // ---- same as above --- -"test_slice_negative_axes", // ---- same as above --- -"test_slice_start_out_of_bounds", // ---- same as above --- -"test_split_variable_parts_1d", // ---- same as above --- -"test_split_variable_parts_2d", // ---- same as above --- -"test_split_variable_parts_default_axis", // ---- same as above --- -"test_split_zero_size_splits", // ---- same as above --- -"test_squeeze", // Issue:: Parser: ONNX/Squeeze: doesn't support non-constant 'axes' input in function 'parseSqueeze' (layer parameters are dynamic) -"test_squeeze_negative_axes", // ---- same as above --- +"test_slice_start_out_of_bounds", +"test_split_zero_size_splits", // ---- incompatible type of input tensor #0 'input': CV_8UC1 given, CV_32FC1 expected in function 'setGraphInput' --- "test_strnormalizer_export_monday_casesensintive_lower", // 'Strings' (1) are not supported in function 'getLayerParams' "test_strnormalizer_export_monday_casesensintive_nochangecase", // ---- same as above --- "test_strnormalizer_export_monday_casesensintive_upper", // ---- same as above --- @@ -392,8 +348,6 @@ "test_tfidfvectorizer_tf_onlybigrams_levelempty", // ---- same as above --- "test_tfidfvectorizer_tf_onlybigrams_skip5", // ---- same as above --- "test_tfidfvectorizer_tf_uniandbigrams_skip5", // Issue:: Parser: Can't create layer "onnx_node_output_0!Y" of type "TfIdfVectorizer" in function 'getLayerInstance' -"test_tile", // Issue:: Parser: ONNX/Tile: repeats being non-constant is not supported. in function 'parseTile' (layer parameters are dynamic) -"test_tile_precomputed", // // ---- same as above --- "test_training_dropout", // Issue::cvtest::norm::wrong data type "test_training_dropout_default", // ---- same as above --- "test_training_dropout_default_mask", // ---- same as above --- @@ -423,10 +377,3 @@ "test_unique_sorted_with_axis_3d", // ---- same as above --- "test_unique_sorted_with_negative_axis", // ---- same as above --- "test_unique_sorted_without_axis", // ---- same as above --- -"test_unsqueeze_axis_0", // Issue::(most probaly weights are required as inputs: Blob axes not found in const blobs in function 'getBlob' -"test_unsqueeze_axis_1", // ---- same as above --- -"test_unsqueeze_axis_2", // ---- same as above --- -"test_unsqueeze_negative_axes", // ---- same as above --- -"test_unsqueeze_three_axes", // ---- same as above --- -"test_unsqueeze_two_axes", // ---- same as above ---) -"test_unsqueeze_unsorted_axes", // ---- same as above ---)