mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #27882 from abhishek-gola:elu_layer_add
Extended Activation layers support #27882 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -1107,8 +1107,51 @@ void ONNXImporter2::parseConstant(LayerParams& layerParams, const opencv_onnx::N
|
||||
{
|
||||
CV_Assert(node_inputs.empty());
|
||||
CV_Assert(node_outputs.size() == 1);
|
||||
CV_Assert(layerParams.blobs.size() == 1);
|
||||
Mat m = layerParams.blobs[0];
|
||||
|
||||
Mat m;
|
||||
if (!layerParams.blobs.empty())
|
||||
{
|
||||
CV_Assert(layerParams.blobs.size() == 1);
|
||||
m = layerParams.blobs[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (layerParams.has("value_float"))
|
||||
{
|
||||
float v = layerParams.get<float>("value_float");
|
||||
int sizes[] = { 1 };
|
||||
m.create(1, sizes, CV_32F);
|
||||
m.at<float>(0) = v;
|
||||
}
|
||||
else if (layerParams.has("value_int"))
|
||||
{
|
||||
int v = layerParams.get<int>("value_int");
|
||||
int sizes[] = { 1 };
|
||||
m.create(1, sizes, CV_32S);
|
||||
m.at<int>(0) = v;
|
||||
}
|
||||
else if (layerParams.has("value_floats"))
|
||||
{
|
||||
const DictValue& arr = layerParams.get("value_floats");
|
||||
int n = (int)arr.size();
|
||||
int sizes[] = { n };
|
||||
m.create(1, sizes, CV_32F);
|
||||
for (int i = 0; i < n; ++i) m.at<float>(i) = (float)arr.getRealValue(i);
|
||||
}
|
||||
else if (layerParams.has("value_ints"))
|
||||
{
|
||||
const DictValue& arr = layerParams.get("value_ints");
|
||||
int n = (int)arr.size();
|
||||
int sizes[] = { n };
|
||||
m.create(1, sizes, CV_32S);
|
||||
for (int i = 0; i < n; ++i) m.at<int>(i) = arr.get<int>(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Error(Error::StsBadArg, "DNN/ONNX: Constant node has no supported attributes");
|
||||
}
|
||||
}
|
||||
|
||||
Arg out = node_outputs[0];
|
||||
ArgData& data = netimpl->args.at(out.idx);
|
||||
data.kind = DNN_ARG_CONST;
|
||||
|
||||
@@ -647,13 +647,13 @@ CASE(test_elu)
|
||||
CASE(test_elu_default)
|
||||
// no filter
|
||||
CASE(test_elu_default_expanded_ver18)
|
||||
// no filter
|
||||
SKIP;
|
||||
CASE(test_elu_example)
|
||||
// no filter
|
||||
CASE(test_elu_example_expanded_ver18)
|
||||
// no filter
|
||||
SKIP;
|
||||
CASE(test_elu_expanded_ver18)
|
||||
// no filter
|
||||
SKIP;
|
||||
CASE(test_equal)
|
||||
// no filter
|
||||
CASE(test_equal_bcast)
|
||||
@@ -1094,6 +1094,12 @@ CASE(test_hardsigmoid_default)
|
||||
// no filter
|
||||
CASE(test_hardsigmoid_example)
|
||||
// no filter
|
||||
CASE(test_hardsigmoid_default_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_hardsigmoid_example_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_hardsigmoid_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_hardswish)
|
||||
// no filter
|
||||
CASE(test_hardswish_expanded)
|
||||
@@ -1170,6 +1176,12 @@ CASE(test_leakyrelu_default)
|
||||
// no filter
|
||||
CASE(test_leakyrelu_example)
|
||||
// no filter
|
||||
CASE(test_leakyrelu_default_expanded)
|
||||
SKIP;
|
||||
CASE(test_leakyrelu_example_expanded)
|
||||
SKIP;
|
||||
CASE(test_leakyrelu_expanded)
|
||||
SKIP;
|
||||
CASE(test_less)
|
||||
// no filter
|
||||
CASE(test_less_bcast)
|
||||
@@ -1677,6 +1689,10 @@ CASE(test_prelu_broadcast)
|
||||
// no filter
|
||||
CASE(test_prelu_example)
|
||||
// no filter
|
||||
CASE(test_prelu_broadcast_expanded)
|
||||
SKIP;
|
||||
CASE(test_prelu_example_expanded)
|
||||
SKIP;
|
||||
CASE(test_qlinearconv)
|
||||
// no filter
|
||||
CASE(test_qlinearmatmul_2D)
|
||||
@@ -2029,6 +2045,8 @@ CASE(test_reflect_pad)
|
||||
SKIP;
|
||||
CASE(test_relu)
|
||||
// no filter
|
||||
CASE(test_relu_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_reshape_allowzero_reordered)
|
||||
// no filter
|
||||
CASE(test_reshape_extended_dims)
|
||||
@@ -2282,13 +2300,13 @@ CASE(test_selu)
|
||||
CASE(test_selu_default)
|
||||
// no filter
|
||||
CASE(test_selu_default_expanded_ver18)
|
||||
// no filter
|
||||
SKIP;
|
||||
CASE(test_selu_example)
|
||||
// no filter
|
||||
CASE(test_selu_example_expanded_ver18)
|
||||
// no filter
|
||||
SKIP;
|
||||
CASE(test_selu_expanded_ver18)
|
||||
// no filter
|
||||
SKIP;
|
||||
CASE(test_sequence_insert_at_back)
|
||||
// no filter
|
||||
CASE(test_sequence_insert_at_front)
|
||||
@@ -2317,6 +2335,10 @@ CASE(test_shrink_hard)
|
||||
// no filter
|
||||
CASE(test_shrink_soft)
|
||||
// no filter
|
||||
CASE(test_shrink_hard_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_shrink_soft_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_sigmoid)
|
||||
// no filter
|
||||
CASE(test_sigmoid_example)
|
||||
@@ -2417,10 +2439,18 @@ CASE(test_softplus)
|
||||
// no filter
|
||||
CASE(test_softplus_example)
|
||||
// no filter
|
||||
CASE(test_softplus_example_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_softplus_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_softsign)
|
||||
// no filter
|
||||
CASE(test_softsign_example)
|
||||
// no filter
|
||||
CASE(test_softsign_example_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_softsign_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_spacetodepth)
|
||||
// no filter
|
||||
CASE(test_spacetodepth_example)
|
||||
@@ -2531,6 +2561,12 @@ CASE(test_thresholdedrelu_default)
|
||||
// no filter
|
||||
CASE(test_thresholdedrelu_example)
|
||||
// no filter
|
||||
CASE(test_thresholdedrelu_default_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_thresholdedrelu_example_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_thresholdedrelu_expanded_ver18)
|
||||
SKIP;
|
||||
CASE(test_tile)
|
||||
SKIP;
|
||||
CASE(test_tile_precomputed)
|
||||
|
||||
@@ -433,3 +433,27 @@
|
||||
"test_reduce_sum_square_keepdims_random",
|
||||
"test_reduce_sum_square_negative_axes_keepdims_example",
|
||||
"test_reduce_sum_square_negative_axes_keepdims_random",
|
||||
"test_elu_default_expanded_ver18",
|
||||
"test_elu_example_expanded_ver18",
|
||||
"test_elu_expanded_ver18",
|
||||
"test_thresholdedrelu_default_expanded_ver18",
|
||||
"test_thresholdedrelu_example_expanded_ver18",
|
||||
"test_thresholdedrelu_expanded_ver18",
|
||||
"test_selu_default_expanded_ver18",
|
||||
"test_selu_example_expanded_ver18",
|
||||
"test_selu_expanded_ver18",
|
||||
"test_hardsigmoid_default_expanded_ver18",
|
||||
"test_hardsigmoid_example_expanded_ver18",
|
||||
"test_hardsigmoid_expanded_ver18",
|
||||
"test_softplus_example_expanded_ver18",
|
||||
"test_softplus_expanded_ver18",
|
||||
"test_softsign_example_expanded_ver18",
|
||||
"test_softsign_expanded_ver18",
|
||||
"test_shrink_hard_expanded_ver18",
|
||||
"test_shrink_soft_expanded_ver18",
|
||||
"test_relu_expanded_ver18",
|
||||
"test_prelu_broadcast_expanded",
|
||||
"test_prelu_example_expanded",
|
||||
"test_leakyrelu_default_expanded",
|
||||
"test_leakyrelu_example_expanded",
|
||||
"test_leakyrelu_expanded",
|
||||
|
||||
@@ -356,9 +356,6 @@
|
||||
"test_dynamicquantizelinear_min_adjusted_expanded", // ---- same as above ---
|
||||
"test_einsum_inner_prod", // Issue::Output shape does not match with reference
|
||||
"test_einsum_scalar",
|
||||
"test_elu_default_expanded_ver18",
|
||||
"test_elu_example_expanded_ver18",
|
||||
"test_elu_expanded_ver18",
|
||||
"test_equal_string",
|
||||
"test_equal_string_broadcast",
|
||||
"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'
|
||||
@@ -389,9 +386,6 @@
|
||||
"test_hannwindow_expanded",
|
||||
"test_hannwindow_symmetric",
|
||||
"test_hannwindow_symmetric_expanded",
|
||||
"test_hardsigmoid_default_expanded_ver18",
|
||||
"test_hardsigmoid_example_expanded_ver18",
|
||||
"test_hardsigmoid_expanded_ver18",
|
||||
"test_identity_opt", // 23221 illegal hardware instruction
|
||||
"test_identity_sequence", // Issue:: Unkonwn error
|
||||
"test_if_opt", // Issue::Failed to allocate 17059022683624350 bytes in function 'OutOfMemoryError'
|
||||
@@ -467,9 +461,6 @@
|
||||
"test_layer_normalization_default_axis",
|
||||
"test_layer_normalization_default_axis_expanded",
|
||||
"test_layer_normalization_default_axis_expanded_ver18",
|
||||
"test_leakyrelu_default_expanded",
|
||||
"test_leakyrelu_example_expanded",
|
||||
"test_leakyrelu_expanded",
|
||||
"test_loop11", // Issue::'Graph' is not supported in function 'getLayerParams'
|
||||
"test_loop13_seq", // Issue::typeProto.has_tensor_type() in function 'populateNet'
|
||||
"test_loop16_seq_none", // Issue::Failed to allocate 179812654996800 bytes in function 'OutOfMemoryError'
|
||||
@@ -542,9 +533,7 @@
|
||||
"test_optional_has_element_optional_input",
|
||||
"test_optional_has_element_tensor_input",
|
||||
"test_prelu_broadcast", // Issue::Parser:Blob slope not found in const blobs in function 'getBlob' (weights are required as inputs)
|
||||
"test_prelu_broadcast_expanded",
|
||||
"test_prelu_example", // ---- same as above ---
|
||||
"test_prelu_example_expanded",
|
||||
"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_2D_int8_float16",
|
||||
@@ -585,7 +574,6 @@
|
||||
"test_regex_full_match_basic",
|
||||
"test_regex_full_match_email_domain",
|
||||
"test_regex_full_match_empty",
|
||||
"test_relu_expanded_ver18",
|
||||
"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_align_corners", // ---- same as above ---
|
||||
"test_resize_downsample_scales_cubic_antialias",
|
||||
@@ -734,9 +722,6 @@
|
||||
"test_sce_sum_expanded", // ---- same as above ---
|
||||
"test_sce_sum_log_prob", // ---- same as above ---
|
||||
"test_sce_sum_log_prob_expanded", // ---- same as above ---
|
||||
"test_selu_default_expanded_ver18",
|
||||
"test_selu_example_expanded_ver18",
|
||||
"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_sequence_map_add_1_sequence_1_tensor",
|
||||
@@ -752,16 +737,10 @@
|
||||
"test_sequence_map_identity_2_sequences",
|
||||
"test_sequence_map_identity_2_sequences_expanded",
|
||||
"test_shape_start_greater_than_end",
|
||||
"test_shrink_hard_expanded_ver18",
|
||||
"test_shrink_soft_expanded_ver18",
|
||||
"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_slice_start_out_of_bounds",
|
||||
"test_softplus_example_expanded_ver18",
|
||||
"test_softplus_expanded_ver18",
|
||||
"test_softsign_example_expanded_ver18",
|
||||
"test_softsign_expanded_ver18",
|
||||
"test_split_1d_uneven_split_opset18", //type mismatch
|
||||
"test_split_2d_uneven_split_opset18",
|
||||
"test_split_equal_parts_1d_opset13",
|
||||
@@ -804,9 +783,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_thresholdedrelu_default_expanded_ver18",
|
||||
"test_thresholdedrelu_example_expanded_ver18",
|
||||
"test_thresholdedrelu_expanded_ver18",
|
||||
"test_training_dropout", // Issue::cvtest::norm::wrong data type
|
||||
"test_training_dropout_default", // ---- same as above --- type mismatch
|
||||
"test_training_dropout_default_mask", // ---- same as above ---
|
||||
|
||||
Reference in New Issue
Block a user