[Core] Reference implementation for RGBtoNV12 and BGRtoNV12 operations - #34437
[Core] Reference implementation for RGBtoNV12 and BGRtoNV12 operations#34437mostafafaheem wants to merge 58 commits into
Conversation
|
Hello @riverlijunjie and @praasz, sorry for the large PR, I thought that splitting it into smaller PRs would not be suitable for the granularity of this task, however, once this PR is merged, I will submit another PR containing CPU plugin reference implementation, and hopefully extend the operation to the GPU plugin. |
There was a problem hiding this comment.
Pull request overview
Adds core ops and template-plugin reference support for RGB/BGR → NV12 conversion, and wires the conversion into the postprocessing pipeline (NV12 single-plane), with accompanying functional/type/visitor tests.
Changes:
- Introduce new opset16 operations
RGBtoNV12andBGRtoNV12(single-plane and two-plane outputs) with shape inference and reference implementation. - Enable evaluation/registration in the template plugin backend and add reference/functional tests.
- Extend postprocessing
convert_color()to support RGB/BGR →NV12_SINGLE_PLANE, plus new preprocess/postprocess tests.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/tests/test_utils/common_test_utils/include/common_test_utils/subgraph_builders/preprocess_builders.hpp | Adds postprocess subgraph builders for RGB/BGR → NV12 single-plane. |
| src/plugins/template/tests/functional/subgraph_reference/preprocess.cpp | Adds template-plugin reference preprocess tests for postprocess RGB/BGR → NV12. |
| src/plugins/template/tests/functional/op_reference/convert_color_to_nv12.cpp | Adds op-reference tests for RGBtoNV12/BGRtoNV12 (single/two-plane). |
| src/plugins/template/backend/opset_int_tbl.hpp | Registers new ops in the template plugin opset table. |
| src/plugins/template/backend/ops/ops_evaluates.hpp | Declares template-backend evaluate specializations for the new ops. |
| src/plugins/template/backend/ops/convert_color_to_nv12.cpp | Implements template-backend evaluation via the core reference function. |
| src/core/tests/visitors/op/convert_color_to_nv12.cpp | Adds visitor attribute tests for both ops and plane modes. |
| src/core/tests/type_prop/convert_color_to_nv12_base.hpp | Adds typed shape/type propagation tests for the new NV12 base op. |
| src/core/tests/type_prop/convert_color_to_nv12.cpp | Instantiates the new type-prop test suite for both ops. |
| src/core/tests/preprocess.cpp | Adds postprocess pipeline tests for RGB/BGR → NV12 single-plane and rejects two-plane. |
| src/core/src/preprocess/preprocess_steps_impl.cpp | Wires postprocess convert_color() to emit RGBtoNV12/BGRtoNV12 for NV12_SINGLE_PLANE. |
| src/core/src/op/util/convert_color_to_nv12_base.cpp | Implements validation/type inference for the NV12 base op. |
| src/core/src/op/rgb_to_nv12.cpp | Implements RGBtoNV12 op shell + cloning. |
| src/core/src/op/bgr_to_nv12.cpp | Implements BGRtoNV12 op shell + cloning. |
| src/core/shape_inference/include/rgb_bgr_to_nv12_shape_inference.hpp | Adds shape inference for RGB/BGR → NV12 (single/two-plane). |
| src/core/reference/include/openvino/reference/convert_color_to_nv12.hpp | Adds reference kernel for RGB/BGR → NV12 conversion. |
| src/core/include/openvino/opsets/opset16_tbl.hpp | Registers new ops in core opset16 table. |
| src/core/include/openvino/op/util/convert_color_to_nv12_base.hpp | Introduces the new base op API/attributes for RGB/BGR → NV12. |
| src/core/include/openvino/op/rgb_to_nv12.hpp | Adds public op header for RGBtoNV12. |
| src/core/include/openvino/op/ops.hpp | Exposes new op headers via umbrella include. |
| src/core/include/openvino/op/bgr_to_nv12.hpp | Adds public op header for BGRtoNV12. |
| src/core/docs/operation_enabling_flow.md | Updates documentation path for op implementation locations. |
|
Some builds are failing due to /__w/openvino/openvino/openvino/src/core/reference/include/openvino/reference/convert_color_to_nv12.hpp:18:36: error: no member named 'min' in namespace 'std'; did you mean 'fmin'?
18 | return static_cast<T>(std::min(std::max(std::round(a), 0.0), 255.0));Overall LGTM, thank you for your PR. Let's wait for more reviews, since this PR is quite big, I'm only covering a part of it. My approve is for the scope of shape infer, spec, type prop tests, reference tests and reference implementation. @riverlijunjie do you know if there's a model we can use to test the changes? |
|
build_jenkins |
|
build_jenkins |
p-durandin
left a comment
There was a problem hiding this comment.
@mostafafaheem please check CI errors:
CMake Error at cmake/developer_package/add_target_helpers.cmake:627 (message):
[ov_core_unit_tests]
'C:/actions-runner/_work/openvino/openvino/openvino/src/core/tests/type_prop/convert_color_to_nv12.cpp'
exists on disk but is not listed in target sources and will not be
compiled. Add it to the appropriate CMakeLists.txt or sources.cmake.
|
@p-durandin Fixed, please check |
|
build_jenkins |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
src/core/include/openvino/op/rgb_to_nv12.hpp:33
- [HIGH] These new public opset17 operations have no Python factory/export or Python graph tests. Unlike the existing opset17 operations and the inverse NV12 conversion ops, users cannot construct
rgb_to_nv12/bgr_to_nv12throughopenvino.opset17. Add wrappers with thesingle_planeattribute, export them fromopenvino.opset17, and cover both output modes.
class OPENVINO_API RGBtoNV12 : public util::ConvertColorToNV12Base {
public:
OPENVINO_OP("RGBtoNV12", "opset17", util::ConvertColorToNV12Base);
src/core/include/openvino/op/util/convert_color_to_nv12_base.hpp:49
- [MEDIUM] The base class registers itself as
ConvertColorToRGBBase, which is unrelated to its class and direction of conversion. This exposes incorrect runtime type metadata and risks a future type-info name collision. Register it asConvertColorToNV12Base, matching the class and establishedConvertColorNV12Base/ConvertColorI420Basenaming.
OPENVINO_OP("ConvertColorToRGBBase", "util");
|
build_jenkins |
|
build_jenkins |
Details:
Tickets:
AI Assistance: