mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #29217 from MBSaravanaBalaji:feat/onnx-lppool
dnn: implement LpPool ONNX operator #29217 ## Summary Implements the `LpPool` ONNX operator (opset 1–18), which was previously unregistered and caused a parse failure. `LpPool` computes the Lp-norm pooling: `(sum(|x|^p))^(1/p)` over a sliding window. ## Changes - New `LpPoolLayer` in `modules/dnn/src/layers/lppool_layer.cpp` - Supports `kernel_shape`, `strides`, `dilations`, `pads`, `auto_pad` (NOTSET/SAME_UPPER), `ceil_mode`, and `p` (default 2) - SIMD fast paths for p=1 (abs + accumulate) and p=2 (square + accumulate + sqrt); scalar fallback for other values of p - Registered `LpPool` dispatch entry in both `onnx_importer.cpp` (classic engine) and `onnx_importer2.cpp` (new graph engine) - Added `LpPoolLayer` declaration to `modules/dnn/include/opencv2/dnn/all_layers.hpp` - Registered layer class in `modules/dnn/src/init.cpp` - Re-enabled 8 lppool conformance tests in `test_onnx_conformance.cpp` (previously in parser denylist) - `test_lppool_2d_same_lower` added to the global conformance denylist — same known SAME_LOWER padding bug that affects `averagepool` and `maxpool` ## Testing All applicable ONNX conformance tests pass: | Test | Result | |------|--------| | test_lppool_1d_default | PASSED | | test_lppool_2d_default | PASSED | | test_lppool_2d_dilations | PASSED | | test_lppool_2d_pads | PASSED | | test_lppool_2d_same_lower | SKIPPED (known SAME_LOWER padding bug, consistent with avgpool/maxpool) | | test_lppool_2d_same_upper | PASSED | | test_lppool_2d_strides | PASSED | | test_lppool_3d_default | PASSED | Tested on: macOS (x86_64/SSE4, Rosetta 2) and Linux x86_64 (AVX2/AVX-512, GCC 13.3.0), Release build OpenCV version: 5.0.0-pre ## Related Issues None --- ### 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 - [ ] 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. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
d36133b325
commit
e2f0876777
@@ -1419,14 +1419,14 @@ static const TestCase testConformanceConfig[] = {
|
||||
{"test_logsoftmax_large_number_expanded_ver18", 0, 0},
|
||||
{"test_logsoftmax_negative_axis_expanded_ver18", 0, 0},
|
||||
{"test_lpnormalization_default", 0, 0},
|
||||
{"test_lppool_1d_default", 0, 0},
|
||||
{"test_lppool_2d_default", 0, 0},
|
||||
{"test_lppool_2d_dilations", 0, 0},
|
||||
{"test_lppool_2d_pads", 0, 0},
|
||||
{"test_lppool_2d_same_lower", 0, 0},
|
||||
{"test_lppool_2d_same_upper", 0, 0},
|
||||
{"test_lppool_2d_strides", 0, 0},
|
||||
{"test_lppool_3d_default", 0, 0},
|
||||
{"test_lppool_1d_default", 1, 1},
|
||||
{"test_lppool_2d_default", 1, 1},
|
||||
{"test_lppool_2d_dilations", 1, 1},
|
||||
{"test_lppool_2d_pads", 1, 1},
|
||||
{"test_lppool_2d_same_lower", 1, 1},
|
||||
{"test_lppool_2d_same_upper", 1, 1},
|
||||
{"test_lppool_2d_strides", 1, 1},
|
||||
{"test_lppool_3d_default", 1, 1},
|
||||
{"test_maxpool_2d_ceil_output_size_reduce_by_one", 0, 0},
|
||||
{"test_maxpool_3d_dilations", 0, 0},
|
||||
{"test_maxpool_3d_dilations_use_ref_impl", 0, 0},
|
||||
|
||||
@@ -70,6 +70,13 @@
|
||||
"test_logsoftmax_default_axis",
|
||||
"test_logsoftmax_large_number",
|
||||
"test_logsoftmax_large_number_expanded",
|
||||
"test_lppool_1d_default",
|
||||
"test_lppool_2d_default",
|
||||
"test_lppool_2d_dilations",
|
||||
"test_lppool_2d_pads",
|
||||
"test_lppool_2d_same_upper",
|
||||
"test_lppool_2d_strides",
|
||||
"test_lppool_3d_default",
|
||||
"test_maxpool_2d_dilations",
|
||||
"test_maxpool_2d_same_lower",
|
||||
"test_maxpool_2d_uint8",
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
"test_einsum_transpose",
|
||||
"test_logsoftmax_large_number", // fp16 accuracy issue
|
||||
"test_logsoftmax_large_number_expanded", // fp16 accuracy issue
|
||||
"test_lppool_1d_default",
|
||||
"test_lppool_2d_default",
|
||||
"test_lppool_2d_dilations",
|
||||
"test_lppool_2d_pads",
|
||||
"test_lppool_2d_same_upper",
|
||||
"test_lppool_2d_strides",
|
||||
"test_lppool_3d_default",
|
||||
"test_maxpool_with_argmax_2d_precomputed_pads", // assertion failed mat.type() == CV_32F
|
||||
"test_nllloss_NCd1d2d3d4d5_none_no_weight_expanded", // crash: https://github.com/opencv/opencv/issues/25471
|
||||
"test_reduce_prod_default_axes_keepdims_example", // fallback to cpu, accuracy
|
||||
|
||||
@@ -1470,6 +1470,20 @@ CASE(test_loop13_seq)
|
||||
// no filter
|
||||
CASE(test_loop16_seq_none)
|
||||
// no filter
|
||||
CASE(test_lppool_1d_default)
|
||||
SKIP; // no nGraph/OpenVINO backend for LpPool, fallback to CPU
|
||||
CASE(test_lppool_2d_default)
|
||||
SKIP;
|
||||
CASE(test_lppool_2d_dilations)
|
||||
SKIP;
|
||||
CASE(test_lppool_2d_pads)
|
||||
SKIP;
|
||||
CASE(test_lppool_2d_same_upper)
|
||||
SKIP;
|
||||
CASE(test_lppool_2d_strides)
|
||||
SKIP;
|
||||
CASE(test_lppool_3d_default)
|
||||
SKIP;
|
||||
CASE(test_lrn)
|
||||
// no filter
|
||||
CASE(test_lrn_default)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"test_averagepool_2d_pads_count_include_pad", // wrong output
|
||||
"test_averagepool_2d_precomputed_pads_count_include_pad", // wrong output
|
||||
"test_averagepool_2d_same_lower", // wrong output
|
||||
"test_lppool_2d_same_lower", // wrong output (same SAME_LOWER padding issue)
|
||||
"test_cast_FLOAT_to_STRING", // Unsupported type in function 'parseCast'
|
||||
"test_cast_STRING_to_FLOAT", // unexception during net.forward() call
|
||||
"test_castlike_FLOAT_to_STRING_expanded", // Unsupported type in function 'parseCast'
|
||||
|
||||
@@ -753,6 +753,13 @@
|
||||
"test_convtranspose_pad",
|
||||
"test_convtranspose_pads",
|
||||
"test_convtranspose_with_kernel",
|
||||
"test_lppool_1d_default",
|
||||
"test_lppool_2d_default",
|
||||
"test_lppool_2d_dilations",
|
||||
"test_lppool_2d_pads",
|
||||
"test_lppool_2d_same_upper",
|
||||
"test_lppool_2d_strides",
|
||||
"test_lppool_3d_default",
|
||||
"test_maxpool_3d_dilations",
|
||||
"test_maxpool_3d_dilations_use_ref_impl",
|
||||
"test_maxpool_3d_dilations_use_ref_impl_large",
|
||||
|
||||
Reference in New Issue
Block a user