opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
75.69k stars 55.61k forks source link

Added int support for OpenVINO dnn backend #25458

Open alexlyulkov opened 1 week ago

alexlyulkov commented 1 week ago

Modified dnn OpenVINO integration to support type inference and int operations.

Added OpenVINO support to Cast, CumSum, Expand, Gather, GatherElements, Scatter, ScatterND, Tile layers. I tried to add Reduce layer, but looks like OpenVINO uses float values inside Reduce operation so it can't pass our int tests.

OpenVINO uses int32 precision for int64 operations, so I've modified input values for int64 tests when backend is OpenVINO.

OpenVINO has a strange behavior with custom layers and int64 values. After model compilation OpenVINO may change types, so the model can have different output type. That's why these tests were disabled:

Also these tests were temporary disabled, they didn't work on both 4.x and 5.x branches:

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

asmorkalov commented 6 days ago
[ RUN      ] Test_ONNX_conformance.Layer_Test/test_scatter_elements_with_negative_indices_NGRAPH_CPU, where GetParam() = (test_scatter_elements_with_negative_indices, NGRAPH/CPU)
Exception during net.forward() call!
unknown file: Failure
C++ exception with description "Check 'false' failed at src/inference/src/infer_request.cpp:215:
ScatterElementsUpdate node with name 'y' have indices value that points to non-existing output tensor element
" thrown in the test body.
[  FAILED  ] Test_ONNX_conformance.Layer_Test/test_scatter_elements_with_negative_indices_NGRAPH_CPU, where GetParam() = (test_scatter_elements_with_negative_indices, NGRAPH/CPU) (10 ms)
asmorkalov commented 6 days ago

Other failures are related to CI. I'll fix it and return back today.