From 806ce968998e2c7ff56fd18b19f522ce7ba41eb9 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Thu, 24 Feb 2022 19:41:47 +0300 Subject: [PATCH] Remove onnx_custom_op doc (#10638) * Remove onnx_custom_op doc * Remove test * Fixed tests --- cmake/test_model_zoo.cmake | 5 -- docs/CMakeLists.txt | 3 - docs/Doxyfile.config | 1 - docs/onnx_custom_op/CMakeLists.txt | 18 ------ .../onnx_custom_op/custom_relu_model.prototxt | 52 ----------------- docs/onnx_custom_op/onnx_custom_op.cpp | 57 ------------------- docs/onnx_custom_op/onnx_custom_op.hpp | 8 --- .../functional/plugin/cpu/CMakeLists.txt | 5 +- .../plugin/cpu/extension/extension.cpp | 32 ----------- 9 files changed, 1 insertion(+), 180 deletions(-) delete mode 100644 docs/onnx_custom_op/CMakeLists.txt delete mode 100644 docs/onnx_custom_op/custom_relu_model.prototxt delete mode 100644 docs/onnx_custom_op/onnx_custom_op.cpp delete mode 100644 docs/onnx_custom_op/onnx_custom_op.hpp diff --git a/cmake/test_model_zoo.cmake b/cmake/test_model_zoo.cmake index 176e1b55220..18442560350 100644 --- a/cmake/test_model_zoo.cmake +++ b/cmake/test_model_zoo.cmake @@ -86,11 +86,6 @@ ov_model_convert("${OpenVINO_SOURCE_DIR}/${rel_path}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_model_zoo/onnx_import" ie_onnx_import_out_files) -set(rel_path "docs/onnx_custom_op") -ov_model_convert("${OpenVINO_SOURCE_DIR}/${rel_path}" - "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_model_zoo/docs/models" - docs_onnx_out_files) - if(ENABLE_TESTS) if(ENABLE_OV_ONNX_FRONTEND AND ENABLE_REQUIREMENTS_INSTALL) find_package(PythonInterp 3 REQUIRED) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 1e0699b931d..75421a3c972 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -17,9 +17,6 @@ if(NOT ENABLE_DOCKER) set(OpenVINO_DIR ${CMAKE_BINARY_DIR}) endif() - if(ENABLE_OV_ONNX_FRONTEND) - add_subdirectory(onnx_custom_op) - endif() add_subdirectory(template_extension) set(all_docs_targets diff --git a/docs/Doxyfile.config b/docs/Doxyfile.config index 1538db98e38..5c076a4dfe6 100644 --- a/docs/Doxyfile.config +++ b/docs/Doxyfile.config @@ -1045,7 +1045,6 @@ EXCLUDE_SYMBOLS = InferenceEngine::details \ EXAMPLE_PATH = "@OpenVINO_SOURCE_DIR@" \ "@OpenVINO_SOURCE_DIR@/docs/HOWTO/" \ "@OpenVINO_SOURCE_DIR@/docs/" \ - "@OpenVINO_SOURCE_DIR@/docs/onnx_custom_op/" \ "@OpenVINO_SOURCE_DIR@/docs/template_extension/" \ "@OpenVINO_SOURCE_DIR@/docs/template_extension/old/" \ "@OpenVINO_SOURCE_DIR@/docs/template_extension/new/" \ diff --git a/docs/onnx_custom_op/CMakeLists.txt b/docs/onnx_custom_op/CMakeLists.txt deleted file mode 100644 index 2f2a77c58b7..00000000000 --- a/docs/onnx_custom_op/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2018-2022 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 -# - -# [cmake:onnx_custom_op] -set(CMAKE_CXX_STANDARD 11) - -set(TARGET_NAME "onnx_custom_op") - -find_package(OpenVINO REQUIRED COMPONENTS ONNX) - -add_library(${TARGET_NAME} STATIC onnx_custom_op.cpp onnx_custom_op.hpp) - -target_link_libraries(${TARGET_NAME} PUBLIC openvino::core openvino::frontend::onnx) -# [cmake:onnx_custom_op] - -# Enable code style check -add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) diff --git a/docs/onnx_custom_op/custom_relu_model.prototxt b/docs/onnx_custom_op/custom_relu_model.prototxt deleted file mode 100644 index 3845cc00ce2..00000000000 --- a/docs/onnx_custom_op/custom_relu_model.prototxt +++ /dev/null @@ -1,52 +0,0 @@ -ir_version: 3 -producer_name: "nGraph ONNX Importer" -graph { - node { - input: "in" - output: "out" - name: "customrelu" - op_type: "CustomRelu" - domain: "com.example" - attribute { - name: "alpha" - type: FLOAT - f: 2 - } - attribute { - name: "beta" - type: FLOAT - f: 3 - } - } - name: "custom relu graph" - input { - name: "in" - type { - tensor_type { - elem_type: 1 - shape { - dim { - dim_value: 8 - } - } - } - } - } - output { - name: "out" - type { - tensor_type { - elem_type: 1 - shape { - dim { - dim_value: 8 - } - } - } - } - } -} -opset_import { - domain: "com.example" - version: 1 -} diff --git a/docs/onnx_custom_op/onnx_custom_op.cpp b/docs/onnx_custom_op/onnx_custom_op.cpp deleted file mode 100644 index 399a6d2b4a3..00000000000 --- a/docs/onnx_custom_op/onnx_custom_op.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -//! [onnx_custom_op:headers] -// onnx_import/onnx_utils.hpp provides ngraph::onnx_import::register_operator function, that registers operator in ONNX importer's set. -#include -// ngraph/opsets/opset5.hpp provides the declaration of predefined nGraph operator set -#include -//! [onnx_custom_op:headers] - -void register_custom_relu_operator() { - // CustomRelu is defined as follows: - // x >= 0 => f(x) = x * alpha - // x < 0 => f(x) = x * beta - -//! [onnx_custom_op:register_operator] - ngraph::onnx_import::register_operator( - "CustomRelu", 1, "com.example", [](const ngraph::onnx_import::Node& onnx_node) -> ngraph::OutputVector { - namespace opset = ngraph::opset5; - - ngraph::OutputVector ng_inputs{onnx_node.get_ng_inputs()}; - const ngraph::Output& data = ng_inputs.at(0); - // create constant node with a single element that's equal to zero - std::shared_ptr zero_node = opset::Constant::create(data.get_element_type(), ngraph::Shape{}, {0}); - // create a negative map for 'data' node, 1 for negative values , 0 for positive values or zero - // then convert it from boolean type to `data.get_element_type()` - std::shared_ptr negative_map = std::make_shared( - std::make_shared(data, zero_node), data.get_element_type()); - // create a positive map for 'data' node, 0 for negative values , 1 for positive values or zero - // then convert it from boolean type to `data.get_element_type()` - std::shared_ptr positive_map = std::make_shared( - std::make_shared(data, zero_node), data.get_element_type()); - - // fetch alpha and beta attributes from ONNX node - float alpha = onnx_node.get_attribute_value("alpha", 1); // if 'alpha' attribute is not provided in the model, then the default value is 1 - float beta = onnx_node.get_attribute_value("beta"); - // create constant node with a single element 'alpha' with type f32 - std::shared_ptr alpha_node = opset::Constant::create(ngraph::element::f32, ngraph::Shape{}, {alpha}); - // create constant node with a single element 'beta' with type f32 - std::shared_ptr beta_node = opset::Constant::create(ngraph::element::f32, ngraph::Shape{}, {beta}); - - return { - std::make_shared( - std::make_shared(alpha_node, std::make_shared(data, positive_map)), - std::make_shared(beta_node, std::make_shared(data, negative_map)) - ) - }; - }); -//! [onnx_custom_op:register_operator] -} - -void unregister_custom_relu_operator() { -//! [onnx_custom_op:unregister_operator] - ngraph::onnx_import::unregister_operator("CustomRelu", 1, "com.example"); -//! [onnx_custom_op:unregister_operator] -} diff --git a/docs/onnx_custom_op/onnx_custom_op.hpp b/docs/onnx_custom_op/onnx_custom_op.hpp deleted file mode 100644 index 3554226da6b..00000000000 --- a/docs/onnx_custom_op/onnx_custom_op.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -void register_custom_relu_operator(); -void unregister_custom_relu_operator(); diff --git a/src/tests/functional/plugin/cpu/CMakeLists.txt b/src/tests/functional/plugin/cpu/CMakeLists.txt index 9ba753bea29..6af1b7155cd 100644 --- a/src/tests/functional/plugin/cpu/CMakeLists.txt +++ b/src/tests/functional/plugin/cpu/CMakeLists.txt @@ -12,12 +12,9 @@ set(INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} $ #include #include -#include #include #include -#include - class CustomAbsKernel : public InferenceEngine::ILayerExecImpl { public: @@ -152,23 +149,6 @@ static std::string model_full_path(const char* path) { return FileUtils::makePath(TEST_MODELS, path); } -TEST(Extension, OnnxModelWithCustomAbs) { - std::vector input_values{1, -2, 3, -4, 5, -6, 7, -8, 9, -10}; - std::vector expected{1, 4, 3, 8, 5, 12, 7, 16, 9, 20}; - InferenceEngine::Core ie; - ie.AddExtension(std::make_shared()); - ngraph::onnx_import::register_operator( - CustomAbs::get_type_info_static().name, 1, "custom_domain", [](const ngraph::onnx_import::Node& node) -> ngraph::OutputVector { - ngraph::OutputVector ng_inputs{node.get_ng_inputs()}; - return {std::make_shared(ng_inputs.at(0))}; - }); - - auto network = ie.ReadNetwork(model_full_path("func_tests/models/custom_abs_op.onnx")); - infer_model(ie, network, input_values, expected); - ngraph::onnx_import::unregister_operator(CustomAbs::get_type_info_static().name, 1, "custom_domain"); -} - - TEST(Extension, XmlModelWithCustomAbs) { std::string model = R"V0G0N( @@ -293,15 +273,3 @@ TEST(Extension, OnnxModelWithExtensionFromDSO) { auto network = ie.ReadNetwork(model_full_path("func_tests/models/custom_template_op.onnx")); infer_model(ie, network, input_values, expected); } - - -TEST(Extension, OnnxModelWithCustomReluDocsExample) { - std::vector input_values{0, -1, 2, -3, 4, -5, 6, -7}; - std::vector expected{0, -3, 4, -9, 8, -15, 12, -21}; - - register_custom_relu_operator(); - InferenceEngine::Core ie; - auto network = ie.ReadNetwork(model_full_path("docs/models/custom_relu_model.onnx")); - infer_model(ie, network, input_values, expected); - unregister_custom_relu_operator(); -}