opencv/modules/dnn/test
alexlyulkov 1d1faaabef
Merge pull request #24411 from alexlyulkov:al/dnn-type-inference
Added int32, int64 support and type inference to dnn #24411

**Added a type inference to dnn similar to the shape inference, added int32 and int64 support.**

- Added getTypes method for layers that calculates layer outputs types and internals types from inputs types (Similar to getMemoryShapes). By default outputs and internals types = input[0] type
- Added type inference pipeline similar to shape inference pipeline. LayersShapes struct (that is used in shape inference pipeline) now contains both shapes and types
- All layers output blobs are now allocated using the calculated types from the type inference.
- Inputs and constants with int32 and int64 types are not automatically converted into float32 now.
- Added int32 and int64 support for all the layers with indexing and for all the layers required in tests.

Added  int32 and int64 support for CUDA:
- Added host<->device data moving for int32 and int64
- Added int32 and int64 support for several layers (just slightly modified CUDA C++ templates)

Passed all the accuracy tests on CPU, OCL, OCL_FP16, CUDA, CUDA_FP16. (except RAFT model)

**CURRENT PROBLEMS**:
-  ONNX parser always converts int64 constants and layers attributes to int32, so some models with int64 constants doesn't work (e.g. RAFT). The solution is to disable int64->int32 conversion and fix attributes reading in a lot of ONNX layers parsers (https://github.com/opencv/opencv/issues/25102)
- I didn't add type inference and int support to VULCAN, so it doesn't work at all now.
- Some layers don't support int yet, so some unknown models may not work.

**CURRENT WORKAROUNDS**:
- CPU arg_layer indides are implemented in int32 followed by a int32->int64 conversion (the master branch has the same workaround with int32->float conversion)
- CPU and OCL pooling_layer indices are implemented in float followed by a float->int64 conversion
- CPU gather_layer indices are implemented in int32, so int64 indices are converted to int32 (the master branch has the same workaround with float->int32 conversion)

**DISABLED TESTS**:
- RAFT model

**REMOVED TESTS**:
- Greater_input_dtype_int64 (because it doesn't fit ONNX rules, the whole test is just comparing float tensor with int constant)

**TODO IN NEXT PULL REQUESTS**:
- Add int64 support for ONNX parser
- Add int support for more layers
- Add int support for OCL (currently int layers just run on CPU)
- Add int tests
- Add int support for other backends
2024-03-01 17:07:38 +03:00
..
imagenet_cls_test_alexnet.py python: better Python 3 support 2018-05-11 17:32:04 +03:00
imagenet_cls_test_googlenet.py Misc. modules/ typos 2018-02-12 07:09:43 -05:00
imagenet_cls_test_inception.py Merge branch 4.x 2021-12-30 21:43:45 +00:00
npy_blob.cpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00
npy_blob.hpp dnn: fix precomp.hpp usage 2018-02-28 17:06:26 +03:00
pascal_semsegm_test_fcn.py Merge branch 4.x 2023-01-09 11:08:02 +00:00
test_backends.cpp Relax test requirements for CUDA in DNNTestNetwork.FastNeuraStyle_eccv16 2024-02-12 14:47:37 +03:00
test_caffe_importer.cpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00
test_common.cpp Extracted 1d test cases to reduce conflicts with 4.x. 2024-02-29 12:02:00 +03:00
test_common.hpp Extracted 1d test cases to reduce conflicts with 4.x. 2024-02-29 12:02:00 +03:00
test_common.impl.hpp Merge pull request #24231 from fengyuentau:halide_cleanup_5.x 2023-10-13 16:53:18 +03:00
test_darknet_importer.cpp dnn(test): skip very long debug tests, reduce test time 2023-12-25 08:44:06 +00:00
test_googlenet.cpp Merge pull request #22275 from zihaomu:fp16_support_conv 2023-05-17 09:38:33 +03:00
test_graph_simplifier.cpp Merge pull request #24808 from fengyuentau:fix_layernorm 2024-01-10 13:01:00 +03:00
test_ie_models.cpp Merge pull request #24072 from dkurt:openvino_cpu_tests 2023-08-02 14:39:11 +03:00
test_int8_layers.cpp Merge pull request #24980 from fengyuentau:on-fly-quantization-removal 2024-02-16 18:21:45 +03:00
test_int.cpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00
test_layers_1d.cpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00
test_layers.cpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00
test_main.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
test_misc.cpp Merge branch 4.x 2024-01-23 17:06:52 +03:00
test_model.cpp Merge branch 4.x 2024-01-19 17:32:22 +03:00
test_nms.cpp batched nms impl 2022-11-29 15:32:34 +08:00
test_onnx_conformance_layer_filter__cuda_denylist.inl.hpp Merge pull request #24353 from alexlyulkov:al/fixed-cumsum-layer 2023-10-03 13:58:25 +03:00
test_onnx_conformance_layer_filter__openvino.inl.hpp Merge pull request #24610 from jimmylaw21:dnn-onnx-add-group-norm-layer 2024-01-12 15:13:26 +03:00
test_onnx_conformance_layer_filter__vulkan_denylist.inl.hpp Merge pull request #24092 from Aser-Abdelfatah:GSoC_Support_GatherElements_ONNX 2023-10-18 10:41:47 +03:00
test_onnx_conformance_layer_filter_opencv_all_denylist.inl.hpp Normalize axis parameter in DNN Concat to handle negative values. 2024-01-16 12:22:22 +03:00
test_onnx_conformance_layer_filter_opencv_cpu_denylist.inl.hpp Merge pull request #21865 from rogday:nary_eltwise_layers 2022-07-19 06:14:05 +03:00
test_onnx_conformance_layer_filter_opencv_denylist.inl.hpp move global skip out of if loop, and add opencv_deny_list 2023-03-13 22:16:51 +08:00
test_onnx_conformance_layer_filter_opencv_ocl_fp16_denylist.inl.hpp implementation of scatter and scatternd with conformance tests enabled 2022-10-17 11:30:32 +08:00
test_onnx_conformance_layer_filter_opencv_ocl_fp32_denylist.inl.hpp implementation of scatter and scatternd with conformance tests enabled 2022-10-17 11:30:32 +08:00
test_onnx_conformance_layer_parser_denylist.inl.hpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00
test_onnx_conformance.cpp Merge branch 4.x 2024-01-23 17:06:52 +03:00
test_onnx_importer.cpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00
test_precomp.hpp dnn: reduce set of ignored warnings 2018-11-15 13:15:59 +03:00
test_tf_importer.cpp dnn(test): skip very long debug tests, reduce test time 2023-12-25 08:44:06 +00:00
test_tflite_importer.cpp Merge pull request #24411 from alexlyulkov:al/dnn-type-inference 2024-03-01 17:07:38 +03:00