From b3a2444bcf614aa47d47ba58885bee58c79406e7 Mon Sep 17 00:00:00 2001 From: Abduragim Shtanchaev <44877829+Abdurrahheem@users.noreply.github.com> Date: Thu, 20 Apr 2023 10:11:33 +0300 Subject: [PATCH] Merge pull request #23501 from Abdurrahheem:additional_lstm_tests Added LSTM and GRU tests for various batch and input length sizes #23501 Added tests with various sequence length and batch sizes Test data: https://github.com/opencv/opencv_extra/pull/1057 ### 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. - [x] The feature is well documented and sample code can be built with the project CMake --- modules/dnn/test/test_onnx_importer.cpp | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/modules/dnn/test/test_onnx_importer.cpp b/modules/dnn/test/test_onnx_importer.cpp index b8615912c5..ef8c494131 100644 --- a/modules/dnn/test/test_onnx_importer.cpp +++ b/modules/dnn/test/test_onnx_importer.cpp @@ -1287,6 +1287,48 @@ TEST_P(Test_ONNX_layers, GRU) testONNXModels("gru", npy, 0, 0, false, false); } +TEST_P(Test_ONNX_layers, gru_cell_batchsize_50_seqlen_1) +{ +#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000) + // IE exception: Node GRU_22 was not assigned on any pointed device + if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)) + applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, + CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION + ); +#endif + if(backend == DNN_BACKEND_CUDA) + applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); + testONNXModels("gru_cell_batchsize_50_seqlen_1", npy, 0, 0, false, false); +} + +TEST_P(Test_ONNX_layers, gru_cell_batchsize_5_seqlen_5) +{ +#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000) + // IE exception: Node GRU_22 was not assigned on any pointed device + if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)) + applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, + CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION + ); +#endif + if(backend == DNN_BACKEND_CUDA) + applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); + testONNXModels("gru_cell_batchsize_5_seqlen_5", npy, 0, 0, false, false); +} + +TEST_P(Test_ONNX_layers, gru_cell_batchsize_1_seqlen_50) +{ +#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000) + // IE exception: Node GRU_22 was not assigned on any pointed device + if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)) + applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, + CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION + ); +#endif + if(backend == DNN_BACKEND_CUDA) + applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); + testONNXModels("gru_cell_batchsize_1_seqlen_50", npy, 0, 0, false, false); +} + TEST_P(Test_ONNX_layers, GRU_bidirectional) { testONNXModels("gru_bi", npy, 0, 0, false, false); @@ -1323,6 +1365,27 @@ TEST_P(Test_ONNX_layers, LSTM_cell_with_peepholes) testONNXModels("lstm_cell_with_peepholes", npy, 0, 0, false, false); } +TEST_P(Test_ONNX_layers, LSTM_cell_batchsize_50_seqlen_1) +{ + if(backend == DNN_BACKEND_CUDA) + applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); + testONNXModels("lstm_cell_batchsize_50_seqlen_1", npy, 0, 0, false, false); +} + +TEST_P(Test_ONNX_layers, LSTM_cell_batchsize_1_seqlen_50) +{ + if(backend == DNN_BACKEND_CUDA) + applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); + testONNXModels("lstm_cell_batchsize_1_seqlen_50", npy, 0, 0, false, false); +} + +TEST_P(Test_ONNX_layers, LSTM_cell_batchsize_5_seqlen_5) +{ + if(backend == DNN_BACKEND_CUDA) + applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); + testONNXModels("lstm_cell_batchsize_5_seqlen_5", npy, 0, 0, false, false); +} + TEST_P(Test_ONNX_layers, Pad2d_Unfused) { testONNXModels("ReflectionPad2d");