From 5fd327ae3078396117b6971e8cb3fd268912ee3e Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 5 Sep 2023 15:41:57 +0400 Subject: [PATCH 01/31] Remove legacy API from IR frontend (#19582) * Remove legacy API from IR frontend * Remove dependency from inference dev API --- .../include/openvino/frontend/ir/frontend.hpp | 4 +- src/frontends/ir/src/CMakeLists.txt | 3 +- src/frontends/ir/src/frontend.cpp | 9 +- src/frontends/ir/src/input_model.cpp | 132 ++--- src/frontends/ir/src/ir_deserializer.cpp | 487 +++++++++--------- src/frontends/ir/src/ir_deserializer.hpp | 16 +- src/frontends/ir/src/rt_info_deserializer.cpp | 4 +- src/frontends/ir/src/utils.cpp | 121 ++++- src/frontends/ir/src/utils.hpp | 19 +- src/frontends/ir/tests/meta_data_tests.cpp | 3 +- .../functional/plugin/shared/CMakeLists.txt | 1 - 11 files changed, 484 insertions(+), 315 deletions(-) diff --git a/src/frontends/ir/include/openvino/frontend/ir/frontend.hpp b/src/frontends/ir/include/openvino/frontend/ir/frontend.hpp index b6719ab8a870e8..cd977a859f0d39 100644 --- a/src/frontends/ir/include/openvino/frontend/ir/frontend.hpp +++ b/src/frontends/ir/include/openvino/frontend/ir/frontend.hpp @@ -19,8 +19,8 @@ class IR_API FrontEnd : public ov::frontend::FrontEnd { FrontEnd() = default; /// \brief Completely convert the remaining, not converted part of a function. - /// \param partiallyConverted partially converted nGraph function - /// \return fully converted nGraph function + /// \param partiallyConverted partially converted ov::Model + /// \return fully converted ov::Model function std::shared_ptr convert(const InputModel::Ptr& model) const override; /// \brief Gets name of this FrontEnd. Can be used by clients diff --git a/src/frontends/ir/src/CMakeLists.txt b/src/frontends/ir/src/CMakeLists.txt index ad869bb967c7de..3d5e9465d39b6e 100644 --- a/src/frontends/ir/src/CMakeLists.txt +++ b/src/frontends/ir/src/CMakeLists.txt @@ -5,5 +5,4 @@ ov_add_frontend(NAME ir FILEDESCRIPTION "FrontEnd to load OpenVINO IR file format" LINK_LIBRARIES openvino::pugixml - # TODO: remove dependency below in CVS-69781 - openvino::runtime::dev) + openvino::core::dev) diff --git a/src/frontends/ir/src/frontend.cpp b/src/frontends/ir/src/frontend.cpp index 6420f69f41ad3c..8b8dca4d995ffb 100644 --- a/src/frontends/ir/src/frontend.cpp +++ b/src/frontends/ir/src/frontend.cpp @@ -5,6 +5,7 @@ #include "openvino/frontend/ir/frontend.hpp" #include +#include #include #include "input_model.hpp" @@ -15,9 +16,7 @@ #include "openvino/util/file_util.hpp" #include "openvino/util/mmap_object.hpp" #include "transformations/resolve_names_collisions.hpp" -#include "xml_parse_utils.h" - -using namespace ov; +#include "utils.hpp" namespace ov { namespace frontend { @@ -25,7 +24,7 @@ namespace ir { namespace { inline size_t get_ir_version(pugi::xml_node& root) { - return pugixml::utils::GetUIntAttr(root, "version", 0); + return static_cast(pugixml::utils::get_uint64_attr(root, "version", 0)); } /** @@ -265,7 +264,7 @@ IR_C_API ov::frontend::FrontEndVersion get_api_version() { } IR_C_API void* get_front_end_data() { - frontend::FrontEndPluginInfo* res = new frontend::FrontEndPluginInfo(); + ov::frontend::FrontEndPluginInfo* res = new ov::frontend::FrontEndPluginInfo(); res->m_name = "ir"; res->m_creator = []() { return std::make_shared(); diff --git a/src/frontends/ir/src/input_model.cpp b/src/frontends/ir/src/input_model.cpp index dc8e3d30292f28..2f58a68c94f89b 100644 --- a/src/frontends/ir/src/input_model.cpp +++ b/src/frontends/ir/src/input_model.cpp @@ -4,23 +4,25 @@ #include "input_model.hpp" -#include - -#include -#include -#include #include +#include "ir_deserializer.hpp" +#include "openvino/core/except.hpp" #include "openvino/core/validation_util.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/subtract.hpp" +#include "openvino/op/util/framework_node.hpp" +#include "openvino/op/util/variable.hpp" #include "openvino/opsets/opset.hpp" +#include "openvino/util/common_util.hpp" +#include "utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; - +OPENVINO_SUPPRESS_DEPRECATED_START namespace { void parse_pre_process(pugi::xml_node& root, std::shared_ptr weights, - std::shared_ptr f) { + std::shared_ptr model) { /* Preprocessing block can have two preprocessing types: * * @@ -44,14 +46,14 @@ void parse_pre_process(pugi::xml_node& root, } // find out to what input this belongs to std::string inputName; - std::shared_ptr input_node; + std::shared_ptr input_node; - inputName = pugixml::utils::GetStrAttr(ppNode, "reference-layer-name", ""); - inputName = trim(inputName); + inputName = pugixml::utils::get_str_attr(ppNode, "reference-layer-name", ""); + inputName = ov::util::trim(inputName); if (inputName.empty()) { // fallback (old format), look for the picture in the inputs - for (const auto& parameter : f->get_parameters()) { + for (const auto& parameter : model->get_parameters()) { if (parameter->get_partial_shape().rank().is_static() && parameter->get_partial_shape().rank().get_length() == 4) { input_node = parameter; @@ -59,14 +61,14 @@ void parse_pre_process(pugi::xml_node& root, } } - IE_ASSERT(!f->get_parameters().empty()); + OPENVINO_ASSERT(!model->get_parameters().empty()); if (!input_node) { - input_node = f->get_parameters()[0]; + input_node = model->get_parameters()[0]; } inputName = input_node->get_friendly_name(); } else { - for (const auto& parameter : f->get_parameters()) { + for (const auto& parameter : model->get_parameters()) { if (parameter->get_friendly_name() == inputName) { input_node = parameter; break; @@ -74,22 +76,19 @@ void parse_pre_process(pugi::xml_node& root, } } - if (!input_node) - IE_THROW() << "pre-process name ref '" << inputName << "' refers to un-existing input"; + OPENVINO_ASSERT(input_node, "pre-process name ref '", inputName, "' refers to un-existing input"); const auto& input_shape = input_node->output(0).get_partial_shape(); - if (input_shape.is_dynamic()) { - IE_THROW() << "can not apply pre-process for '" << inputName << "' input"; - } + OPENVINO_ASSERT(!input_shape.is_dynamic(), "can not apply pre-process for '", inputName, "' input"); - Shape mean_scalar_shape; // [C, 1 ... 1] - Shape mean_shape; // [1, H, W] - for 4D case + ov::Shape mean_scalar_shape; // [C, 1 ... 1] + ov::Shape mean_shape; // [1, H, W] - for 4D case const auto inputDims = input_shape.to_shape(); - if (inputDims.size() < 2) { - IE_THROW() << "network did not define input dimensions properly"; - } else if (inputDims.size() == 2) { // NC + OPENVINO_ASSERT(inputDims.size() >= 2, "network did not define input dimensions properly"); + + if (inputDims.size() == 2) { // NC mean_scalar_shape = {inputDims[1]}; mean_shape = {1}; } else if (inputDims.size() == 3) { // CHW - legacy representation for 3D input shape @@ -110,25 +109,29 @@ void parse_pre_process(pugi::xml_node& root, auto input_type = input_node->get_output_element_type(0); FOREACH_CHILD (chan, ppNode, "channel") { - auto chanNo = pugixml::utils::GetUInt64Attr(chan, "id", next_channel_id++); + auto chanNo = pugixml::utils::get_uint64_attr(chan, "id", next_channel_id++); auto meanNode = chan.child("mean"); if (!meanNode.empty()) { if (!meanNode.attribute("value") && (!meanNode.attribute("size"))) { - IE_THROW() << "mean should have at least one of the following attribute: value, size"; + OPENVINO_THROW("mean should have at least one of the following attribute: value, size"); } if (meanNode.attribute("value")) { - mean_scalar_values.insert({chanNo, pugixml::utils::GetFloatAttr(meanNode, "value")}); + mean_scalar_values.insert({chanNo, pugixml::utils::get_float_attr(meanNode, "value")}); } if (meanNode.attribute("size") && meanNode.attribute("offset")) { - auto const_size = pugixml::utils::GetUInt64Attr(meanNode, "size"); - auto const_offset = pugixml::utils::GetUInt64Attr(meanNode, "offset"); + auto const_size = pugixml::utils::get_uint64_attr(meanNode, "size"); + auto const_offset = pugixml::utils::get_uint64_attr(meanNode, "offset"); if (shape_size(mean_shape) * input_type.size() != const_size) { - IE_THROW() << "mean blob size mismatch expected input, got: " << const_size << " expecting " - << mean_shape << " x " << input_type.size(); + OPENVINO_THROW("mean blob size mismatch expected input, got: ", + const_size, + " expecting ", + mean_shape, + " x ", + input_type.size()); } if (const_offset + const_size > weights->size()) { - IE_THROW() << "mean value offset and size are out of weights size range"; + OPENVINO_THROW("mean value offset and size are out of weights size range"); } mean_values.insert({chanNo, {const_size, const_offset}}); } @@ -136,25 +139,28 @@ void parse_pre_process(pugi::xml_node& root, } if (!mean_values.empty() && !mean_scalar_values.empty()) { - IE_THROW() << "mean values have different types"; + OPENVINO_THROW("mean values have different types"); } if (!mean_scalar_values.empty()) { if (mean_scalar_values.size() != channels) { - IE_THROW() << "Number of mean values (" << mean_scalar_values.size() - << ") is not equal to number of channels (" << channels << ")"; + OPENVINO_THROW("Number of mean values (", + mean_scalar_values.size(), + ") is not equal to number of channels (", + channels, + ")"); } std::vector values(channels); for (const auto& item : mean_scalar_values) { if (item.first >= channels) { - IE_THROW() << "Mean values channel index " << item.first << " is out of range (" << channels << ")"; + OPENVINO_THROW("Mean values channel index ", item.first, " is out of range (", channels, ")"); } values[item.first] = item.second; } - auto mean_values_constant = ngraph::op::Constant::create(input_type, mean_scalar_shape, values); + auto mean_values_constant = ov::op::v0::Constant::create(input_type, mean_scalar_shape, values); const auto& consumers = input_node->output(0).get_target_inputs(); - auto add = std::make_shared(input_node, mean_values_constant); + auto add = std::make_shared(input_node, mean_values_constant); for (const auto& consumer : consumers) { consumer.replace_source_output(add); } @@ -162,35 +168,38 @@ void parse_pre_process(pugi::xml_node& root, if (!mean_values.empty()) { if (mean_values.size() != channels) { - IE_THROW() << "Number of mean values (" << mean_values.size() << ") is not equal to number of channels (" - << channels << ")"; + OPENVINO_THROW("Number of mean values (", + mean_values.size(), + ") is not equal to number of channels (", + channels, + ")"); } - NodeVector per_channel_values(channels); + ov::NodeVector per_channel_values(channels); for (const auto& item : mean_values) { if (item.first >= channels) { - IE_THROW() << "Mean values channel index " << item.first << " is out of range (" << channels << ")"; + OPENVINO_THROW("Mean values channel index ", item.first, " is out of range (", channels, ")"); } const size_t offset = item.second.second; const char* data = weights->get_ptr() + offset; - per_channel_values[item.first] = ngraph::opset1::Constant::create(input_type, mean_shape, data); + per_channel_values[item.first] = ov::op::v0::Constant::create(input_type, mean_shape, data); } - OPENVINO_SUPPRESS_DEPRECATED_START - auto const_node = get_constant_from_source(std::make_shared(per_channel_values, 0)); - OPENVINO_SUPPRESS_DEPRECATED_END - IE_ASSERT(const_node); + auto const_node = get_constant_from_source(std::make_shared(per_channel_values, 0)); + OPENVINO_ASSERT(const_node); const auto& consumers = input_node->output(0).get_target_inputs(); - auto add = std::make_shared(input_node, const_node); + auto add = std::make_shared(input_node, const_node); for (const auto& consumer : consumers) { consumer.replace_source_output(add); } } } } // namespace +OPENVINO_SUPPRESS_DEPRECATED_END namespace ov { namespace frontend { namespace ir { +OPENVINO_SUPPRESS_DEPRECATED_START class InputModel::InputModelIRImpl { std::shared_ptr m_weights; std::unordered_map m_extensions; @@ -206,7 +215,7 @@ class InputModel::InputModelIRImpl { m_extensions(extensions) { pugi::xml_parse_result res = m_xml_doc.load(stream); if (res.status != pugi::status_ok) { - IE_THROW() << res.description() << " at offset " << res.offset; + OPENVINO_THROW(res.description(), " at offset ", res.offset); } m_root = m_xml_doc.document_element(); for (const auto& it : ov::get_available_opsets()) { @@ -214,7 +223,7 @@ class InputModel::InputModelIRImpl { } } - std::shared_ptr convert(); + std::shared_ptr convert(); }; InputModel::InputModel(std::istream& stream, @@ -222,23 +231,24 @@ InputModel::InputModel(std::istream& stream, const std::unordered_map& extensions) { _impl = std::make_shared(stream, weights, extensions); } +OPENVINO_SUPPRESS_DEPRECATED_END -std::shared_ptr InputModel::convert() { +std::shared_ptr InputModel::convert() { return _impl->convert(); } -std::shared_ptr InputModel::InputModelIRImpl::convert() { - std::unordered_map> variables; +std::shared_ptr InputModel::InputModelIRImpl::convert() { + std::unordered_map> variables; // Load default opsets - size_t version = pugixml::utils::GetUIntAttr(m_root, "version", 0); + size_t version = static_cast(pugixml::utils::get_uint64_attr(m_root, "version", 0)); ov::XmlDeserializer visitor(m_root, m_weights, m_opsets, m_extensions, variables, version); - std::shared_ptr function; - visitor.on_attribute("net", function); - function->get_rt_info()["version"] = int64_t(version); - parse_pre_process(m_root, m_weights, function); + std::shared_ptr model; + visitor.on_attribute("net", model); + model->get_rt_info()["version"] = int64_t(version); + parse_pre_process(m_root, m_weights, model); - return function; + return model; } } // namespace ir diff --git a/src/frontends/ir/src/ir_deserializer.cpp b/src/frontends/ir/src/ir_deserializer.cpp index 56aa587ee44adf..42be66281d5d24 100644 --- a/src/frontends/ir/src/ir_deserializer.cpp +++ b/src/frontends/ir/src/ir_deserializer.cpp @@ -7,45 +7,51 @@ #include #include -#include "ie_ngraph_utils.hpp" -#include "ngraph/op/util/framework_node.hpp" -#include "ngraph/opsets/opset1.hpp" +#include "ngraph/runtime/shared_buffer.hpp" #include "openvino/core/except.hpp" #include "openvino/core/meta_data.hpp" +#include "openvino/core/type/element_type.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/loop.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/util/assign_base.hpp" +#include "openvino/op/util/framework_node.hpp" +#include "openvino/op/util/read_value_base.hpp" +#include "openvino/op/util/sub_graph_base.hpp" +#include "openvino/op/util/variable.hpp" #include "rt_info_deserializer.hpp" #include "transformations/rt_info/attributes.hpp" #include "utils.hpp" -#include "xml_parse_utils.h" -using namespace ov; - -XmlDeserializer::IoMap XmlDeserializer::updated_io_map(const pugi::xml_node& node, const pugi::xml_node& body_node) { +ov::XmlDeserializer::IoMap ov::XmlDeserializer::updated_io_map(const pugi::xml_node& node, + const pugi::xml_node& body_node) { if (body_node.empty()) { - IE_THROW() << "Missing body part."; + OPENVINO_THROW("Missing body part."); } // Fill map: parameter/result id to parameter/result number in Function auto extend_io_map = io_map; FOREACH_CHILD (layer, body_node.child("layers"), "layer") { - auto type = pugixml::utils::GetStrAttr(layer, "type"); + auto type = pugixml::utils::get_str_attr(layer, "type"); if (type == "Parameter") { - auto id = pugixml::utils::GetUIntAttr(layer, "id"); + auto id = static_cast(pugixml::utils::get_uint64_attr(layer, "id")); extend_io_map.inputs.insert({id, -1}); // try add as unconnected } else if (type == "Result") { - auto id = pugixml::utils::GetUIntAttr(layer, "id"); + auto id = static_cast(pugixml::utils::get_uint64_attr(layer, "id")); extend_io_map.outputs.insert({id, -1}); // try add as unconnected } } return extend_io_map; } -std::vector> XmlDeserializer::parse_input_description( +std::vector> ov::XmlDeserializer::parse_input_description( const pugi::xml_node& node, const std::string& body_name, const std::string& port_map_name) { - std::vector> inputs; + std::vector> inputs; auto body_node = node.child(body_name.c_str()); const auto up_io_map = updated_io_map(node, body_node); @@ -53,49 +59,49 @@ std::vector> Xml // Parse PortMap: external_port_id for inputs does not always appear in consecutive order std::map input_map; FOREACH_CHILD (input, node.child(port_map_name.c_str()), "input") { - int64_t ext_port_id = pugixml::utils::GetInt64Attr(input, "external_port_id"); + int64_t ext_port_id = pugixml::utils::get_int64_attr(input, "external_port_id"); input_map.emplace(ext_port_id, input); } for (const auto& input : input_map) { auto& xml_input = input.second; auto axis_attr = xml_input.attribute("axis"); - int64_t ti_input_index = pugixml::utils::GetInt64Attr(xml_input, "external_port_id"); - size_t body_parameter_index = pugixml::utils::GetUIntAttr(xml_input, "internal_layer_id"); + int64_t ti_input_index = pugixml::utils::get_int64_attr(xml_input, "external_port_id"); + size_t body_parameter_index = + static_cast(pugixml::utils::get_uint64_attr(xml_input, "internal_layer_id")); - // if axis is set, then slicing is enabled. Create ngraph::TensorIterator::SlicedInput. + // if axis is set, then slicing is enabled. Create ov::TensorIterator::SlicedInput. if (!axis_attr.empty()) { - size_t axis = pugixml::utils::GetUIntAttr(xml_input, "axis"); - int64_t start = pugixml::utils::GetInt64Attr(xml_input, "start", 0); - int64_t stride = pugixml::utils::GetInt64Attr(xml_input, "stride", 1); - int64_t end = pugixml::utils::GetInt64Attr(xml_input, "end", -1); - int64_t part_size = pugixml::utils::GetInt64Attr(xml_input, "part_size", 1); + size_t axis = static_cast(pugixml::utils::get_uint64_attr(xml_input, "axis")); + int64_t start = pugixml::utils::get_int64_attr(xml_input, "start", 0); + int64_t stride = pugixml::utils::get_int64_attr(xml_input, "stride", 1); + int64_t end = pugixml::utils::get_int64_attr(xml_input, "end", -1); + int64_t part_size = pugixml::utils::get_int64_attr(xml_input, "part_size", 1); const auto input_index = up_io_map.inputs.at(body_parameter_index); - inputs.push_back(std::make_shared(ti_input_index, - input_index, - start, - stride, - part_size, - end, - axis)); + inputs.push_back(std::make_shared(ti_input_index, + input_index, + start, + stride, + part_size, + end, + axis)); } else { - // otherwise find corresponding back edge and create ngraph::TensorIterator::MergedInput + // otherwise find corresponding back edge and create ov::TensorIterator::MergedInput bool is_back_edge_exist = false; FOREACH_CHILD (xml_edge, node.child("back_edges"), "edge") { - size_t to_layer = pugixml::utils::GetUIntAttr(xml_edge, "to-layer"); + size_t to_layer = static_cast(pugixml::utils::get_uint64_attr(xml_edge, "to-layer")); if (to_layer == body_parameter_index) { - size_t from_layer = pugixml::utils::GetUIntAttr(xml_edge, "from-layer"); + size_t from_layer = static_cast(pugixml::utils::get_uint64_attr(xml_edge, "from-layer")); const auto input_index = up_io_map.inputs.at(body_parameter_index); const auto output_index = up_io_map.outputs.at(from_layer); - inputs.push_back( - std::make_shared(ti_input_index, - input_index, - output_index)); + inputs.push_back(std::make_shared(ti_input_index, + input_index, + output_index)); is_back_edge_exist = true; break; @@ -108,26 +114,25 @@ std::vector> Xml const auto input_index = up_io_map.inputs.at(body_parameter_index); inputs.push_back( - std::make_shared(ti_input_index, - input_index)); + std::make_shared(ti_input_index, input_index)); } } } return inputs; } -std::vector> -XmlDeserializer::parse_output_description(const pugi::xml_node& node, - const std::string& body_name, - const std::string& port_map_name) { - std::vector> outputs; +std::vector> +ov::XmlDeserializer::parse_output_description(const pugi::xml_node& node, + const std::string& body_name, + const std::string& port_map_name) { + std::vector> outputs; auto body_node = node.child(body_name.c_str()); const auto up_io_map = updated_io_map(node, body_node); // Parse PortMap: outputs std::map output_map; FOREACH_CHILD (output, node.child(port_map_name.c_str()), "output") { - int64_t ext_port_id = pugixml::utils::GetInt64Attr(output, "external_port_id"); + int64_t ext_port_id = pugixml::utils::get_int64_attr(output, "external_port_id"); output_map.emplace(ext_port_id, output); } @@ -135,38 +140,38 @@ XmlDeserializer::parse_output_description(const pugi::xml_node& node, for (const auto& output : output_map) { auto& xml_output = output.second; auto axis_attr = xml_output.attribute("axis"); - size_t body_result_index = pugixml::utils::GetUIntAttr(xml_output, "internal_layer_id"); + size_t body_result_index = + static_cast(pugixml::utils::get_uint64_attr(xml_output, "internal_layer_id")); // if external_port_id < 0 it means that this body result isn't connected to the Loop output // and is used only for internal needs. For TensorIterator external_port_id is always > 0. - if (pugixml::utils::GetInt64Attr(xml_output, "external_port_id") >= 0) { + if (pugixml::utils::get_int64_attr(xml_output, "external_port_id") >= 0) { // if axis is set, then concatenation is enabled. Create - // ngraph::TensorIterator::ConcatOutput. + // ov::TensorIterator::ConcatOutput. if (!axis_attr.empty()) { - int64_t axis = pugixml::utils::GetInt64Attr(xml_output, "axis"); - int64_t start = pugixml::utils::GetInt64Attr(xml_output, "start", 0); - int64_t stride = pugixml::utils::GetInt64Attr(xml_output, "stride", 1); - int64_t end = pugixml::utils::GetInt64Attr(xml_output, "end", -1); - int64_t part_size = pugixml::utils::GetInt64Attr(xml_output, "part_size", 1); + int64_t axis = pugixml::utils::get_int64_attr(xml_output, "axis"); + int64_t start = pugixml::utils::get_int64_attr(xml_output, "start", 0); + int64_t stride = pugixml::utils::get_int64_attr(xml_output, "stride", 1); + int64_t end = pugixml::utils::get_int64_attr(xml_output, "end", -1); + int64_t part_size = pugixml::utils::get_int64_attr(xml_output, "part_size", 1); const auto output_index = up_io_map.outputs.at(body_result_index); outputs.push_back( - std::make_shared(output_index, - output_number, - start, - stride, - part_size, - end, - axis)); + std::make_shared(output_index, + output_number, + start, + stride, + part_size, + end, + axis)); } else { - // otherwise create ngraph::TensorIterator::BodyOutput. -1 means last iteration. + // otherwise create ov::TensorIterator::BodyOutput. -1 means last iteration. const auto output_index = up_io_map.outputs.at(body_result_index); - outputs.push_back( - std::make_shared(output_index, - output_number, - -1)); + outputs.push_back(std::make_shared(output_index, + output_number, + -1)); } output_number++; } @@ -174,31 +179,32 @@ XmlDeserializer::parse_output_description(const pugi::xml_node& node, return outputs; } -ngraph::op::v5::Loop::SpecialBodyPorts XmlDeserializer::parse_purpose_attribute(const pugi::xml_node& node) { - ngraph::op::v5::Loop::SpecialBodyPorts result = {-1, -1}; +ov::op::v5::Loop::SpecialBodyPorts ov::XmlDeserializer::parse_purpose_attribute(const pugi::xml_node& node) { + ov::op::v5::Loop::SpecialBodyPorts result = {-1, -1}; auto body_node = node.child("body"); const auto up_io_map = updated_io_map(node, body_node); - NGRAPH_CHECK(!up_io_map.inputs.empty() || !up_io_map.outputs.empty(), - "No parameters or results found in body Model."); + OPENVINO_ASSERT(!up_io_map.inputs.empty() || !up_io_map.outputs.empty(), + "No parameters or results found in body Model."); // Parse PortMap: external_port_id for inputs/outputs does not always appear in consecutive // order std::map input_map; FOREACH_CHILD (input, node.child("port_map"), "input") { - int64_t ext_port_id = pugixml::utils::GetInt64Attr(input, "external_port_id"); + int64_t ext_port_id = pugixml::utils::get_int64_attr(input, "external_port_id"); input_map.emplace(ext_port_id, input); } std::map output_map; FOREACH_CHILD (output, node.child("port_map"), "output") { - int64_t ext_port_id = pugixml::utils::GetInt64Attr(output, "external_port_id"); + int64_t ext_port_id = pugixml::utils::get_int64_attr(output, "external_port_id"); output_map.emplace(ext_port_id, output); } for (const auto& input : input_map) { auto& xml_input = input.second; - auto purpose = pugixml::utils::GetStrAttr(xml_input, "purpose", ""); - size_t body_parameter_index = pugixml::utils::GetUIntAttr(xml_input, "internal_layer_id"); + auto purpose = pugixml::utils::get_str_attr(xml_input, "purpose", ""); + size_t body_parameter_index = + static_cast(pugixml::utils::get_uint64_attr(xml_input, "internal_layer_id")); if (purpose == "current_iteration") { result.current_iteration_input_idx = up_io_map.inputs.at(body_parameter_index); } @@ -206,8 +212,9 @@ ngraph::op::v5::Loop::SpecialBodyPorts XmlDeserializer::parse_purpose_attribute( for (const auto& output : output_map) { auto& xml_output = output.second; - auto purpose = pugixml::utils::GetStrAttr(xml_output, "purpose", ""); - size_t body_parameter_index = pugixml::utils::GetUIntAttr(xml_output, "internal_layer_id"); + auto purpose = pugixml::utils::get_str_attr(xml_output, "purpose", ""); + size_t body_parameter_index = + static_cast(pugixml::utils::get_uint64_attr(xml_output, "internal_layer_id")); if (purpose == "execution_condition") { result.body_condition_output_idx = up_io_map.outputs.at(body_parameter_index); } @@ -216,7 +223,7 @@ ngraph::op::v5::Loop::SpecialBodyPorts XmlDeserializer::parse_purpose_attribute( return result; } -void XmlDeserializer::on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) { +void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor& adapter) { static const std::unordered_set skip_names = {"input_descriptions", "output_descriptions", "special_body_ports", @@ -237,91 +244,91 @@ void XmlDeserializer::on_adapter(const std::string& name, ngraph::ValueAccessor< body_name = "else_body"; port_map_name = "else_port_map"; } - if (auto a = ngraph::as_type>>>(&adapter)) { + if (auto a = ov::as_type< + ov::AttributeAdapter>>>( + &adapter)) { a->set(parse_input_description(m_node, body_name, port_map_name)); - } else if (auto a = ngraph::as_type>>>(&adapter)) { + } else if (auto a = ov::as_type>>>(&adapter)) { a->set(parse_output_description(m_node, body_name, port_map_name)); - } else if (auto a = - ngraph::as_type>(&adapter)) { + } else if (auto a = ov::as_type>(&adapter)) { a->set(parse_purpose_attribute(m_node)); } } if (skip_names.count(name) && !getStrAttribute(m_node.child("data"), name, val)) return; - if (auto a = ngraph::as_type>(&adapter)) { - static_cast(*a) = InferenceEngine::details::convertPrecision(val); - } else if (auto a = ngraph::as_type>(&adapter)) { + OPENVINO_SUPPRESS_DEPRECATED_START + if (auto a = ov::as_type>(&adapter)) { + static_cast(*a) = ov::element::Type(val); + } else if (auto a = ov::as_type>(&adapter)) { PartialShape shape; if (!get_partial_shape_from_attribute(m_node.child("data"), name, shape)) return; a->set(shape); - } else if (auto a = ngraph::as_type>(&adapter)) { + } else if (auto a = ov::as_type>(&adapter)) { Dimension dim; if (!get_dimension_from_attribute(m_node.child("data"), name, dim)) return; a->set(dim); - } else if (auto a = ngraph::as_type>(&adapter)) { + } else if (auto a = ov::as_type>(&adapter)) { std::vector shape; if (!getParameters(m_node.child("data"), name, shape)) return; - static_cast(*a) = ngraph::Shape(shape); - } else if (auto a = ngraph::as_type>(&adapter)) { + static_cast(*a) = ov::Shape(shape); + } else if (auto a = ov::as_type>(&adapter)) { std::vector shape; if (!getParameters(m_node.child("data"), name, shape)) return; - static_cast(*a) = ngraph::Strides(shape); + static_cast(*a) = ov::Strides(shape); #if defined(__APPLE__) || defined(__EMSCRIPTEN__) - } else if (auto a = ngraph::as_type>>(&adapter)) { + } else if (auto a = ov::as_type>>(&adapter)) { std::vector result; if (!getParameters(m_node.child("data"), name, result)) return; static_cast&>(*a) = result; #else - } else if (auto a = ngraph::as_type>>(&adapter)) { + } else if (auto a = ov::as_type>>(&adapter)) { std::vector result; if (!getParameters(m_node.child("data"), name, result)) return; a->set(result); #endif - } else if (auto a = ngraph::as_type>(&adapter)) { + } else if (auto a = ov::as_type>(&adapter)) { std::vector axes; if (!getParameters(m_node.child("data"), name, axes)) return; - static_cast(*a) = ngraph::AxisSet(axes); - } else if (auto a = ngraph::as_type>(&adapter)) { + static_cast(*a) = ov::AxisSet(axes); + } else if (auto a = ov::as_type>(&adapter)) { if (!getStrAttribute(m_node.child("data"), name, val)) return; - static_cast(*a) = ngraph::as_enum(val); - } else if (auto a = ngraph::as_type>(&adapter)) { + static_cast(*a) = ov::as_enum(val); + } else if (auto a = ov::as_type>(&adapter)) { if (!getStrAttribute(m_node.child("data"), name, val)) return; - static_cast(*a) = ngraph::as_enum(val); - } else if (auto a = ngraph::as_type>(&adapter)) { + static_cast(*a) = ov::as_enum(val); + } else if (auto a = ov::as_type>(&adapter)) { std::vector shape; if (!getParameters(m_node.child("data"), name, shape)) return; std::vector coord_diff(shape.begin(), shape.end()); - static_cast(*a) = ngraph::CoordinateDiff(coord_diff); - } else if (auto a = ngraph::as_type>>(&adapter)) { + static_cast(*a) = ov::CoordinateDiff(coord_diff); + } else if (auto a = ov::as_type>>(&adapter)) { std::string variable_id; if (!getStrAttribute(m_node.child("data"), name, variable_id)) return; if (!m_variables.count(variable_id)) { - m_variables[variable_id] = std::make_shared( - ngraph::VariableInfo{ngraph::PartialShape::dynamic(), ngraph::element::dynamic, variable_id}); + m_variables[variable_id] = std::make_shared( + ov::op::util::VariableInfo{ov::PartialShape::dynamic(), ov::element::dynamic, variable_id}); } a->set(m_variables[variable_id]); - } else if (auto a = ngraph::as_type>>( - &adapter)) { + } else if (auto a = ov::as_type>>(&adapter)) { std::string value; pugi::xml_node dn = m_node.child("data"); - auto type = pugixml::utils::GetStrAttr(m_node, "type"); + auto type = pugixml::utils::get_str_attr(m_node, "type"); if (dn.empty()) - IE_THROW() << "No attrtibutes defined for " << type << " op!"; + OPENVINO_THROW("No attrtibutes defined for ", type, " op!"); if (getStrAttribute(dn, name, value)) { auto buffer = std::make_shared(value.size()); @@ -332,21 +339,21 @@ void XmlDeserializer::on_adapter(const std::string& name, ngraph::ValueAccessor< std::vector shape; std::string el_type_str; - size_t offset = pugixml::utils::GetUInt64Attr(dn, "offset"); - size_t size = pugixml::utils::GetUInt64Attr(dn, "size"); + size_t offset = static_cast(pugixml::utils::get_uint64_attr(dn, "offset")); + size_t size = static_cast(pugixml::utils::get_uint64_attr(dn, "size")); if (!getStrAttribute(dn, "element_type", el_type_str)) return; if (!getParameters(dn, "shape", shape)) return; - ngraph::element::Type el_type = InferenceEngine::details::convertPrecision(el_type_str); + ov::element::Type el_type = ov::element::Type(el_type_str); if (!m_weights) - IE_THROW() << "Empty weights data in bin file or bin file cannot be found!"; + OPENVINO_THROW("Empty weights data in bin file or bin file cannot be found!"); if (m_weights->size() < offset + size) - IE_THROW() << "Incorrect weights in bin file!"; - if (size < ((ngraph::shape_size(shape) * el_type.bitwidth() + 7) >> 3)) - IE_THROW() << "Attribute and shape size are inconsistent for " << type << " op!"; + OPENVINO_THROW("Incorrect weights in bin file!"); + if (size < ((ov::shape_size(shape) * el_type.bitwidth() + 7) >> 3)) + OPENVINO_THROW("Attribute and shape size are inconsistent for ", type, " op!"); char* data = m_weights->get_ptr() + offset; auto buffer = @@ -356,11 +363,11 @@ void XmlDeserializer::on_adapter(const std::string& name, ngraph::ValueAccessor< m_weights); a->set(buffer); } - } else if (auto a = ngraph::as_type>(&adapter)) { - const auto& type = pugixml::utils::GetStrAttr(m_node, "type"); - const auto& version = pugixml::utils::GetStrAttr(m_node, "version"); + } else if (auto a = ov::as_type>(&adapter)) { + const auto& type = pugixml::utils::get_str_attr(m_node, "type"); + const auto& version = pugixml::utils::get_str_attr(m_node, "version"); - ngraph::op::FrameworkNodeAttrs node_attrs; + ov::op::util::FrameworkNodeAttrs node_attrs; node_attrs.set_opset_name(version); node_attrs.set_type_name(type); @@ -373,45 +380,46 @@ void XmlDeserializer::on_adapter(const std::string& name, ngraph::ValueAccessor< } a->set(node_attrs); - } else if (const auto& a = ngraph::as_type>(&adapter)) { - ngraph::element::TypeVector types; - if (!getParameters(m_node.child("data"), name, types)) + } else if (const auto& a = ov::as_type>(&adapter)) { + ov::element::TypeVector types; + if (!getParameters(m_node.child("data"), name, types)) return; a->set(types); } else { - IE_THROW() << "Error IR reading. Attribute adapter can not be found for " << name << " parameter"; + OPENVINO_THROW("Error IR reading. Attribute adapter can not be found for ", name, " parameter"); } + OPENVINO_SUPPRESS_DEPRECATED_END } -void XmlDeserializer::on_adapter(const std::string& name, - ngraph::ValueAccessor>& adapter) { - std::shared_ptr ngraph_function; +void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor>& adapter) { + std::shared_ptr model; io_map = {}; if (!name.compare("body") || !name.compare("then_body") || !name.compare("else_body")) { auto body_node = m_node.child(name.c_str()); if (body_node.empty()) { - IE_THROW() << "TensorIterator has no body."; + OPENVINO_THROW("TensorIterator has no body."); } - ngraph_function = parse_function(m_node.child(name.c_str()), m_weights); + model = parse_function(m_node.child(name.c_str()), m_weights); } else if (!name.compare("net")) { - ngraph_function = parse_function(m_node, m_weights); + model = parse_function(m_node, m_weights); } else { - IE_THROW() << "Error: not recognized adapter name: " << name << "."; + OPENVINO_THROW("Error: not recognized adapter name: ", name, "."); } - adapter.set(ngraph_function); + adapter.set(model); } -std::shared_ptr XmlDeserializer::parse_function( +OPENVINO_SUPPRESS_DEPRECATED_START +std::shared_ptr ov::XmlDeserializer::parse_function( const pugi::xml_node& root, const std::shared_ptr& weights) { // OV_ITT_SCOPE_CHAIN(FIRST_INFERENCE, taskChain, itt::domains::V10Reader_RT, "V10Parser", "Parse"); struct FunctionNodes { - ngraph::ParameterVector parameters; - ngraph::ResultVector results; - ngraph::NodeVector all; - ngraph::SinkVector sinks; + ov::ParameterVector parameters; + ov::ResultVector results; + ov::NodeVector all; + ov::SinkVector sinks; }; struct Edge { @@ -434,7 +442,7 @@ std::shared_ptr XmlDeserializer::parse_function( FOREACH_CHILD (node, root.child("layers"), "layer") { auto node_param = parse_generic_params(node); if (opName.find(node_param.name) != opName.end() && node_param.type != "Result") - IE_THROW() << "Invalid IR! " << node_param.name << " name is not unique!"; + OPENVINO_THROW("Invalid IR! ", node_param.name, " name is not unique!"); opName.insert(node_param.name); params[node_param.layerId] = {node, node_param}; if (node_param.type == "Result" || node_param.type == "Assign") { @@ -451,10 +459,10 @@ std::shared_ptr XmlDeserializer::parse_function( // Read all edges and store them for further usage FOREACH_CHILD (_ec, root.child("edges"), "edge") { - size_t fromLayer = pugixml::utils::GetUIntAttr(_ec, "from-layer"); - size_t fromPort = pugixml::utils::GetUIntAttr(_ec, "from-port"); - size_t toLayer = pugixml::utils::GetUIntAttr(_ec, "to-layer"); - size_t toPort = pugixml::utils::GetUIntAttr(_ec, "to-port"); + size_t fromLayer = static_cast(pugixml::utils::get_uint64_attr(_ec, "from-layer")); + size_t fromPort = static_cast(pugixml::utils::get_uint64_attr(_ec, "from-port")); + size_t toLayer = static_cast(pugixml::utils::get_uint64_attr(_ec, "to-layer")); + size_t toPort = static_cast(pugixml::utils::get_uint64_attr(_ec, "to-port")); edges[toLayer].push_back({fromLayer, fromPort, toPort}); } @@ -470,76 +478,64 @@ std::shared_ptr XmlDeserializer::parse_function( }; std::for_each(outputs.begin(), outputs.end(), dfs); - // OV_ITT_SCOPE_NEXT(FIRST_INFERENCE, taskChain, "ConstructNgraphNodes"); - FunctionNodes func_nodes; - std::map> id_to_node; - std::map> variable_id_to_read_value; + std::map> id_to_node; + std::map> variable_id_to_read_value; - // Following topological order create nGraph operations + // Following topological order create OpenVINO operations for (auto& layer_id : order) { auto& p = params[layer_id]; const auto& edgeIt = edges.find(layer_id); if (edgeIt == edges.end()) continue; - ngraph::OutputVector inputs(edgeIt->second.size()); + ov::OutputVector inputs(edgeIt->second.size()); for (auto& e : edgeIt->second) { auto input_node = id_to_node[e.fromLayerId]; if (!input_node) { - IE_THROW() << "Attempt to access node " << e.fromLayerId << " that not in graph."; + OPENVINO_THROW("Attempt to access node ", e.fromLayerId, " that not in graph."); } auto& p_output = params[e.fromLayerId].params; size_t const realInputPortId = p.params.get_real_input_port_id(e.toPortId); if (realInputPortId >= inputs.size()) - IE_THROW() << p.params.type << " layer " << p.params.name << " with id: " << p.params.layerId - << " is inconsistent!"; + OPENVINO_THROW(p.params.type, + " layer ", + p.params.name, + " with id: ", + p.params.layerId, + " is inconsistent!"); inputs[realInputPortId] = input_node->output(p_output.get_real_output_port_id(e.fromPortId)); } auto node = create_node(inputs, p.xml, weights, p.params); id_to_node[layer_id] = node; - // Check that output shape after OpenVINO node validation the same as in IR - // because IR always right! - // Temporary disabled! - // for (size_t i = 0; i < p.params.outputPorts.size(); ++i) { - // if (p.params.outputPorts[i].dims != node->output(i).get_shape()) { - // IE_THROW() << "Shape after Model infer " << - // details::dumpVec(node->output(i).get_shape()) - // << " differ from IR shapes: " << - // details::dumpVec(p.params.outputPorts[i].dims); - // } - // } - - if (const auto& parameter_node = std::dynamic_pointer_cast(node)) { + if (const auto& parameter_node = std::dynamic_pointer_cast(node)) { io_map.inputs.insert({layer_id, func_nodes.parameters.size()}); func_nodes.parameters.emplace_back(parameter_node); } - if (const auto& result_node = std::dynamic_pointer_cast(node)) { + if (const auto& result_node = std::dynamic_pointer_cast(node)) { io_map.outputs.insert({layer_id, func_nodes.results.size()}); func_nodes.results.emplace_back(result_node); } - if (const auto& sink = std::dynamic_pointer_cast(node)) { + if (const auto& sink = std::dynamic_pointer_cast(node)) { func_nodes.sinks.emplace_back(sink); } - if (const auto& read_value = std::dynamic_pointer_cast(node)) { + if (const auto& read_value = std::dynamic_pointer_cast(node)) { variable_id_to_read_value[read_value->get_variable_id()] = read_value; } func_nodes.all.emplace_back(node); } - // OV_ITT_SCOPE_NEXT(FIRST_INFERENCE, taskChain, "ConstructNgraphFunction"); - - auto function = std::make_shared(func_nodes.results, - func_nodes.sinks, - func_nodes.parameters, - pugixml::utils::GetStrAttr(root, "name", "")); + auto function = std::make_shared(func_nodes.results, + func_nodes.sinks, + func_nodes.parameters, + pugixml::utils::get_str_attr(root, "name", "")); for (const auto& sink : func_nodes.sinks) { - if (const auto& assign = std::dynamic_pointer_cast(sink)) { + if (const auto& assign = std::dynamic_pointer_cast(sink)) { assign->add_control_dependency(variable_id_to_read_value.at(assign->get_variable_id())); } } @@ -557,6 +553,7 @@ std::shared_ptr XmlDeserializer::parse_function( return function; } +OPENVINO_SUPPRESS_DEPRECATED_END class MetaDataParser : public ov::Meta { public: @@ -582,9 +579,9 @@ class MetaDataParser : public ov::Meta { ov::Any parse_value(const pugi::xml_node& node) const { if (has_attr(node)) { - return pugixml::utils::GetStrAttr(node, "value"); + return pugixml::utils::get_str_attr(node, "value"); } else if (std::string(node.name()) == "unset" && has_attr(node, "unset_cli_parameters")) { - return pugixml::utils::GetStrAttr(node, "unset_cli_parameters"); + return pugixml::utils::get_str_attr(node, "unset_cli_parameters"); } else { return parse_node(node); } @@ -625,7 +622,7 @@ class MetaDataParser : public ov::Meta { mutable std::once_flag m_oc; }; -void XmlDeserializer::read_meta_data(const std::shared_ptr& model, const pugi::xml_node& meta_section) { +void ov::XmlDeserializer::read_meta_data(const std::shared_ptr& model, const pugi::xml_node& meta_section) { if (meta_section.empty()) return; auto& rt_info = model->get_rt_info(); @@ -633,7 +630,7 @@ void XmlDeserializer::read_meta_data(const std::shared_ptr& model, co if (data.empty()) continue; if (!data.attribute("value").empty()) { - rt_info[data.name()] = pugixml::utils::GetStrAttr(data, "value"); + rt_info[data.name()] = pugixml::utils::get_str_attr(data, "value"); } else { // Use meta data for set of parameters std::shared_ptr meta = std::make_shared(data.name(), data); @@ -642,9 +639,9 @@ void XmlDeserializer::read_meta_data(const std::shared_ptr& model, co } } -void XmlDeserializer::read_legacy_meta_data(const std::shared_ptr& model, - const std::unordered_set& names, - const pugi::xml_node& root_section) { +void ov::XmlDeserializer::read_legacy_meta_data(const std::shared_ptr& model, + const std::unordered_set& names, + const pugi::xml_node& root_section) { const auto& read_meta = [](const std::shared_ptr& model, const std::string& name, const pugi::xml_node& meta_section) { @@ -657,7 +654,7 @@ void XmlDeserializer::read_legacy_meta_data(const std::shared_ptr& mo std::shared_ptr meta = std::make_shared("cli_parameters", data); rt_info["conversion_parameters"] = meta; } else if (!data.attribute("value").empty()) { - rt_info[data.name()] = pugixml::utils::GetStrAttr(data, "value"); + rt_info[data.name()] = pugixml::utils::get_str_attr(data, "value"); } else { OPENVINO_THROW("Unsupported legacy argument: ", data.name()); } @@ -672,30 +669,34 @@ void XmlDeserializer::read_legacy_meta_data(const std::shared_ptr& mo read_meta(model, it, root_section.child(it.c_str())); } -GenericLayerParams XmlDeserializer::parse_generic_params(const pugi::xml_node& node) { +ov::GenericLayerParams ov::XmlDeserializer::parse_generic_params(const pugi::xml_node& node) { const auto parsePort = [](const pugi::xml_node& parentNode, const GenericLayerParams& params, bool input) -> GenericLayerParams::LayerPortData { GenericLayerParams::LayerPortData port; - port.portId = pugixml::utils::GetUIntAttr(parentNode, "id"); + port.portId = static_cast(pugixml::utils::get_uint64_attr(parentNode, "id")); FOREACH_CHILD (node, parentNode, "dim") { int64_t dim = 0; const pugi::char_t* dimVal = node.child_value(); std::stringstream ss(dimVal); if (!(ss >> dim) || dim < -1) { - IE_THROW() << "dimension (" << dimVal << ") in node " << node.name() - << " must be greater or equal to -1: at offset " << node.offset_debug(); + OPENVINO_THROW("dimension (", + dimVal, + ") in node ", + node.name(), + " must be greater or equal to -1: at offset ", + node.offset_debug()); } port.dims.emplace_back(dim); } - ngraph::element::Type type(ngraph::element::Type_t::undefined); + ov::element::Type type(ov::element::Type_t::undefined); // Input port hasn't precision if (!input) { - const std::string& preStr = pugixml::utils::GetStrAttr(parentNode, "precision"); - type = InferenceEngine::details::convertPrecision(preStr); + const std::string& preStr = pugixml::utils::get_str_attr(parentNode, "precision"); + type = ov::element::Type(preStr); } port.precision = type; std::vector names; @@ -718,12 +719,12 @@ GenericLayerParams XmlDeserializer::parse_generic_params(const pugi::xml_node& n }; GenericLayerParams params; - params.layerId = pugixml::utils::GetUIntAttr(node, "id"); - params.version = pugixml::utils::GetStrAttr(node, "version"); + params.layerId = static_cast(pugixml::utils::get_uint64_attr(node, "id")); + params.version = pugixml::utils::get_str_attr(node, "version"); - params.type = pugixml::utils::GetStrAttr(node, "type"); + params.type = pugixml::utils::get_str_attr(node, "type"); - params.name = pugixml::utils::GetStrAttr(node, "name"); + params.name = pugixml::utils::get_str_attr(node, "name"); auto outNode = node.child("output"); if (!outNode.empty()) { @@ -750,30 +751,43 @@ static const std::string& translate_type_name(const std::string& name) { return name; } -std::shared_ptr XmlDeserializer::create_node( - const std::vector>& inputs, +OPENVINO_SUPPRESS_DEPRECATED_START +std::shared_ptr ov::XmlDeserializer::create_node( + const std::vector>& inputs, const pugi::xml_node& node, const std::shared_ptr& weights, const GenericLayerParams& params) { // Check that inputs are correctly defined for (size_t i = 0; i < inputs.size(); i++) { if (!inputs[i].get_node()) - IE_THROW() << params.type << " layer " << params.name << " with id: " << params.layerId - << " has incorrect input with index " << i << "!"; - if (ngraph::element::Type_t::undefined == inputs[i].get_element_type()) - IE_THROW() << params.type << " layer " << params.name << " with id: " << params.layerId - << " has undefined element type for input with index " << i << "!"; + OPENVINO_THROW(params.type, + " layer ", + params.name, + " with id: ", + params.layerId, + " has incorrect input with index ", + i, + "!"); + if (ov::element::Type_t::undefined == inputs[i].get_element_type()) + OPENVINO_THROW(params.type, + " layer ", + params.name, + " with id: ", + params.layerId, + " has undefined element type for input with index ", + i, + "!"); } const std::string& type_name = translate_type_name(params.type); - std::shared_ptr ngraphNode; + std::shared_ptr ovNode; ov::DiscreteTypeInfo type(type_name.c_str(), params.version.c_str()); auto extensionIt = m_extensions.find(type); if (extensionIt != m_extensions.end()) { XmlDeserializer visitor(node, weights, m_opsets, m_extensions, m_variables, m_version); - ngraphNode = (*extensionIt->second).create(inputs, visitor).at(0).get_node_shared_ptr(); + ovNode = (*extensionIt->second).create(inputs, visitor).at(0).get_node_shared_ptr(); } // Find registered opset @@ -795,57 +809,69 @@ std::shared_ptr XmlDeserializer::create_node( opsetIt = m_opsets.find("opset6"); } - if (!ngraphNode && opsetIt != m_opsets.end()) { + if (!ovNode && opsetIt != m_opsets.end()) { if (params.version == "opset1") { // MVN, ROIPooling and ReorgYolo were missing in opset1 if (type_name == "MVN" || type_name == "ROIPooling" || type_name == "ReorgYolo") { opsetIt = m_opsets.find("opset2"); if (opsetIt == m_opsets.end()) { - IE_THROW() << "Cannot create " << params.type << " layer " << params.name - << " id:" << params.layerId << " from unsupported opset: " << params.version; + OPENVINO_THROW("Cannot create ", + params.type, + " layer ", + params.name, + " id:", + params.layerId, + " from unsupported opset: ", + params.version); } } } auto const& opset = opsetIt->second; - ngraphNode = std::shared_ptr(opset.create_insensitive(type_name)); - if (!ngraphNode) { - IE_THROW() << "Opset " << params.version << " doesn't contain the operation with type: " << type_name; + ovNode = std::shared_ptr(opset.create_insensitive(type_name)); + if (!ovNode) { + OPENVINO_THROW("Opset ", params.version, " doesn't contain the operation with type: ", type_name); } // Share Weights form constant blob - if (auto constant = std::dynamic_pointer_cast(ngraphNode)) { + if (auto constant = std::dynamic_pointer_cast(ovNode)) { constant->alloc_buffer_on_visit_attributes(false); } - ngraphNode->set_arguments(inputs); + ovNode->set_arguments(inputs); XmlDeserializer visitor(node, weights, m_opsets, m_extensions, m_variables, m_version); - if (ngraphNode->visit_attributes(visitor)) { - ngraphNode->constructor_validate_and_infer_types(); + if (ovNode->visit_attributes(visitor)) { + ovNode->constructor_validate_and_infer_types(); } // To be sure that all default values will be initialized: - ngraphNode = ngraphNode->clone_with_new_inputs(ngraphNode->input_values()); + ovNode = ovNode->clone_with_new_inputs(ovNode->input_values()); } - if (!ngraphNode && m_extensions.count(ov::op::util::FrameworkNode::get_type_info_static())) { - ngraphNode = std::make_shared(inputs); + if (!ovNode && m_extensions.count(ov::op::util::FrameworkNode::get_type_info_static())) { + ovNode = std::make_shared(inputs); XmlDeserializer visitor(node, weights, m_opsets, m_extensions, m_variables, m_version); - ngraphNode->visit_attributes(visitor); + ovNode->visit_attributes(visitor); size_t index{0}; for (const auto& output_params : params.outputPorts) { - ngraphNode->set_output_type(index, output_params.precision, ngraph::PartialShape(output_params.dims)); + ovNode->set_output_type(index, output_params.precision, ov::PartialShape(output_params.dims)); ++index; } } - if (!ngraphNode) { - IE_THROW() << "Cannot create " << params.type << " layer " << params.name << " id:" << params.layerId - << " from unsupported opset: " << params.version; + if (!ovNode) { + OPENVINO_THROW("Cannot create ", + params.type, + " layer ", + params.name, + " id:", + params.layerId, + " from unsupported opset: ", + params.version); } // Save run time info - auto& rtInfo = ngraphNode->get_rt_info(); + auto& rtInfo = ovNode->get_rt_info(); pugi::xml_node dn = node.child("data"); if (dn) { const auto pr_data = dn.attribute("PrimitivesPriority"); @@ -858,10 +884,10 @@ std::shared_ptr XmlDeserializer::create_node( } } - ngraphNode->set_friendly_name(params.name); - for (size_t i = 0; i < params.outputPorts.size() && i < ngraphNode->get_output_size(); ++i) { + ovNode->set_friendly_name(params.name); + for (size_t i = 0; i < params.outputPorts.size() && i < ovNode->get_output_size(); ++i) { if (!params.outputPorts[i].names.empty()) - ngraphNode->get_output_tensor(i).set_names(params.outputPorts[i].names); + ovNode->get_output_tensor(i).set_names(params.outputPorts[i].names); } ov::pass::Attributes attrs_factory; @@ -875,12 +901,12 @@ std::shared_ptr XmlDeserializer::create_node( if (!getStrAttribute(item, "name", attribute_name)) { std::stringstream ss; item.print(ss); - IE_THROW() << "rt_info attribute has no \"name\" field: " << ss.str(); + OPENVINO_THROW("rt_info attribute has no \"name\" field: ", ss.str()); } if (!getStrAttribute(item, "version", attribute_version)) { std::stringstream ss; item.print(ss); - IE_THROW() << "rt_info attribute: " << attribute_name << " has no \"version\" field: " << ss.str(); + OPENVINO_THROW("rt_info attribute: ", attribute_name, " has no \"version\" field: ", ss.str()); } const auto& type_info = ov::DiscreteTypeInfo(attribute_name.c_str(), attribute_version.c_str()); auto attr = attrs_factory.create_by_type_info(type_info); @@ -890,13 +916,13 @@ std::shared_ptr XmlDeserializer::create_node( if (attr.as().visit_attributes(attribute_visitor)) { auto res = rt_info.emplace(type_info, attr); if (!res.second) { - IE_THROW() << "multiple rt_info attributes are detected: " << attribute_name; + OPENVINO_THROW("multiple rt_info attributes are detected: ", attribute_name); } } else { - IE_THROW() << "VisitAttributes is not supported for: " << item.name() << " attribute"; + OPENVINO_THROW("VisitAttributes is not supported for: ", item.name(), " attribute"); } } else { - IE_THROW() << "Attribute: " << item.name() << " is not recognized as runtime attribute"; + OPENVINO_THROW("Attribute: ", item.name(), " is not recognized as runtime attribute"); } } else { // As runtime attributes are optional, so we skip attribute if it is unknown to avoid exception @@ -908,14 +934,14 @@ std::shared_ptr XmlDeserializer::create_node( // read runtime info only for IR v11+ if (m_version > 10) { // set node runtime info attributes - set_runtime_info(ngraphNode->get_rt_info(), node.child("rt_info")); + set_runtime_info(ovNode->get_rt_info(), node.child("rt_info")); // set output ports runtime info attributes auto out_node = node.child("output"); if (!out_node.empty()) { size_t index{0}; FOREACH_CHILD (rt_node, out_node, "port") { - set_runtime_info(ngraphNode->output(index).get_rt_info(), rt_node.child("rt_info")); + set_runtime_info(ovNode->output(index).get_rt_info(), rt_node.child("rt_info")); ++index; } } @@ -925,11 +951,12 @@ std::shared_ptr XmlDeserializer::create_node( if (!in_node.empty()) { size_t index{0}; FOREACH_CHILD (rt_node, in_node, "port") { - set_runtime_info(ngraphNode->input(index).get_rt_info(), rt_node.child("rt_info")); + set_runtime_info(ovNode->input(index).get_rt_info(), rt_node.child("rt_info")); ++index; } } } - return ngraphNode; + return ovNode; } +OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/ir/src/ir_deserializer.hpp b/src/frontends/ir/src/ir_deserializer.hpp index b9cd35701a718c..f2062393f2986a 100644 --- a/src/frontends/ir/src/ir_deserializer.hpp +++ b/src/frontends/ir/src/ir_deserializer.hpp @@ -9,15 +9,13 @@ #include #include -#include "ie_ngraph_utils.hpp" #include "input_model.hpp" -#include "ngraph/opsets/opset.hpp" +#include "ngraph/runtime/aligned_buffer.hpp" #include "openvino/core/attribute_visitor.hpp" #include "openvino/core/op_extension.hpp" #include "openvino/op/loop.hpp" #include "openvino/op/util/sub_graph_base.hpp" #include "utils.hpp" -#include "xml_parse_utils.h" namespace ov { @@ -43,7 +41,7 @@ struct GenericLayerParams { } ++real_id; } - IE_THROW() << "Can not find input port with id " << id << " in layer " << name; + OPENVINO_THROW("Can not find input port with id ", id, " in layer ", name); } size_t get_real_output_port_id(size_t id) const { @@ -54,12 +52,13 @@ struct GenericLayerParams { } ++real_id; } - IE_THROW() << "Can not find output port with id " << id << " in layer " << name; + OPENVINO_THROW("Can not find output port with id ", id, " in layer ", name); } }; class XmlDeserializer : public ov::AttributeVisitor { public: + OPENVINO_SUPPRESS_DEPRECATED_START explicit XmlDeserializer(const pugi::xml_node& node, const std::shared_ptr& weights, const std::unordered_map& opsets, @@ -72,6 +71,7 @@ class XmlDeserializer : public ov::AttributeVisitor { m_extensions(extensions), m_variables(variables), m_version(version) {} + OPENVINO_SUPPRESS_DEPRECATED_END void on_adapter(const std::string& name, ov::ValueAccessor& value) override { std::string val; @@ -164,12 +164,14 @@ class XmlDeserializer : public ov::AttributeVisitor { // TODO consider to call only once per layer/TI-Loop node IoMap updated_io_map(const pugi::xml_node& node, const pugi::xml_node& body_node); + OPENVINO_SUPPRESS_DEPRECATED_START /// \brief Traverses xml node representation in order to create ov function for it. /// \param node xml node representation /// \param weights weights attached to current node /// \return shared pointer to function representing input node std::shared_ptr parse_function(const pugi::xml_node& root, const std::shared_ptr& weights); + OPENVINO_SUPPRESS_DEPRECATED_END /// \brief Traverses xml node representation in order to get the purpose attribute of /// inputs/outputs in the body of Loop op. \param node xml node representation \return struct /// with value of purpuse attribute @@ -177,10 +179,12 @@ class XmlDeserializer : public ov::AttributeVisitor { GenericLayerParams parse_generic_params(const pugi::xml_node& node); + OPENVINO_SUPPRESS_DEPRECATED_START std::shared_ptr create_node(const ov::OutputVector& inputs, const pugi::xml_node& node, const std::shared_ptr& weights, const GenericLayerParams& params); + OPENVINO_SUPPRESS_DEPRECATED_END void read_meta_data(const std::shared_ptr& model, const pugi::xml_node& meta_section); @@ -190,7 +194,9 @@ class XmlDeserializer : public ov::AttributeVisitor { // -- DATA -- const pugi::xml_node m_node; + OPENVINO_SUPPRESS_DEPRECATED_START const std::shared_ptr& m_weights; + OPENVINO_SUPPRESS_DEPRECATED_END const std::unordered_map& m_opsets; const std::unordered_map& m_extensions; std::unordered_map>& m_variables; diff --git a/src/frontends/ir/src/rt_info_deserializer.cpp b/src/frontends/ir/src/rt_info_deserializer.cpp index f7317cfaf28139..00a7d894ade486 100644 --- a/src/frontends/ir/src/rt_info_deserializer.cpp +++ b/src/frontends/ir/src/rt_info_deserializer.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "rt_info_deserializer.hpp" + #include -#include -#include #include "openvino/frontend/exception.hpp" diff --git a/src/frontends/ir/src/utils.cpp b/src/frontends/ir/src/utils.cpp index 8436952951010e..e1edf6905804f8 100644 --- a/src/frontends/ir/src/utils.cpp +++ b/src/frontends/ir/src/utils.cpp @@ -4,12 +4,126 @@ #include "utils.hpp" -#include "ie_ngraph_utils.hpp" +#include "openvino/core/type/element_type.hpp" #include "openvino/util/common_util.hpp" +namespace pugixml { +namespace utils { + +std::string get_str_attr(const pugi::xml_node& node, const char* str, const char* def) { + auto attr = node.attribute(str); + if (attr.empty()) { + if (def != nullptr) + return def; + + OPENVINO_THROW("node <", + node.name(), + "> is missing mandatory attribute: '", + str, + "' at offset ", + node.offset_debug()); + } + return attr.value(); +} + +int64_t get_int64_attr(const pugi::xml_node& node, const char* str) { + auto attr = node.attribute(str); + if (attr.empty()) + OPENVINO_THROW("node <", + node.name(), + "> is missing mandatory attribute: ", + str, + " at offset ", + node.offset_debug()); + std::string str_value = std::string(attr.value()); + std::size_t idx = 0; + long long int_value = std::stoll(str_value, &idx, 10); + if (idx != str_value.length()) + OPENVINO_THROW("node <", + node.name(), + "> has attribute \"", + str, + "\" = \"", + str_value, + "\" which is not an 64 bit integer", + " at offset ", + node.offset_debug()); + return static_cast(int_value); +} + +int64_t get_int64_attr(const pugi::xml_node& node, const char* str, int64_t def) { + auto attr = node.attribute(str); + if (attr.empty()) + return def; + return get_int64_attr(node, str); +} + +uint64_t get_uint64_attr(const pugi::xml_node& node, const char* str) { + auto attr = node.attribute(str); + if (attr.empty()) + OPENVINO_THROW("node <", + node.name(), + "> is missing mandatory attribute: ", + str, + " at offset ", + node.offset_debug()); + std::string str_value = std::string(attr.value()); + std::size_t idx = 0; + long long int_value = std::stoll(str_value, &idx, 10); + if (idx != str_value.length() || int_value < 0) + OPENVINO_THROW("node <", + node.name(), + "> has attribute \"", + str, + "\" = \"", + str_value, + "\" which is not an unsigned 64 bit integer", + " at offset ", + node.offset_debug()); + return static_cast(int_value); +} + +uint64_t get_uint64_attr(const pugi::xml_node& node, const char* str, uint64_t def) { + auto attr = node.attribute(str); + if (attr.empty()) + return def; + return get_uint64_attr(node, str); +} + +float get_float_attr(const pugi::xml_node& node, const char* str) { + auto attr = node.attribute(str); + if (attr.empty()) + OPENVINO_THROW("node <", + node.name(), + "> is missing mandatory attribute: ", + str, + " at offset ", + node.offset_debug()); + std::string str_value = std::string(attr.value()); + std::stringstream str_stream(str_value); + str_stream.imbue(std::locale("C")); + float float_value; + str_stream >> float_value; + if (!str_stream.eof()) + OPENVINO_THROW("node <", + node.name(), + "> has attribute \"", + str, + "\" = \"", + str_value, + "\" which is not a floating point", + " at offset ", + node.offset_debug()); + return float_value; +} + +} // namespace utils +} // namespace pugixml + namespace ov { + void operator>>(const std::stringstream& in, ov::element::Type& type) { - type = InferenceEngine::details::convertPrecision(ov::util::trim(in.str())); + type = ov::element::Type(ov::util::trim(in.str())); } bool getStrAttribute(const pugi::xml_node& node, const std::string& name, std::string& value) { @@ -46,8 +160,7 @@ void str_to_set_of_strings(const std::string& value, std::set& res) // trim leading and trailing whitespaces auto strBegin = field.find_first_not_of(" "); if (strBegin == std::string::npos) - IE_THROW() << "Cannot get a set of strings from \"" << value << "\". Value \"" << field - << "\" is incorrect"; + OPENVINO_THROW("Cannot get a set of strings from \"", value, "\". Value \"", field, "\" is incorrect"); auto strRange = field.find_last_not_of(" ") - strBegin + 1; res.insert(field.substr(strBegin, strRange)); diff --git a/src/frontends/ir/src/utils.hpp b/src/frontends/ir/src/utils.hpp index 534e48d19eb979..1b45cf7238b003 100644 --- a/src/frontends/ir/src/utils.hpp +++ b/src/frontends/ir/src/utils.hpp @@ -5,10 +5,25 @@ #pragma once #include -#include +#include +#include "openvino/core/partial_shape.hpp" #include "openvino/core/type/element_type.hpp" -#include "xml_parse_utils.h" + +#define FOREACH_CHILD(c, p, tag) for (auto c = p.child(tag); !c.empty(); c = c.next_sibling(tag)) + +namespace pugixml { +namespace utils { + +std::string get_str_attr(const pugi::xml_node& node, const char* str, const char* def = nullptr); +uint64_t get_uint64_attr(const pugi::xml_node& node, const char* str); +uint64_t get_uint64_attr(const pugi::xml_node& node, const char* str, uint64_t def); +int64_t get_int64_attr(const pugi::xml_node& node, const char* str); +int64_t get_int64_attr(const pugi::xml_node& node, const char* str, int64_t def); +float get_float_attr(const pugi::xml_node& node, const char* str); + +} // namespace utils +} // namespace pugixml namespace ov { void operator>>(const std::stringstream& in, ov::element::Type& type); diff --git a/src/frontends/ir/tests/meta_data_tests.cpp b/src/frontends/ir/tests/meta_data_tests.cpp index 4fadc98c41d6d5..8dd75fd65e33e7 100644 --- a/src/frontends/ir/tests/meta_data_tests.cpp +++ b/src/frontends/ir/tests/meta_data_tests.cpp @@ -10,6 +10,7 @@ #include "file_utils.h" #include "openvino/core/any.hpp" #include "openvino/openvino.hpp" +#include "openvino/util/file_util.hpp" class MetaData : public ::testing::Test { public: @@ -393,7 +394,7 @@ TEST_F(MetaData, get_meta_data_as_map) { } TEST_F(MetaData, get_meta_data_from_removed_file) { - std::string file_path = InferenceEngine::getIELibraryPath() + ov::util::FileTraits::file_separator + + std::string file_path = ov::util::get_ov_lib_path() + ov::util::FileTraits::file_separator + ov::test::utils::generateTestFilePrefix() + "_test_model.xml"; // Create file { diff --git a/src/tests/functional/plugin/shared/CMakeLists.txt b/src/tests/functional/plugin/shared/CMakeLists.txt index 13eeb2375a92c7..f5bb32f5859391 100644 --- a/src/tests/functional/plugin/shared/CMakeLists.txt +++ b/src/tests/functional/plugin/shared/CMakeLists.txt @@ -28,7 +28,6 @@ if(ENABLE_TEMPLATE) list(APPEND DEPENDENCIES openvino_template_plugin) endif() -# remove once CVS-69781 is fixed if(ENABLE_OV_IR_FRONTEND) list(APPEND DEPENDENCIES openvino_ir_frontend) endif() From 3d679edf189355805d55db43b814474f23e48702 Mon Sep 17 00:00:00 2001 From: Mingyu Kim Date: Tue, 5 Sep 2023 21:37:31 +0900 Subject: [PATCH 02/31] [GPU] Remove propagate_constants pass at pre_optimize_graph stage (#19323) Co-authored-by: Lyamin-Roman --- .../src/graph/graph_optimizer/prepare_buffer_fusing.cpp | 4 ++++ src/plugins/intel_gpu/src/graph/program.cpp | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp index 5cd3c68ff72ad6..f9125baa5fdbfb 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp @@ -478,6 +478,10 @@ void prepare_buffer_fusing::run(program& p) { return; } + // do not optimize crop, that must be calculated in propagate_constants + if (node.is_constant()) + return; + if (node.get_dependencies().size() == 1 && node.get_users().size() > 0) { if (p.is_loop_body() && node.get_dependency(0).is_type()) { return; diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cpp index 4e7bc297cb133e..bc55f8e376380f 100644 --- a/src/plugins/intel_gpu/src/graph/program.cpp +++ b/src/plugins/intel_gpu/src/graph/program.cpp @@ -580,11 +580,6 @@ void program::pre_optimize_graph(bool is_internal) { apply_opt_pass(lo, optimize_data); - if (!is_internal) { - // ToDo remove hidden dependencies from propagate_constants pass - apply_opt_pass(); - } - // try to fuse buffers (i.e. depth_concat in bfyx format) after padding calculations if (optimize_data) { apply_opt_pass(); From 77600c770158012a58d0bf84a875ec35d8a9f22a Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Tue, 5 Sep 2023 16:47:05 +0400 Subject: [PATCH 03/31] [GPU] Add FullyConnected custom op (#19539) --- .../include/intel_gpu/op/fully_connected.hpp | 38 ++ .../intel_gpu/plugin/primitives_list.hpp | 1 + .../intel_gpu/plugin/program_builder.hpp | 4 +- .../intel_gpu/runtime/debug_configuration.hpp | 2 +- .../src/plugin/ops/fully_connected.cpp | 83 ++++ .../intel_gpu/src/plugin/ops/matmul.cpp | 301 ++++---------- .../transformations/convert_matmul_to_fc.cpp | 172 ++++++++ .../transformations/convert_matmul_to_fc.hpp | 19 + .../move_fc_reshape_to_weights.cpp | 112 +++++ .../move_fc_reshape_to_weights.hpp | 38 ++ .../transformations/op/fully_connected.cpp | 50 +++ .../src/plugin/transformations_pipeline.cpp | 13 + .../dynamic/matmul_weights_decompression.cpp | 256 ++++++++++++ .../intel_gpu/tests/unit/CMakeLists.txt | 1 + .../convert_matmul_to_fc_test.cpp | 386 ++++++++++++++++++ .../move_fc_reshape_to_weights.cpp | 107 +++++ 16 files changed, 1361 insertions(+), 222 deletions(-) create mode 100644 src/plugins/intel_gpu/include/intel_gpu/op/fully_connected.hpp create mode 100644 src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp create mode 100644 src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp create mode 100644 src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.hpp create mode 100644 src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.cpp create mode 100644 src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.hpp create mode 100644 src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected.cpp create mode 100644 src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp create mode 100644 src/plugins/intel_gpu/tests/unit/transformations/convert_matmul_to_fc_test.cpp create mode 100644 src/plugins/intel_gpu/tests/unit/transformations/move_fc_reshape_to_weights.cpp diff --git a/src/plugins/intel_gpu/include/intel_gpu/op/fully_connected.hpp b/src/plugins/intel_gpu/include/intel_gpu/op/fully_connected.hpp new file mode 100644 index 00000000000000..a77c39c20338c0 --- /dev/null +++ b/src/plugins/intel_gpu/include/intel_gpu/op/fully_connected.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/core/node.hpp" +#include "openvino/op/op.hpp" + +namespace ov { +namespace intel_gpu { +namespace op { + +class FullyConnected : public ov::op::Op { +public: + OPENVINO_OP("FullyConnected", "gpu_opset"); + + FullyConnected() = default; + + FullyConnected(const ov::Output& A, + const ov::Output& B, + const ov::element::Type output_type = ov::element::undefined); + + bool visit_attributes(ov::AttributeVisitor &visitor) override; + + void validate_and_infer_types() override; + + std::shared_ptr clone_with_new_inputs(const ov::OutputVector& new_args) const override; + + ov::element::Type get_output_type() const { return m_output_type; } + +protected: + ov::element::Type m_output_type; +}; + +} // namespace op +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp index fc96b9ddeaeb03..5fd423e8e7b4be 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp @@ -261,3 +261,4 @@ REGISTER_FACTORY(internal, NonMaxSuppressionIEInternal); REGISTER_FACTORY(internal, GenerateProposalsIEInternal); REGISTER_FACTORY(internal, NmsStaticShapeIE8); REGISTER_FACTORY(internal, MulticlassNmsIEInternal); +REGISTER_FACTORY(internal, FullyConnected); diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hpp index 1cad1a8d397c56..6d3b40c6f8022c 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hpp @@ -35,8 +35,8 @@ enum class eltwise_mode : int32_t; #define REGISTER_FACTORY_IMPL(op_version, op_name) \ void __register ## _ ## op_name ## _ ## op_version(); \ void __register ## _ ## op_name ## _ ## op_version() { \ - ProgramBuilder::RegisterFactory( \ - [](ProgramBuilder& p, const std::shared_ptr& op) { \ + ProgramBuilder::RegisterFactory( \ + [](ProgramBuilder& p, const std::shared_ptr& op) { \ auto op_casted = std::dynamic_pointer_cast(op); \ OPENVINO_ASSERT(op_casted, "[GPU] Invalid ov Node type passed into ", __PRETTY_FUNCTION__); \ Create##op_name##Op(p, op_casted); \ diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp index a912316e409244..7bca0f2a73f023 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp @@ -3,7 +3,7 @@ // #pragma once -#include +#include #include #include #include diff --git a/src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp b/src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp new file mode 100644 index 00000000000000..c6f957afc97f59 --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp @@ -0,0 +1,83 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "intel_gpu/plugin/program_builder.hpp" +#include "intel_gpu/plugin/common_utils.hpp" + +#include "intel_gpu/op/fully_connected.hpp" + +#include "intel_gpu/primitives/fully_connected.hpp" +#include "intel_gpu/primitives/reshape.hpp" +#include "intel_gpu/primitives/reorder.hpp" + + +namespace ov { +namespace op { +namespace internal { +using FullyConnected = ov::intel_gpu::op::FullyConnected; +} // namespace internal +} // namespace op +} // namespace ov + +namespace ov { +namespace intel_gpu { + +static void CreateFullyConnectedOp(ProgramBuilder& p, const std::shared_ptr& op) { + validate_inputs_count(op, {2}); + auto inputs = p.GetInputInfo(op); + std::string layerName = layer_type_name_ID(op); + + auto inputName = inputs[0].pid; + auto weightsName = inputs[1].pid; + + auto shape_a = op->get_input_partial_shape(0); + auto shape_b = op->get_input_partial_shape(1); + + auto rank_a = shape_a.rank().get_length(); + auto rank_b = shape_b.rank().get_length(); + + auto fcPrim = cldnn::fully_connected(layerName, + cldnn::input_info(inputName), + weightsName, + "", + cldnn::element_type_to_data_type(op->get_output_element_type(0)), + cldnn::padding(), + rank_a, + rank_b); + + p.add_primitive(*op, fcPrim); + + if (shape_a.size() > 3 && !p.use_new_shape_infer()) { + auto lastLayerName = layerName; + auto outReshapeName = layerName + "_cldnn_out_reshape"; + + // add reorder + auto outDims = op->get_output_shape(0); + auto outTensor = tensor_from_dims(outDims); + + if (outDims.size() > 4) { + cldnn::format outputFormat = cldnn::format::bfyx; + switch (outDims.size()) { + case 5: outputFormat = cldnn::format::bfzyx; break; + case 6: outputFormat = cldnn::format::bfwzyx; break; + default: break; + } + + cldnn::primitive_id reorderId = "reorder:" + outReshapeName + "_reorder"; + cldnn::layout outputLayout(cldnn::element_type_to_data_type(op->get_output_element_type(0)), outputFormat, outTensor); + auto reorder_prim = cldnn::reorder(reorderId, cldnn::input_info(layerName), outputLayout); + p.add_primitive(*op, reorder_prim); + lastLayerName = reorderId; + } + + // add reshape + auto outReshapePrim = cldnn::reshape(outReshapeName, cldnn::input_info(lastLayerName), outTensor); + p.add_primitive(*op, outReshapePrim); + } +} + +REGISTER_FACTORY_IMPL(internal, FullyConnected); + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/ops/matmul.cpp b/src/plugins/intel_gpu/src/plugin/ops/matmul.cpp index 32d13b0cb3e16d..eced7765e693ea 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/matmul.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/matmul.cpp @@ -20,57 +20,6 @@ namespace ov { namespace intel_gpu { -/* -* get_aligned_shapes function align two input shapes to have the same size and -* the same batch dimensions (last two dimensions are not comparable). -* It also checks that dimensions are compatible so in case with two shapes -* for example: [2, 32, 64] [3, 64, 64] it will raise an exception. -*/ - -static std::tuple get_aligned_shapes(const PartialShape& shape_a, - const PartialShape& shape_b, - const std::shared_ptr& matmul) { - PartialShape shape_a_aligned(shape_a), shape_b_aligned(shape_b); - auto rank_a = shape_a_aligned.rank().get_length(); - auto rank_b = shape_b_aligned.rank().get_length(); - size_t max_size = std::max(rank_a, rank_b); - if (max_size == 1) { - return std::make_tuple(false, shape_a_aligned, shape_b_aligned); - } - - for (size_t i = 0, cnt = max_size - rank_a; i < cnt; ++i) { - shape_a_aligned.insert(shape_a_aligned.begin(), 1); - } - for (size_t i = 0, cnt = max_size - rank_b; i < cnt; ++i) { - shape_b_aligned.insert(shape_b_aligned.begin(), 1); - } - - if (matmul->get_transpose_a()) { - std::swap(*(shape_a_aligned.end() - 1), *(shape_a_aligned.end() - 2)); - } - if (matmul->get_transpose_b()) { - std::swap(*(shape_b_aligned.end() - 1), *(shape_b_aligned.end() - 2)); - } - - for (size_t i = 0; i < max_size - 2; ++i) { - auto a_dim = shape_a_aligned[i], b_dim = shape_b_aligned[i]; - if (a_dim.is_dynamic()) { - if (b_dim == 1) { - shape_a_aligned[i] = shape_b_aligned[i] = a_dim; - } else { - return std::make_tuple(false, shape_a_aligned, shape_b_aligned); - } - } else { - if (a_dim != b_dim && a_dim.get_length() > 1 && b_dim.get_length() > 1) { - OPENVINO_THROW("Shapes can't be aligned: ", shape_a_aligned, " ", shape_b_aligned); - } - auto max_value = std::max(a_dim.get_length(), b_dim.get_length()); - shape_a_aligned[i] = shape_b_aligned[i] = max_value; - } - } - return {true, shape_a_aligned, shape_b_aligned}; -} - static void CreateMatMulOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {2}); auto inputs = p.GetInputInfo(op); @@ -82,181 +31,95 @@ static void CreateMatMulOp(ProgramBuilder& p, const std::shared_ptrget_input_node_shared_ptr(1)); - is_fc &= std::count_if(shape_b.begin(), shape_b.end(), [](Dimension x) { return x != 1; }) <= 2; - // TODO: This conditions can be relaxed with proper handling in FC path - is_fc &= rank_a > 1 && rank_b > 1; - - PartialShape shape_a_aligned, shape_b_aligned; - bool aligned = false; - if (shape_b.is_static()) { - std::tie(aligned, shape_a_aligned, shape_b_aligned) = get_aligned_shapes(shape_a, shape_b, op); - } - is_fc &= aligned; - - if (is_fc) { - if (shape_a_aligned.size() < 2 || shape_b_aligned.size() < 2) { - OPENVINO_THROW("MatMul ", op->get_friendly_name(), " shapes are inconsistent."); + auto alpha = 1.0f; + auto beta = 0.0f; + auto transA = op->get_transpose_a(); + auto transB = op->get_transpose_b(); + + std::array inputShapes{ + op->get_input_partial_shape(0), + op->get_input_partial_shape(1) + }; + + auto canTransposeInputs = [&] (const std::array& shapes, bool transA, bool transB, ov::element::Type type) -> bool { + if (!transA && !transB) + return false; + + // dynamic shapes and 1D tensors are not transposed + if (shapes[0].is_dynamic() || shapes[1].is_dynamic() || + shapes[0].size() < 2 || shapes[1].size() < 2) + return false; + + // don't transpose inputs if they're aligned to 16 + bool inputsAligned = std::all_of(shapes[0].rbegin(), shapes[0].rbegin() + 2, + [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() % 16 == 0; }) && + std::all_of(shapes[1].rbegin(), shapes[1].rbegin() + 2, + [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() % 16 == 0; }); + if (inputsAligned) + return false; + + // Heuristic condition for permute and tiled_opt kernel perform better than ref kernel. + bool in0_large = std::all_of(shapes[0].rbegin(), shapes[0].rbegin() + 2, + [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() >= 64; }); + bool in1_large = std::all_of(shapes[1].rbegin(), shapes[1].rbegin() + 2, + [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() >= 64; }); + // Optimized for clDNN + auto is_u8_i8 = (type == ov::element::Type_t::i8 || type == ov::element::Type_t::u8); + bool in0_very_large = tensor_from_dims(shapes[0].to_shape()).count() > 100000; + bool in1_very_large = tensor_from_dims(shapes[0].to_shape()).count() > 100000; + bool needs_to_transpose_inputs = (in0_very_large || in1_very_large) && !is_u8_i8 && !p.get_engine().get_device_info().supports_immad; + + return (in0_large && in1_large) || needs_to_transpose_inputs; + }; + + auto transposeInput = [] (ProgramBuilder& p, const std::shared_ptr& op, const ov::PartialShape& shape, + const std::string& suffix, const cldnn::primitive_id& primitiveId) -> cldnn::input_info { + std::vector transposeOrder(shape.size()); + std::iota(transposeOrder.begin(), transposeOrder.end(), 0); + std::swap(*(transposeOrder.end() - 1), *(transposeOrder.end() - 2)); + + auto permuteName = op->get_friendly_name() + suffix; + auto permutePrim = cldnn::permute(permuteName, + cldnn::input_info(primitiveId), + transposeOrder); + p.add_primitive(*op, permutePrim); + return cldnn::input_info(permuteName); + }; + + if (canTransposeInputs(inputShapes, transA, transB, op->get_input_element_type(0))) { + if (transA) { + inputs[0] = transposeInput(p, op, inputShapes[0], "/transpose_a", inputs[0].pid); + transA = false; } - auto inputName = inputs[0].pid; - auto weightsName = inputs[1].pid; - - auto create_transpose = [&](const std::string& transposeName, const std::string& transposeInputName, size_t rank) { - std::vector transpose_order(rank); - std::iota(transpose_order.begin(), transpose_order.end(), 0); - std::swap(*(transpose_order.end() - 1), *(transpose_order.end() - 2)); - - auto permutePrim = cldnn::permute(transposeName, - cldnn::input_info(transposeInputName), - transpose_order); - p.add_primitive(*op, permutePrim); - }; - - // Weights normalization - if (!op->get_transpose_b()) { - auto transposeName = op->get_friendly_name() + "/transpose_b"; - create_transpose(transposeName, weightsName, rank_b); - weightsName = transposeName; + if (transB) { + inputs[1] = transposeInput(p, op, inputShapes[1], "/transpose_b", inputs[1].pid); + transB = false; } + } - // Input normalization - if (op->get_transpose_a()) { - auto transposeName = op->get_friendly_name() + "/transpose_a"; - create_transpose(transposeName, inputName, rank_a); - inputName = transposeName; - } - - auto fcPrim = cldnn::fully_connected(layerName, - cldnn::input_info(inputName), - weightsName, - "", - cldnn::element_type_to_data_type(op->get_output_element_type(0)), - cldnn::padding(), - rank_a, - rank_b); - - p.add_primitive(*op, fcPrim); - - if (shape_a_aligned.size() > 3 && !p.use_new_shape_infer()) { - auto lastLayerName = layerName; + auto gemmPrim = cldnn::gemm(layerName, + inputs, + cldnn::element_type_to_data_type(op->get_output_element_type(0)), + transA, + transB, + alpha, + beta, + rank_a, + rank_b); + + p.add_primitive(*op, gemmPrim); + + if (!p.use_new_shape_infer()) { + auto outDims = op->get_output_shape(0); + auto outDimsN = outDims.size(); + // Reshape output if gemm specific shape does not match default one + if (outDimsN < 4) { + auto outputShape = tensor_from_dims(outDims); auto outReshapeName = layerName + "_cldnn_out_reshape"; - - // add reorder - auto outDims = op->get_output_shape(0); - auto outTensor = tensor_from_dims(outDims); - - if (outDims.size() > 4) { - cldnn::format outputFormat = cldnn::format::bfyx; - switch (outDims.size()) { - case 5: outputFormat = cldnn::format::bfzyx; break; - case 6: outputFormat = cldnn::format::bfwzyx; break; - default: break; - } - - cldnn::primitive_id reorderId = "reorder:" + outReshapeName + "_reorder"; - cldnn::layout outputLayout(cldnn::element_type_to_data_type(op->get_output_element_type(0)), outputFormat, outTensor); - auto reorder_prim = cldnn::reorder(reorderId, cldnn::input_info(layerName), outputLayout); - p.add_primitive(*op, reorder_prim); - lastLayerName = reorderId; - } - - // add reshape - auto outReshapePrim = cldnn::reshape(outReshapeName, cldnn::input_info(lastLayerName), outTensor); + auto outReshapePrim = cldnn::reshape(outReshapeName, cldnn::input_info(layerName), outputShape); p.add_primitive(*op, outReshapePrim); } - } else { - // Add actual gemm - auto alpha = 1.0f; - auto beta = 0.0f; - auto transA = op->get_transpose_a(); - auto transB = op->get_transpose_b(); - - std::array inputShapes{ - op->get_input_partial_shape(0), - op->get_input_partial_shape(1) - }; - - auto canTransposeInputs = [&] (const std::array& shapes, bool transA, bool transB, ov::element::Type type) -> bool { - if (!transA && !transB) - return false; - - // dynamic shapes and 1D tensors are not transposed - if (shapes[0].is_dynamic() || shapes[1].is_dynamic() || - shapes[0].size() < 2 || shapes[1].size() < 2) - return false; - - // don't transpose inputs if they're aligned to 16 - bool inputsAligned = std::all_of(shapes[0].rbegin(), shapes[0].rbegin() + 2, - [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() % 16 == 0; }) && - std::all_of(shapes[1].rbegin(), shapes[1].rbegin() + 2, - [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() % 16 == 0; }); - if (inputsAligned) - return false; - - // Heuristic condition for permute and tiled_opt kernel perform better than ref kernel. - bool in0_large = std::all_of(shapes[0].rbegin(), shapes[0].rbegin() + 2, - [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() >= 64; }); - bool in1_large = std::all_of(shapes[1].rbegin(), shapes[1].rbegin() + 2, - [] (const ov::Dimension& dim) { return dim.is_static() && dim.get_length() >= 64; }); - // Optimized for clDNN - auto is_u8_i8 = (type == ov::element::Type_t::i8 || type == ov::element::Type_t::u8); - bool in0_very_large = tensor_from_dims(shapes[0].to_shape()).count() > 100000; - bool in1_very_large = tensor_from_dims(shapes[0].to_shape()).count() > 100000; - bool needs_to_transpose_inputs = (in0_very_large || in1_very_large) && !is_u8_i8 && !p.get_engine().get_device_info().supports_immad; - - return (in0_large && in1_large) || needs_to_transpose_inputs; - }; - - auto transposeInput = [] (ProgramBuilder& p, const std::shared_ptr& op, const ov::PartialShape& shape, - const std::string& suffix, const cldnn::primitive_id& primitiveId) -> cldnn::input_info { - std::vector transposeOrder(shape.size()); - std::iota(transposeOrder.begin(), transposeOrder.end(), 0); - std::swap(*(transposeOrder.end() - 1), *(transposeOrder.end() - 2)); - - auto permuteName = op->get_friendly_name() + suffix; - auto permutePrim = cldnn::permute(permuteName, - cldnn::input_info(primitiveId), - transposeOrder); - p.add_primitive(*op, permutePrim); - return cldnn::input_info(permuteName); - }; - - if (canTransposeInputs(inputShapes, transA, transB, op->get_input_element_type(0))) { - if (transA) { - inputs[0] = transposeInput(p, op, inputShapes[0], "/transpose_a", inputs[0].pid); - transA = false; - } - - if (transB) { - inputs[1] = transposeInput(p, op, inputShapes[1], "/transpose_b", inputs[1].pid); - transB = false; - } - } - - auto gemmPrim = cldnn::gemm(layerName, - inputs, - cldnn::element_type_to_data_type(op->get_output_element_type(0)), - transA, - transB, - alpha, - beta, - rank_a, - rank_b); - - p.add_primitive(*op, gemmPrim); - - if (!p.use_new_shape_infer()) { - auto outDims = op->get_output_shape(0); - auto outDimsN = outDims.size(); - // Reshape output if gemm specific shape does not match default one - if (outDimsN < 4) { - auto outputShape = tensor_from_dims(outDims); - auto outReshapeName = layerName + "_cldnn_out_reshape"; - auto outReshapePrim = cldnn::reshape(outReshapeName, cldnn::input_info(layerName), outputShape); - p.add_primitive(*op, outReshapePrim); - } - } } } diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp new file mode 100644 index 00000000000000..5d4531a54967c5 --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp @@ -0,0 +1,172 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "intel_gpu/op/fully_connected.hpp" +#include "convert_matmul_to_fc.hpp" +#include "openvino/op/matmul.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/transpose.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/core/rt_info.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "transformations/utils/utils.hpp" + +namespace ov { +namespace intel_gpu { + +ConvertMatMulToFullyConnected::ConvertMatMulToFullyConnected() { + auto static_rank_gt_1 = [](const ov::Output& output) { + const auto& r = output.get_partial_shape().rank(); + return r.is_static() && r.get_length() > 1; + }; + auto weights_path = [&static_rank_gt_1](const ov::Output& output) { + const auto& pshape = output.get_partial_shape(); + return ov::op::util::is_on_constant_path(output) && + static_rank_gt_1(output) && + pshape.is_static() && + std::count_if(pshape.begin(), pshape.end(), [](const ov::Dimension& x) { return x != 1; }) <= 2; + }; + + auto activations_m = ov::pass::pattern::any_input(static_rank_gt_1); + auto weights_m = ov::pass::pattern::any_input(weights_path); + auto matmul_m = ov::pass::pattern::wrap_type({ activations_m, weights_m }, ov::pass::pattern::has_static_rank()); + + ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) { + const auto& pattern_map = m.get_pattern_value_map(); + + auto matmul = std::dynamic_pointer_cast(pattern_map.at(matmul_m).get_node_shared_ptr()); + if (!matmul || transformation_callback(matmul)) { + return false; + } + + // fc_input_a and fc_input_b - are the final inputs that will be set to FullyConnected. + // So in case of adding new operations that takes matmul inputs we need keep update fc_input_a and fc_input_b. + auto fc_input_a = pattern_map.at(activations_m); + auto fc_input_b = pattern_map.at(weights_m); + bool is_convert = false; + if (auto convert_node = std::dynamic_pointer_cast(fc_input_b.get_node_shared_ptr())) { + if (is_decompression(convert_node)) { + is_convert = true; + fc_input_b = convert_node->get_input_node_shared_ptr(0); + } else { + return false; + } + } + + auto shape_a = fc_input_a.get_partial_shape(); + auto shape_b = fc_input_b.get_partial_shape(); + OPENVINO_ASSERT(shape_b.is_static()); + + auto rank_a = shape_a.rank().get_length(); + auto rank_b = shape_b.rank().get_length(); + + /* + * get_aligned_shapes function align two input shapes to have the same size and + * the same batch dimensions (last two dimensions are not comparable). + * It also checks that dimensions are compatible so in case with two shapes + * for example: [2, 32, 64] [3, 64, 64] it will raise an exception. + */ + + auto get_aligned_shapes = [&shape_a, &shape_b, &rank_a, &rank_b, &matmul]() -> std::tuple { + ov::PartialShape shape_a_aligned(shape_a); + ov::PartialShape shape_b_aligned(shape_b); + size_t max_size = std::max(rank_a, rank_b); + for (size_t i = 0, cnt = max_size - rank_a; i < cnt; ++i) { + shape_a_aligned.insert(shape_a_aligned.begin(), 1); + } + for (size_t i = 0, cnt = max_size - rank_b; i < cnt; ++i) { + shape_b_aligned.insert(shape_b_aligned.begin(), 1); + } + + if (matmul->get_transpose_a()) { + std::swap(*(shape_a_aligned.end() - 1), *(shape_a_aligned.end() - 2)); + } + if (matmul->get_transpose_b()) { + std::swap(*(shape_b_aligned.end() - 1), *(shape_b_aligned.end() - 2)); + } + + // check on per-batch MatMul which can't be converted to FC + for (size_t i = 0; i < max_size - 2; ++i) { + if (shape_b_aligned[i] == 1) { + shape_b_aligned[i] = shape_a_aligned[i]; + } else { + return std::make_tuple(false, std::move(shape_a_aligned), std::move(shape_b_aligned)); + } + } + return std::make_tuple(true, std::move(shape_a_aligned), std::move(shape_b_aligned)); + }; + + /* + * create_transpose function return Transpose operation to replace transpose_a or transpose_b + * arguments with an operation. In other words in this function we create Transpose operation + * with order length equal to output_shape length of given node and fill order with increasing + * sequence starting from 0 and replace last two dimension. For example for length = 4 the + * order will be [0, 1, 3, 2] that emulates transpose_a or transpose_b attribute. + */ + ov::NodeVector new_ops; + + auto create_transpose = [this, &new_ops ](const ov::Output& node, const std::string& transpose_name) { + std::vector transpose_order(node.get_partial_shape().size()); + std::iota(transpose_order.begin(), transpose_order.end(), 0); + std::swap(*(transpose_order.end() - 1), *(transpose_order.end() - 2)); + + auto transpose_const = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ transpose_order.size() }, transpose_order); + auto transpose = std::make_shared(node, transpose_const); + if (!ov::is_type(transpose)) { + new_ops.push_back(transpose_const); + MatcherPass::register_new_node(transpose); + } + transpose->set_friendly_name(transpose_name); + ov::disable_constant_folding(transpose); + new_ops.push_back(transpose); + return transpose; + }; + + bool success = true; + ov::PartialShape shape_a_aligned; + ov::PartialShape shape_b_aligned; + std::tie(success, shape_a_aligned, shape_b_aligned) = get_aligned_shapes(); + if (!success) { + return false; + } + + auto aligned_a_rank = shape_a_aligned.rank(); + auto aligned_b_rank = shape_b_aligned.rank(); + if (aligned_a_rank.get_length() < 2 || aligned_b_rank.get_length() < 2) { + OPENVINO_THROW("MatMul " + matmul->get_friendly_name() + " shapes are inconsistent."); + } + + // Weights normalization + if (!matmul->get_transpose_b()) { + fc_input_b = create_transpose(fc_input_b, matmul->get_friendly_name() + "/transpose_b"); + } + + // Input normalization + if (matmul->get_transpose_a()) { + fc_input_a = create_transpose(fc_input_a, matmul->get_friendly_name() + "/transpose_a"); + } + + // Connect Convert to new input if needed + if (is_convert) { + auto convert = pattern_map.at(weights_m).get_node_shared_ptr(); + convert->input(0).replace_source_output(fc_input_b); + convert->validate_and_infer_types(); + fc_input_b = convert; + } + + // Create FullyConnected + auto fc = std::make_shared(fc_input_a, fc_input_b, matmul->get_output_element_type(0)); + fc->set_friendly_name(matmul->get_friendly_name()); + new_ops.push_back(fc); + ov::copy_runtime_info(matmul, new_ops); + ov::replace_node(matmul, fc); + return true; + }; + + auto m = std::make_shared(matmul_m); + this->register_matcher(m, callback); +} + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.hpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.hpp new file mode 100644 index 00000000000000..ab086acd81e67f --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/pass/graph_rewrite.hpp" + +namespace ov { +namespace intel_gpu { + +class ConvertMatMulToFullyConnected: public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("ConvertMatMulToFullyConnected", "0"); + ConvertMatMulToFullyConnected(); +}; + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.cpp b/src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.cpp new file mode 100644 index 00000000000000..8ed48f4768ec42 --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.cpp @@ -0,0 +1,112 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "move_fc_reshape_to_weights.hpp" +#include "intel_gpu/op/fully_connected.hpp" +#include "transformations/utils/utils.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "openvino/pass/pattern/op/or.hpp" + +#include "openvino/op/matmul.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/subtract.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/transpose.hpp" +#include "openvino/op/reshape.hpp" + +namespace ov { +namespace intel_gpu { + +MoveFCReshapeToWeights::MoveFCReshapeToWeights() { + using namespace ov::pass::pattern; + + auto weights_m = wrap_type(consumers_count(1)); + auto convert_m = wrap_type({weights_m}); + + auto sub_const_m = wrap_type(consumers_count(1)); + auto subtract_m = wrap_type({convert_m, sub_const_m}); + + auto mul_const_m = wrap_type(consumers_count(1)); + auto mul_with_sub_m = wrap_type({subtract_m, mul_const_m}, rank_equals(3)); + auto mul_no_sub_m = wrap_type({convert_m, mul_const_m}, rank_equals(3)); + auto mul_m = std::make_shared(OutputVector{mul_with_sub_m, mul_no_sub_m}); + + auto one_consumer_rank_2 = [](const ov::Output& out) { + return consumers_count(1)(out) && rank_equals(2)(out); + }; + auto reshape_const_m = wrap_type(consumers_count(1)); + auto reshape_m = wrap_type({mul_m, reshape_const_m}, one_consumer_rank_2); + + auto transpose_const_m = wrap_type(); + auto transpose_m = wrap_type({reshape_m, transpose_const_m}); + auto weights_input_m = std::make_shared(ov::OutputVector{reshape_m, transpose_m}); + + auto data_m = any_input(); + auto fully_connected_m = wrap_type({data_m, weights_input_m}); + + ov::matcher_pass_callback callback = [&](ov::pass::pattern::Matcher& m) { + const auto fully_connected = m.get_match_root(); + const auto weights_path = fully_connected->get_input_node_shared_ptr(1); + const bool with_transpose = ov::is_type(weights_path); + if (with_transpose) { + const auto transpose_const = ov::as_type_ptr(weights_path->get_input_node_shared_ptr(1)); + if (transpose_const->cast_vector() != std::vector{1, 0}) { + return false; + } + } + + const auto& fc_input_shape = fully_connected->get_input_shape(1); + const auto reshape = with_transpose ? weights_path->get_input_node_shared_ptr(0) : weights_path; + + auto check_decompression_const = [&](const std::shared_ptr& node) { + if (!ov::is_type(node)) + return false; + ov::Shape expected_shape(3, 1); + const size_t out_channels_idx = with_transpose ? 2 : 1; + expected_shape[out_channels_idx] = fc_input_shape[0]; + return node->get_output_shape(0) == expected_shape; + }; + + const auto mul = reshape->get_input_node_shared_ptr(0); + if (!check_decompression_const(mul->get_input_node_shared_ptr(1))) + return false; + const auto mul_parent = mul->get_input_node_shared_ptr(0); + const bool with_subtract = ov::is_type(mul_parent); + if (with_subtract && !check_decompression_const(mul_parent->get_input_node_shared_ptr(1))) + return false; + + const auto convert = with_subtract ? mul_parent->get_input_node_shared_ptr(0) : mul_parent; + const auto weights = convert->get_input_node_shared_ptr(0); + ov::Shape expected_weights_shape(3, 1); + expected_weights_shape[1] = fc_input_shape[with_transpose ? 1 : 0]; + expected_weights_shape[2] = fc_input_shape[with_transpose ? 0 : 1]; + if (weights->get_output_shape(0) != expected_weights_shape) + return false; + + auto squeeze_constant = [](const std::shared_ptr& node) { + const auto constant = ov::as_type_ptr(node); + auto shape = constant->get_shape(); + shape.erase(shape.begin()); + const auto new_constant = std::make_shared(*constant, shape); + ov::replace_node(constant, new_constant); + ov::copy_runtime_info(constant, new_constant); + new_constant->set_friendly_name(constant->get_friendly_name()); + }; + + // We can remove 3D->2D reshape if we manually reshape all constants in the weights subgraph + ov::replace_output_update_name(reshape->output(0), reshape->input_value(0)); + squeeze_constant(mul->get_input_node_shared_ptr(1)); + squeeze_constant(weights); + if (with_subtract) + squeeze_constant(mul_parent->get_input_node_shared_ptr(1)); + return true; + }; + + auto m = std::make_shared(fully_connected_m); + this->register_matcher(m, callback); +} + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.hpp b/src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.hpp new file mode 100644 index 00000000000000..f573abd4589e8f --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/move_fc_reshape_to_weights.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/pass/graph_rewrite.hpp" + +namespace ov { +namespace intel_gpu { + +/** + * This transformation is applied to the FC with compressed 3D u8 weights. It moves Reshape at the weights path to the constants + * in order to constant fold the Reshape node. + * Example: + * Weights(3D) Weights(2D) + * | | + * Convert Subtract_const(3D) Convert Subtract_const(2D) + * | / | / + * Subtract(optional) Subtract(optional) + * | Multiply_const(3D) ====> | Multiply_const(2D) + * | / | / + * Multiply Multiply + * | | + * Reshape(2D) | + * | | + * Data Transpose(optional) Data Transpose(optional) + * \ / \ / + * FullyConnected FullyConnected + */ +class MoveFCReshapeToWeights: public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("MoveFCReshapeToWeights", "0"); + MoveFCReshapeToWeights(); +}; + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected.cpp new file mode 100644 index 00000000000000..e10e2e2edcaba7 --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected.cpp @@ -0,0 +1,50 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "intel_gpu/op/fully_connected.hpp" +#include "matmul_shape_inference.hpp" + +namespace ov { +namespace intel_gpu { +namespace op { + +FullyConnected::FullyConnected(const ov::Output& A, + const ov::Output& B, + const ov::element::Type output_type) + : Op({A, B}), m_output_type(output_type) { + validate_and_infer_types(); +} + +std::shared_ptr FullyConnected::clone_with_new_inputs(const ov::OutputVector& new_args) const { + check_new_args_count(this, new_args); + + return std::make_shared(new_args.at(0), new_args.at(1), m_output_type); +} + +void FullyConnected::validate_and_infer_types() { + const auto input_size = get_input_size(); + NODE_VALIDATION_CHECK(this, + input_size >= 2, + "Number of inputs is incorrect. Current value is: ", + input_size, + ", expected at least 2."); + + ov::op::v0::MatMul op; + op.set_transpose_a(false); + op.set_transpose_b(true); + + auto out_shapes = ov::op::v0::shape_infer(&op, std::vector{get_input_partial_shape(0), get_input_partial_shape(1)}); + + auto output_type = m_output_type == ov::element::undefined ? get_input_element_type(0) : m_output_type; + set_output_type(0, output_type, out_shapes[0]); +} + +bool FullyConnected::visit_attributes(ov::AttributeVisitor &visitor) { + visitor.on_attribute("output_type", m_output_type); + return true; +} + +} // namespace op +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp index 4f3da690a95308..105de693b0d32d 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp @@ -103,6 +103,10 @@ #include "transformations/convert_precision.hpp" #include "transformations/init_node_info.hpp" #include "transformations/rt_info/fused_names_attribute.hpp" +#include "transformations/smart_reshape/matmul_sr.hpp" + +#include "plugin/transformations/convert_matmul_to_fc.hpp" +#include "plugin/transformations/move_fc_reshape_to_weights.hpp" #include "transformations/low_precision/mark_dequantization_subgraph.hpp" #include "low_precision/pull_reshape_through_dequantization.hpp" @@ -252,6 +256,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { manager.register_pass(); manager.register_pass(); manager.register_pass(); + manager.register_pass(); precisions_map int_convert_precision_map { {ov::element::i64, ov::element::i32}, @@ -606,6 +611,14 @@ void TransformationsPipeline::apply(std::shared_ptr func) { manager.run_passes(func); } + + { + ov::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + + manager.run_passes(func); + } } } // namespace intel_gpu } // namespace ov diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp new file mode 100644 index 00000000000000..01f7f43749bf2c --- /dev/null +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp @@ -0,0 +1,256 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph_functions/builders.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "transformations/rt_info/decompression.hpp" + +using namespace ngraph; +using namespace ov::test; + +namespace SubgraphTestsDefinitions { +/* + * Subtract_const(U8) + * / + * Weights(U8) Convert(F32) + * | / + * Convert(F32) Reshape(optional) + * \ / Multiply_const(F32) + * Subtract(optional) / + * \ Reshape(optional) + * \ / + * Multiply + * | + * Data(F32) Transpose(optional) + * \ / + * Matmul + * | + * Bias + */ +using MatmulWeightsDecompressionParams = std::tuple, // input shapes + ov::test::ElementType, // weights precision + ov::test::ElementType, // activations precision + bool, // transpose on weights + bool, // decompression subtract + bool, // reshape on decompression constants + std::map>; // additional config + +class MatmulWeightsDecompression : public testing::WithParamInterface, public SubgraphBaseTest { +public: + static std::string get_test_case_name(testing::TestParamInfo obj) { + std::vector inputShapes; + ov::test::ElementType weights_precision; + ov::test::ElementType activations_precision; + bool transpose; + bool decompression_sub; + bool reshape_on_decompression; + std::map additional_config; + + std::tie(inputShapes, + weights_precision, + activations_precision, + transpose, + decompression_sub, + reshape_on_decompression, + additional_config) = obj.param; + + std::ostringstream result; + for (const auto& shape : inputShapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << "TS="; + for (const auto& shape : inputShapes) { + result << "("; + if (!shape.second.empty()) { + auto itr = shape.second.begin(); + do { + result << ov::test::utils::vec2str(*itr); + } while (++itr != shape.second.end() && result << "_"); + } + result << ")_"; + } + result << "weights_precision=" << weights_precision << "_"; + result << "activations_precision=" << activations_precision << "_"; + result << "transpose_weights=" << transpose << "_"; + result << "decompression_subtract=" << decompression_sub << "_"; + result << "reshape_on_decompression=" << reshape_on_decompression << "_"; + + result << "config=("; + for (const auto& configEntry : additional_config) { + result << configEntry.first << ", " << configEntry.second << ":"; + } + result << ")"; + + return result.str(); + } + +protected: + std::shared_ptr init_subgraph(std::vector& inputShapes, + const ov::element::Type data_precision, + const ov::element::Type weights_precision, + const bool transpose_weights, + const bool add_subtract, + const bool reshape_on_decompression) { + ov::ParameterVector params{std::make_shared(data_precision, inputShapes[0])}; + auto transpose_if_necessary = [&](const ov::Shape& shape) { + if (!transpose_weights) + return shape; + auto transposed_shape = shape; + std::swap(*transposed_shape.rbegin(), *(transposed_shape.rbegin() + 1)); + return transposed_shape; + }; + + auto weights_shape = transpose_if_necessary(inputShapes[1].to_shape()); + auto weights = ngraph::builder::makeConstant(weights_precision, weights_shape, {}, true); + weights->set_friendly_name("Compressed_weights"); + auto weights_convert = std::make_shared(weights, data_precision); + + std::shared_ptr mul_parent = weights_convert; + auto output_channels = transpose_weights ? *(weights_shape.rbegin() + 1) : *weights_shape.rbegin(); + auto scaleshift_target_shape = transpose_if_necessary(ov::Shape{1, output_channels}); + auto scaleshift_const_shape = reshape_on_decompression ? ov::Shape{output_channels} : scaleshift_target_shape; + if (add_subtract) { + auto shift_const = ngraph::builder::makeConstant(weights_precision, scaleshift_const_shape, {}, true); + std::shared_ptr shift_convert = std::make_shared(shift_const, data_precision); + if (reshape_on_decompression) { + auto shift_reshape_const = ov::opset10::Constant::create(ov::element::i32, {scaleshift_target_shape.size()}, scaleshift_target_shape); + auto shift_reshape = std::make_shared(shift_convert, shift_reshape_const, false); + shift_convert = shift_reshape; + } + mul_parent = std::make_shared(weights_convert, shift_convert); + } + + std::shared_ptr scale_const = ngraph::builder::makeConstant(data_precision, scaleshift_const_shape, {}, true); + if (reshape_on_decompression) { + auto scale_reshape_const = ov::opset10::Constant::create(ov::element::i32, {scaleshift_target_shape.size()}, scaleshift_target_shape); + auto scale_reshape = std::make_shared(scale_const, scale_reshape_const, false); + scale_const = scale_reshape; + } + auto multiply = std::make_shared(mul_parent, scale_const); + + std::shared_ptr matmul_weights = multiply; + if (transpose_weights) { + const size_t rank = matmul_weights->get_output_partial_shape(0).size(); + std::vector order(rank); + std::iota(order.begin(), order.end(), 0); + std::swap(*order.rbegin(), *(order.rbegin() + 1)); + auto transpose_constant = ov::opset10::Constant::create(ov::element::i32, {rank}, order); + auto transpose = std::make_shared(matmul_weights, transpose_constant); + matmul_weights = transpose; + } + auto matMul = builder::makeMatMul(params[0], matmul_weights); + return std::make_shared(NodeVector{matMul}, params, "MatmulWeightsDecompression"); + } + + void SetUp() override { + targetDevice = ov::test::utils::DEVICE_GPU; + + std::vector inputShapes; + ov::test::ElementType weights_precision; + ov::test::ElementType activations_precision; + bool transpose_weights; + bool decompression_sub; + bool reshape_on_decompression; + std::map additional_config; + + std::tie(inputShapes, + weights_precision, + activations_precision, + transpose_weights, + decompression_sub, + reshape_on_decompression, + additional_config) = GetParam(); + + configuration.insert(additional_config.begin(), additional_config.end()); + init_input_shapes(inputShapes); + + inType = outType = activations_precision; + + function = init_subgraph(inputDynamicShapes, activations_precision, weights_precision, transpose_weights, decompression_sub, reshape_on_decompression); + } + + void checkResults() { + const auto& test_param = GetParam(); + ov::test::ElementType weights_precision = std::get<1>(test_param); + for (const auto& n : compiledModel.get_runtime_model()->get_ordered_ops()) { + if (n->get_friendly_name() == "Compressed_weights") { + ASSERT_EQ(n->get_output_element_type(0), weights_precision); + } + } + } +}; + +TEST_P(MatmulWeightsDecompression, CompareWithRefs) { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + run(); + checkResults(); +} + +namespace { + +const std::vector activations_precisions = {ov::element::f32, ov::element::f16}; +const std::vector weights_precisions = {ov::element::u8}; +const std::vector> input_shapes_basic = { + {{{-1, -1, -1}, {{1, 4, 16}, {10, 16, 16}}}, {{}, {{16, 32}}}}, + {{{}, {{1, 4, 16}}}, {{}, {{1, 16, 32}}}}, + {{{}, {{10, 40, 496}}}, {{}, {{1, 496, 240}}}}, + {{{}, {{1, 4, 48}}}, {{}, {{48, 256}}}}, + {{{}, {{11, 339, 377}}}, {{}, {{377, 335}}}}, + {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {{}, {{1, 480, 256}}}}, + {{{}, {{1, 4, 32}}}, {{}, {{32, 256}}}}, + {{{}, {{1, 4, 512}}}, {{}, {{512, 256}}}}, + {{{}, {{1, 16, 32}}}, {{}, {{32, 64}}}}, + {{{}, {{2, 4, 32}}}, {{}, {{32, 65}}}}, + {{{}, {{3, 12, 768}}}, {{}, {{768, 1024}}}}, + {{{}, {{11, 339, 577}}}, {{}, {{577, 335}}}}, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic, + MatmulWeightsDecompression, + ::testing::Combine(::testing::ValuesIn(input_shapes_basic), + ::testing::ValuesIn(weights_precisions), + ::testing::ValuesIn(activations_precisions), + ::testing::Values(true), + ::testing::Values(true), + ::testing::Values(true), + ::testing::Values(std::map())), + MatmulWeightsDecompression::get_test_case_name); + +const std::vector> input_shapes_corner_cases_basic = { + {{{-1, -1, -1}, {{1, 4, 16}}}, {{}, {{1, 16, 32}}}}, + {{{-1, -1, -1}, {{1, 4, 16}}}, {{}, {{16, 32}}}}, +}; +const std::vector> input_shapes_corner_cases_big = { + {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {{}, {{1, 480, 256}}}}, +}; + +const std::vector transpose_weights = {true, false}; +const std::vector add_decompression_sub = {true, false}; +const std::vector reshape_on_decompression = {true, false}; + +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_basic, + MatmulWeightsDecompression, + ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases_basic), + ::testing::ValuesIn(weights_precisions), + ::testing::ValuesIn(activations_precisions), + ::testing::ValuesIn(transpose_weights), + ::testing::ValuesIn(add_decompression_sub), + ::testing::ValuesIn(reshape_on_decompression), + ::testing::Values(std::map{})), + MatmulWeightsDecompression::get_test_case_name); + +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_big, + MatmulWeightsDecompression, + ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases_big), + ::testing::ValuesIn(weights_precisions), + ::testing::ValuesIn(activations_precisions), + ::testing::ValuesIn(transpose_weights), + ::testing::ValuesIn(add_decompression_sub), + ::testing::ValuesIn(reshape_on_decompression), + ::testing::Values(std::map{})), + MatmulWeightsDecompression::get_test_case_name); +} // namespace + +} // namespace SubgraphTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/unit/CMakeLists.txt b/src/plugins/intel_gpu/tests/unit/CMakeLists.txt index 9a144cbdb7d5bd..fd5d039fe877ab 100644 --- a/src/plugins/intel_gpu/tests/unit/CMakeLists.txt +++ b/src/plugins/intel_gpu/tests/unit/CMakeLists.txt @@ -63,6 +63,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_graph gtest gtest_main gflags + common_test_utils openvino::reference inference_engine_transformations gmock) diff --git a/src/plugins/intel_gpu/tests/unit/transformations/convert_matmul_to_fc_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/convert_matmul_to_fc_test.cpp new file mode 100644 index 00000000000000..4dd06da5ff5d0b --- /dev/null +++ b/src/plugins/intel_gpu/tests/unit/transformations/convert_matmul_to_fc_test.cpp @@ -0,0 +1,386 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common_test_utils/ov_test_utils.hpp" +#include "transformations/rt_info/decompression.hpp" + +using namespace testing; +using namespace ov::intel_gpu; + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest1) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 3, 2, 2 }); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 1, 2, 2 }, { 1 }); + auto matmul = std::make_shared(input1, input2, true, false); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 3, 2, 2 }); + auto transpose_constant1 = ov::opset1::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 2, 1 }); + auto transpose1 = std::make_shared(input1, transpose_constant1); + + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 1, 2, 2 }, { 1 }); + auto transpose_constant2 = ov::opset1::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 2, 1 }); + auto transpose2 = std::make_shared(input2, transpose_constant2); + + auto matmul = std::make_shared(transpose1, transpose2); + + model_ref = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest2) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 1, 2}); + auto input2 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 1}); + auto matmul = std::make_shared(input1, input2, false, false); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1, input2}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 1, 2}); + auto input2 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 1}); + auto matmul = std::make_shared(input1, input2, false, false); + + model_ref = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1, input2}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest3) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{2, 2}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{2, 2}, {1}); + auto matmul = std::make_shared(input1, input2); + + model_ref = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest4) { + { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{-1, -1, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{2, 2}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{-1, -1, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{2, 2}, {1}); + auto matmul = std::make_shared(input1, input2); + + model_ref = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest5) { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{ -1, -1, 2 }); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 3, 2, 2 }, { 1 }); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest6) { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{ -1, -1, 2 }); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 3, 1, 2 }, { 1 }); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest7) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{3, 2}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{3, 2}, {1}); + auto fc = std::make_shared(input1, input2); + + model_ref = std::make_shared(ov::NodeVector{fc}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest8) { + { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{-1, -1, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{3, 2}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{-1, -1, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{3, 2}, {1}); + + auto fc = std::make_shared(input1, input2); + auto a_shape = std::make_shared(input1); + + auto I = ov::op::util::node_to_get_shape_value_of_indices_from_shape_node(a_shape, {0, 1}); + auto O = ov::opset1::Constant::create(ov::element::i64, { 1 }, { 3 }); + auto output_shape = std::make_shared(ov::OutputVector{I, O}, 0); + + model_ref = std::make_shared(ov::NodeVector{fc}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest9) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{2, 2}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{2, 2}, {1}); + auto matmul = std::make_shared(input1, input2); + + model_ref = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest10) { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape::dynamic()); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 2, 2 }, { 1 }); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest11) { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{18, -1, 1}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{18, 80, 1}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest12) { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{1, -1, 1}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{2, 80, 1}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest13) { + { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{-1, -1, 1}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 80, 1}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::PartialShape{-1, -1, 1}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 80, 1}, {1}); + auto matmul = std::make_shared(input1, input2); + + model_ref = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest14) { + { + auto input1 = std::make_shared(ov::element::u8, ov::PartialShape{-1, -1, 1}); + auto input2 = ov::opset1::Constant::create(ov::element::i8, ov::Shape{1, 80, 1}, {1}); + auto matmul = std::make_shared>( + ov::element::TypeVector{ov::element::f32, ov::element::f32}, + ov::element::TypeVector{ov::element::f32}, + ov::op::TemporaryReplaceOutputType(input1, ov::element::f32).get(), + ov::op::TemporaryReplaceOutputType(input2, ov::element::f32).get(), + false, + true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::u8, ov::PartialShape{-1, -1, 1}); + auto input2 = ov::opset1::Constant::create(ov::element::i8, ov::Shape{1, 80, 1}, {1}); + auto matmul = std::make_shared(input1, input2, ov::element::f32); + + model_ref = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest_second_input_rank_adj_1) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{5, 2, 3}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 2, 3}, {1}); + auto matmul = std::make_shared(input1, input2, false, true); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{5, 2, 3}); + auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 2, 3}, {1}); + auto matmul = std::make_shared(input1, input2); + model_ref = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{input1}); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest_second_input_rank_adj_2) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 2, 3 }); + auto weights = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 2, 3 }, { 1 }); + auto matmul = std::make_shared(input1, weights, false, true); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 2, 3 }); + auto weights = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 2, 3 }, { 1 }); + auto matmul = std::make_shared(input1, weights); + + model_ref = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest_second_input_rank_adj_3) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 5, 2, 3 }); + auto weights = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 1, 2, 3 }, { 1 }); + auto matmul = std::make_shared(input1, weights, false, true); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 5, 2, 3 }); + + auto weights = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 1, 2, 3 }, { 1 }); + auto matmul = std::make_shared(input1, weights); + model_ref = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest_decompress_convert_0) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 3, 2, 2 }); + auto input2 = ov::opset1::Constant::create(ov::element::f16, ov::Shape{ 1, 2, 2 }, { 1 }); + auto convert = std::make_shared(input2, ov::element::f32); + ov::mark_as_decompression(convert); + auto matmul = std::make_shared(input1, convert, false, false); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 3, 2, 2 }); + + auto input2 = ov::opset1::Constant::create(ov::element::f16, ov::Shape{ 1, 2, 2 }, { 1 }); + auto transpose_constant = ov::opset1::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 2, 1 }); + auto transpose = std::make_shared(input2, transpose_constant); + auto convert = std::make_shared(transpose, ov::element::f32); + + auto matmul = std::make_shared(input1, convert); + + model_ref = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest_decompress_convert_1) { + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 3, 2, 2 }); + auto input2 = ov::opset1::Constant::create(ov::element::f16, ov::Shape{ 1, 2, 2 }, { 1 }); + auto convert = std::make_shared(input2, ov::element::f32); + ov::mark_as_decompression(convert); + auto matmul = std::make_shared(input1, convert, true, false); + + model = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + manager.register_pass(); + } + { + auto input1 = std::make_shared(ov::element::f32, ov::Shape{ 3, 2, 2 }); + auto transpose_constant1 = ov::opset1::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 2, 1 }); + auto transpose1 = std::make_shared(input1, transpose_constant1); + + auto input2 = ov::opset1::Constant::create(ov::element::f16, ov::Shape{ 1, 2, 2 }, { 1 }); + auto transpose_constant2 = ov::opset1::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 2, 1 }); + auto transpose2 = std::make_shared(input2, transpose_constant2); + auto convert = std::make_shared(transpose2, ov::element::f32); + + auto matmul = std::make_shared(transpose1, convert); + + model_ref = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ input1 }); + } +} + +TEST_F(TransformationTestsF, ConvertMatMulToFullyConnectedTest_compressed_u8_weights) { + { + auto data = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto weights = ov::opset1::Constant::create(ov::element::u8, ov::Shape{1, 2, 2}, {1}); + auto convert = std::make_shared(weights, ov::element::f32); + auto sub_const = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 1, 2}, {1}); + auto sub = std::make_shared(convert, sub_const); + auto mul_const = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 1, 2}, {1}); + auto mul = std::make_shared(sub, mul_const); + auto matmul = std::make_shared(data, mul); + + model = std::make_shared(ov::NodeVector{matmul}, ov::ParameterVector{data}); + manager.register_pass(); + } + { + auto data = std::make_shared(ov::element::f32, ov::Shape{3, 2, 2}); + auto weights = ov::opset1::Constant::create(ov::element::u8, ov::Shape{1, 2, 2}, {1}); + auto convert = std::make_shared(weights, ov::element::f32); + auto sub_const = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 1, 2}, {1}); + auto sub = std::make_shared(convert, sub_const); + auto mul_const = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 1, 2}, {1}); + auto mul = std::make_shared(sub, mul_const); + + auto transpose_const = ov::opset1::Constant::create(ov::element::i32, {3}, {0, 2, 1}); + auto transpose = std::make_shared(mul, transpose_const); + auto matmul = std::make_shared(data, transpose); + + model_ref = std::make_shared(ov::NodeVector{ matmul }, ov::ParameterVector{ data }); + } +} diff --git a/src/plugins/intel_gpu/tests/unit/transformations/move_fc_reshape_to_weights.cpp b/src/plugins/intel_gpu/tests/unit/transformations/move_fc_reshape_to_weights.cpp new file mode 100644 index 00000000000000..8b760790e34aaa --- /dev/null +++ b/src/plugins/intel_gpu/tests/unit/transformations/move_fc_reshape_to_weights.cpp @@ -0,0 +1,107 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "common_test_utils/ov_test_utils.hpp" + +using namespace testing; +using namespace ov::intel_gpu; + +using MoveFCReshapeToWeightsParams = std::tuple, // data_shape - weights_shape + bool, // add transpose + bool>; // add subtract + +class MoveFCReshapeToWeightsTests : public TransformationTestsF, public WithParamInterface { +public: + static std::string get_test_case_name(testing::TestParamInfo obj) { + std::pair input_shapes; + bool add_transpose; + bool add_subtract; + std::tie(input_shapes, add_transpose, add_subtract) = obj.param; + + std::ostringstream result; + result << "Input_shape=(" << input_shapes.first << ")_Weights_shape=(" << input_shapes.second + << ")_add_transpose=" << add_transpose << "_add_subtract=" << add_subtract; + return result.str(); + } + + static std::shared_ptr init_model(const ov::PartialShape& data_shape, + const ov::Shape& weights_shape, + const bool add_transpose, + const bool add_subtract, + const bool add_reshape) { + auto data = std::make_shared(ov::element::f32, data_shape); + auto transposed_shape = weights_shape; + if (add_transpose) + std::swap(*(transposed_shape.rbegin() + 1), *transposed_shape.rbegin()); + std::shared_ptr weights_path = ov::opset1::Constant::create(ov::element::u8, transposed_shape, {1}); + weights_path = std::make_shared(weights_path, ov::element::f32); + + ov::Shape decompression_shape(weights_shape.size(), 1); + const size_t n_idx = add_transpose ? transposed_shape.size() - 1 : transposed_shape.size() - 2; + decompression_shape[n_idx] = transposed_shape[n_idx]; + + if (add_subtract) { + auto sub_const = ov::opset1::Constant::create(ov::element::f32, decompression_shape, {1}); + weights_path = std::make_shared(weights_path, sub_const); + } + auto mul_const = ov::opset1::Constant::create(ov::element::f32, decompression_shape, {1}); + weights_path = std::make_shared(weights_path, mul_const); + + if (add_reshape) { + auto target_shape = transposed_shape; + target_shape.erase(target_shape.begin()); + auto reshape_const = ov::opset1::Constant::create(ov::element::i32, {2}, target_shape); + weights_path = std::make_shared(weights_path, reshape_const, false); + } + if (add_transpose) { + auto transpose_const = ov::opset1::Constant::create(ov::element::i32, {2}, {1, 0}); + weights_path = std::make_shared(weights_path, transpose_const); + } + auto fully_connected = std::make_shared(data, weights_path); + return std::make_shared(ov::NodeVector{fully_connected}, ov::ParameterVector{data}); + } + +protected: + void SetUp() override { + TransformationTestsF::SetUp(); + std::pair input_shapes; + bool add_transpose; + bool add_subtract; + std::tie(input_shapes, add_transpose, add_subtract) = this->GetParam(); + + ov::Shape ref_weights_shape = input_shapes.second; + ref_weights_shape.erase(ref_weights_shape.begin()); + model = init_model(input_shapes.first, input_shapes.second, add_transpose, add_subtract, true); + model_ref = init_model(input_shapes.first, ref_weights_shape, add_transpose, add_subtract, false); + manager.register_pass(); + } +}; + +TEST_P(MoveFCReshapeToWeightsTests, CompareFunctions) {} + +const std::vector> input_shapes_wo_transpose = { + {{-1, -1, -1}, {1, 4, 3}} +}; +const std::vector add_transpose = {false, true}; +const std::vector add_subtract = {false, true}; + +INSTANTIATE_TEST_SUITE_P(smoke_TransformationTests_wo_transpose, MoveFCReshapeToWeightsTests, + ::testing::Combine( + ::testing::ValuesIn(input_shapes_wo_transpose), + ::testing::ValuesIn(add_transpose), + ::testing::ValuesIn(add_subtract)), + MoveFCReshapeToWeightsTests::get_test_case_name); From 188d53d8138c099a92d9d6bdaf306593b8efb8c3 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Tue, 5 Sep 2023 17:07:13 +0400 Subject: [PATCH 04/31] [TF Hub][TF FE] Clean-up all downloaded files for TF Hub models validation (#19612) Signed-off-by: Kazantsev, Roman --- .../models_hub_common/constants.py | 7 +++++++ .../tf_hub_tests/test_tf_hub_convert_model.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/model_hub_tests/models_hub_common/constants.py b/tests/model_hub_tests/models_hub_common/constants.py index 65abfdf436a9ad..a4c5934d5ea49b 100644 --- a/tests/model_hub_tests/models_hub_common/constants.py +++ b/tests/model_hub_tests/models_hub_common/constants.py @@ -3,6 +3,13 @@ # SPDX-License-Identifier: Apache-2.0 import os +import tempfile + +if os.environ.get('TFHUB_CACHE_DIR') is not None: + tf_hub_cache_dir = os.environ['TFHUB_CACHE_DIR'] +else: + tf_hub_cache_dir = os.path.join(tempfile.gettempdir(), "tfhub_modules") + os.environ['TFHUB_CACHE_DIR'] = tf_hub_cache_dir # supported_devices : CPU, GPU, GNA test_device = os.environ.get('TEST_DEVICE', 'CPU;GPU').split(';') diff --git a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py index 6ae10afa2c5c6f..2640e8214e9044 100644 --- a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py +++ b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py @@ -1,7 +1,9 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import gc import os +import shutil import numpy as np import pytest @@ -9,6 +11,7 @@ import tensorflow_hub as hub # noinspection PyUnresolvedReferences import tensorflow_text # do not delete, needed for text models +from models_hub_common.constants import tf_hub_cache_dir from models_hub_common.test_convert_model import TestConvertModel from models_hub_common.utils import get_models_list @@ -79,6 +82,20 @@ def infer_fw_model(self, model_obj, inputs): fw_outputs[internal_name] = out_value return fw_outputs + def teardown_method(self): + # remove all downloaded files for TF Hub models + for file_name in os.listdir(tf_hub_cache_dir): + file_path = os.path.join(tf_hub_cache_dir, file_name) + try: + if os.path.isfile(file_path) or os.path.islink(file_path): + os.unlink(file_path) + elif os.path.isdir(file_path): + shutil.rmtree(file_path) + except Exception as e: + pass + # deallocate memory after each test case + gc.collect() + @pytest.mark.parametrize("model_name,model_link,mark,reason", get_models_list(os.path.join(os.path.dirname(__file__), "precommit_models"))) @pytest.mark.precommit From bf5690fa7dcbed5cb2bb5eca91aa4108c54b752f Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 5 Sep 2023 16:23:17 +0200 Subject: [PATCH 05/31] [GA] Parallel tests (#18773) * test job * added script to the test package * test call fix * switched test to large runner * Added option to split tests by suites * extended logs * enabled test cache * fixed workload * optimized splitting mode * excluded disabled suites * temroary removed parallel logs * added failed logs * fixed empty name in suites * test on 4 cores * make step optional * fixed param * test * grouping suites * set suite arg * increase test timeout * test commit * test pip deps * include requirements.txt to the test package * fixed deps step order * fixed test counter * fixed smart filter for suites * clean up * disabled repeat failed tests * review comments * use runtime execution time for skipped tests * removed disabled suites * reduced command lines * enabled tests results * fixed typo * removed unused argument pp * Log improvements * merge cached and runtime filters * fixed order * fixed init list error * fixed cache writing * enable windows pipeline * changed runner for windows * optimized balancing using heap * Fixed test counter * fixed windows pipeline * extended logging * changed pipelines * added logs on Windows * fixed pipelines * debug * removed os specific code * fixed "#" * fixed test results * fixed win pipeline * cleanup debug * rebase fixes * windows pip requirements * aligned run_conformance.py * Apply suggestions from code review Co-authored-by: Andrey Kashchikhin * reverted windows changes * reverted build runner * fixed review comments * minor review fixes * make help func static * renamed test runner * fixed merge issue * removed unused log * reduced command line * fixed issue fith conformance run * fixed typo * set testa as default split unit * fixed tasks queue with time -1 * fixed test result caculation * reverted wrong fix * reverted changes * set time limitation * reverted unused change * fix win command lines * reuse env variables in pipeline * fixed install files permissions * fixed pipeline syntax * reset validation schema * fixed env names * reverted initial setting of env * increased test runner * fixed pathes * reuse env path * reset validation schema * Revert "reuse env path" This reverts commit 97422ac5957dbe04ef7b65e5ef74e6bc6a541acd. * Revert "increased test runner" This reverts commit 010aa31641fca5562caafb4962ecd4ddadd8f582. * revert command line reduction * made if condition clearer --------- Co-authored-by: Andrey Kashchikhin --- .github/workflows/linux.yml | 29 +- .../functional_test_utils/CMakeLists.txt | 4 + .../layer_tests_summary/run_conformance.py | 26 +- .../layer_tests_summary/run_parallel.py | 356 ++++++++++-------- .../layer_tests_summary/utils/constants.py | 3 + 5 files changed, 248 insertions(+), 170 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7fe5e42e216ac7..3dc75adf3c9384 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -749,10 +749,12 @@ jobs: defaults: run: shell: bash - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest-4-cores env: INSTALL_DIR: ${{ github.workspace }}/install INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests + PARALLEL_TEST_SCRIPT: ${{ github.workspace }}/install/tests/functional_test_utils/run_parallel.py + PARALLEL_TEST_CACHE: ${{ github.workspace }}/install/tests/test_cache.lst steps: - name: Create Directories @@ -784,15 +786,34 @@ jobs: tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_tests.tar.gz || exit 1 popd - - name: Intel CPU plugin func tests + - name: Install python dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}/functional_test_utils/requirements.txt + + - name: Cache Tests Execution Time + id: tests-functional-cpu-cache + uses: actions/cache@v3 + with: + path: ${{ env.PARALLEL_TEST_CACHE }} + key: ${{ runner.os }}-tests-functional-cpu-cache + + - name: Intel CPU plugin func tests (parallel) run: | source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_cpu_func_tests --gtest_print_time=1 --gtest_filter=*smoke* --gtest_output=xml:"${{ env.INSTALL_TEST_DIR }}/TEST-CPUFuncTests.xml" + python3 ${{ env.PARALLEL_TEST_SCRIPT }} -e ${{ env.INSTALL_TEST_DIR }}/ov_cpu_func_tests -c ${{ env.PARALLEL_TEST_CACHE }} -w ${{ env.INSTALL_TEST_DIR }} -s suite -rf 0 -- --gtest_print_time=1 --gtest_filter=*smoke* + timeout-minutes: 25 - name: Upload Test Results uses: actions/upload-artifact@v3 if: ${{ always() }} with: name: test-results-functional-cpu - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml + path: | + ${{ env.INSTALL_TEST_DIR }}/TEST*.xml + ${{ env.INSTALL_TEST_DIR }}/logs/failed/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/crashed/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/hanged/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/interapted/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/disabled_tests.log if-no-files-found: 'error' diff --git a/src/tests/test_utils/functional_test_utils/CMakeLists.txt b/src/tests/test_utils/functional_test_utils/CMakeLists.txt index a164bbdd180225..15b7bc0167f0df 100644 --- a/src/tests/test_utils/functional_test_utils/CMakeLists.txt +++ b/src/tests/test_utils/functional_test_utils/CMakeLists.txt @@ -29,6 +29,10 @@ addIeTarget( $ ) +install(PROGRAMS layer_tests_summary/run_parallel.py DESTINATION tests/functional_test_utils COMPONENT tests EXCLUDE_FROM_ALL) +install(FILES layer_tests_summary/requirements.txt DESTINATION tests/functional_test_utils COMPONENT tests EXCLUDE_FROM_ALL) +install(DIRECTORY layer_tests_summary/utils DESTINATION tests/functional_test_utils COMPONENT tests EXCLUDE_FROM_ALL) + ie_faster_build(${TARGET_NAME} PCH PRIVATE "src/precomp.hpp" ) diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py index 96d641494a43b8..8c64a0eeb9d3d7 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py @@ -141,7 +141,7 @@ def __download_models(self, url_to_download, path_to_save): logger.info(f"The file {download_path} is archieve. Should be unzip to {path_to_save}") return file_utils.unzip_archieve(download_path, path_to_save) return download_path - + def __dump_subgraph(self): subgraph_dumper_path = os.path.join(self._ov_path, f'{SUBGRAPH_DUMPER_BIN_NAME}{constants.OS_BIN_FILE_EXT}') @@ -196,7 +196,7 @@ def __check_expected_failures(self): if len(diff) > 0: logger.error(f"Unexpected failures: {diff}") exit(-1) - + intersection = self._expected_failures.intersection(this_run_failures) if this_run_failures != self._expected_failures and self._expected_failures_update: logger.info(f"Expected failures file {self._expected_failures} will be updated!!!") @@ -225,19 +225,21 @@ def __run_conformance(self): os.mkdir(report_dir) if not os.path.isdir(logs_dir): os.mkdir(logs_dir) - - command_line_args = [f"--device={self._device}", + + command_line_args = [f"--device={self._device}", f'--input_folders="{self._model_path}"' if self._type == constants.OP_CONFORMANCE else '', f"--report_unique_name", f'--output_folder="{parallel_report_dir}"', f'--gtest_filter=\"{self._gtest_filter}\"', f'--config_path="{self._ov_config_path}"', f'--shape_mode={self._special_mode}'] - conformance = TestParallelRunner(f"{conformance_path}", - command_line_args, - self._workers, - logs_dir, - self._cache_path, - self._is_parallel_over_devices, - self._expected_failures if not self._expected_failures_update else set()) + conformance = TestParallelRunner(exec_file_path=f"{conformance_path}", + test_command_line=command_line_args, + worker_num=self._workers, + working_dir=logs_dir, + cache_path=self._cache_path, + split_unit=constants.TEST_UNIT_NAME, + repeat_failed=1, + is_parallel_devices=self._is_parallel_over_devices, + excluded_tests=self._expected_failures if not self._expected_failures_update else set()) conformance.run() conformance.postprocess_logs() @@ -319,4 +321,4 @@ def run(self, dump_models: bool): args.parallel_devices, args.expected_failures, args.expected_failures_update) conformance.run(args.dump_graph) - + diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py index e04b972eb0d45f..b0832867ea219b 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py @@ -21,6 +21,7 @@ import csv import datetime import shlex +import heapq if sys.version_info.major >= 3: import _thread as thread @@ -38,6 +39,7 @@ FILENAME_LENGTH = 255 LOG_NAME_REPLACE_STR = "##NAME##" DEFAULT_PROCESS_TIMEOUT = 3600 +DEFAULT_SUITE_TIMEOUT = 3600 DEFAULT_TEST_TIMEOUT = 900 MAX_LENGHT = 4096 if not constants.IS_WIN else 8191 @@ -45,17 +47,22 @@ def parse_arguments(): parser = ArgumentParser() exec_file_path_help = "Path to the test executable file" cache_path_help = "Path to the cache file with test_name list sorted by execution time. .lst file!" - worker_num_help = "Worker number. Default value is `cpu_count-1` " + worker_num_help = "Worker number. Default value is `cpu_count` " working_dir_num_help = "Working dir" process_timeout_help = "Process timeout in s" parallel_help = "Parallel over HW devices. For example run tests over GPU.0, GPU.1 and etc" + split_unit_help = "Split by test or suite" + repeat_help = "Number of times to repeat failed and interrupted tests" parser.add_argument("-e", "--exec_file", help=exec_file_path_help, type=str, required=True) parser.add_argument("-c", "--cache_path", help=cache_path_help, type=str, required=False, default="") - parser.add_argument("-j", "--workers", help=worker_num_help, type=int, required=False, default=(os.cpu_count() - 1) if os.cpu_count() > 2 else 1) + parser.add_argument("-j", "--workers", help=worker_num_help, type=int, required=False, default=os.cpu_count()) parser.add_argument("-p", "--parallel_devices", help=parallel_help, type=int, required=False, default=0) parser.add_argument("-w", "--working_dir", help=working_dir_num_help, type=str, required=False, default=".") parser.add_argument("-t", "--process_timeout", help=process_timeout_help, type=int, required=False, default=DEFAULT_PROCESS_TIMEOUT) + parser.add_argument("-s", "--split_unit", help=split_unit_help, type=str, required=False, default=constants.TEST_UNIT_NAME) + parser.add_argument("-rf", "--repeat_failed", help=repeat_help, type=int, required=False, default=1) + return parser.parse_args() def get_test_command_line_args(): @@ -82,7 +89,7 @@ def get_device_by_args(args: list): break return device -# Class to read test cache +# Class to read test cache class TestStructure: _name = "" _time = 0 @@ -147,7 +154,7 @@ def kill_process_tree(pid): # logger.warning(f"Impossible to kill process {pid} with error: {err}") pass - + def __find_free_process(self): while True: for pid in range(len(self._process_list)): @@ -184,8 +191,8 @@ def update_worker(self): self._timers[pid] = datetime.datetime.now() self._idx += 1 return True - - def compelete_all_processes(self): + + def compelete_all_processes(self): while len(self._process_list) > 0: for pid in range(len(self._process_list)): try: @@ -206,7 +213,7 @@ def compelete_all_processes(self): class TestParallelRunner: def __init__(self, exec_file_path: os.path, test_command_line: list, worker_num: int, working_dir: os.path, cache_path: os.path, - is_parallel_devices=False, excluded_tests=set()): + split_unit: str, repeat_failed: int, is_parallel_devices=False, excluded_tests=set()): self._exec_file_path = exec_file_path self._working_dir = working_dir self._conformance_ir_filelists = list() @@ -221,17 +228,19 @@ def __init__(self, exec_file_path: os.path, test_command_line: list, if not os.path.exists(head): os.mkdir(head) self._is_save_cache = True + if split_unit in constants.UNIT_NAMES: + self._split_unit = split_unit + else: + logger.error(f"Incorrect split_unit argument: {split_unit}. Please use the following values: {','.join(constants.UNIT_NAMES)}") + sys.exit(-1) + self._repeat_failed = repeat_failed self._disabled_tests = list() self._total_test_cnt = 0 self._device = get_device_by_args(self._command.split()) self._available_devices = [self._device] if not self._device is None else [] if has_python_api and is_parallel_devices: self._available_devices = get_available_devices(self._device) - self._excluded_tests_re = set() - self._orig_excluded_tests = excluded_tests - for test in excluded_tests: - self._excluded_tests_re.add(f'"{self.__replace_restricted_symbols(test)}":') - + self._excluded_tests = excluded_tests def __init_basic_command_line_for_exec_file(self, test_command_line: list): command = f'{self._exec_file_path}' @@ -241,6 +250,8 @@ def __init_basic_command_line_for_exec_file(self, test_command_line: list): is_input_folder = True command += f" --input_folders=" argument = argument[argument.find("=")+1:] + elif "--gtest_filter" in argument: + self._gtest_filter = argument[argument.find("=")+1:] if is_input_folder and argument[0] != "-": buf = "" for _ in argument.split(','): @@ -250,13 +261,33 @@ def __init_basic_command_line_for_exec_file(self, test_command_line: list): buf = file_utils.prepare_filelist(input_path, ["*.xml"]) self._conformance_ir_filelists.append(buf) buf += "," - argument = buf + argument = buf else: is_input_folder = False command += f" " command += f"{argument}" return command + @staticmethod + def __get_suite_filter(test_filter: str, suite_filter: str): + filters = test_filter.split(':') + suite_filter_mixed = '' + for filter in filters: + patterns = filter.strip('\"').split('*') + suite_filter = f'{suite_filter}*' + suite_filter_part = suite_filter + for pattern in patterns: + if pattern and suite_filter.find(pattern) == -1: + suite_filter_part += f'{pattern}*' + if suite_filter_part == suite_filter: + suite_filter_mixed = f'"{suite_filter_part}"' + break + if not suite_filter_mixed: + suite_filter_mixed = f'"{suite_filter_part}"' + else: + suite_filter_mixed += f':"{suite_filter_part}"' + return suite_filter_mixed + @staticmethod def __replace_restricted_symbols(input_string:str): restricted_symbols = "!@$%^&-+`~:;\",<>?" @@ -264,7 +295,9 @@ def __replace_restricted_symbols(input_string:str): input_string = input_string.replace(symbol, '*') return input_string - def __get_test_list_by_runtime(self): + def __get_test_list_by_runtime(self, test_unit = constants.TEST_UNIT_NAME): + self._total_test_cnt = 0 + self._disabled_tests.clear() test_list_file_name = os.path.join(self._working_dir, "test_list.lst") if os.path.isfile(test_list_file_name): try: @@ -282,156 +315,147 @@ def __get_test_list_by_runtime(self): logger.error(f"The test list file does not exists! Please check the process output!") exit(-1) - test_list = list() + tests_dict = dict() with open(test_list_file_name) as test_list_file: test_suite = "" for test_name in test_list_file.read().split('\n'): if "Running main() from" in test_name: continue if not ' ' in test_name: - test_suite = test_name + test_suite = test_name.replace(".", "") continue - pos = test_name.find('#') + pos = test_name.find(' # ') if pos > 0 or test_suite != "": - real_test_name = test_suite + (test_name[2:pos-2] if pos > 0 else test_name[2:]) + real_test_name = test_suite + "." + (test_name[2:pos-1] if pos > 0 else test_name[2:]) if constants.DISABLED_PREFIX in real_test_name: self._disabled_tests.append(real_test_name) - else: - test_list.append(f'"{self.__replace_restricted_symbols(real_test_name)}":') + elif test_unit == constants.TEST_UNIT_NAME: + tests_dict[real_test_name] = 1 + self._total_test_cnt += 1 + elif test_unit == constants.SUITE_UNIT_NAME: + tests_dict[test_suite] = tests_dict.get(test_suite, 0) + 1 + self._total_test_cnt += 1 test_list_file.close() os.remove(test_list_file_name) - logger.info(f"Len test_list_runtime (without disabled tests): {len(test_list)}") - if len(test_list) == 0: + logger.info(f"Len test_list_runtime (without disabled tests): {len(tests_dict)}") + if len(tests_dict) == 0: logger.warning(f"Look like there are not tests to run! Please check the filters!") exit(0) - return test_list + return tests_dict def __get_test_list_by_cache(self): - test_list_cache = list() + tests_dict_cache = dict() if os.path.isfile(self._cache_path): logger.info(f"Get test list from cache file: {self._cache_path}") with open(self._cache_path, "r") as cache_file: for line in cache_file.readlines(): pos = line.find(":") - time = line[:pos] - test_name = line[pos+1:] - if not constants.DISABLED_PREFIX in test_name: - test_list_cache.append(TestStructure(test_name.replace("\n", ""), time)) - logger.info(f"Len test_list_cache: {len(test_list_cache)}") - return test_list_cache - - def __generate_test_lists(self, test_list_cache: list, test_list_runtime:list): - cached_test_list = list() - runtime_test_test = list() - cached_test_list_names = list() - - for test in test_list_cache: - if test._name in test_list_runtime and not test in self._excluded_tests_re: - cached_test_list.append(test) - cached_test_list_names.append(test._name) - for test in test_list_runtime: - if not test in cached_test_list_names and not test in self._excluded_tests_re: - runtime_test_test.append(test) - - if len(runtime_test_test) > 0: + time = int(line[:pos]) + test_name = line[pos+1:].replace("\n", "") + test_suite = test_name[:test_name.find(".")] + + if self._split_unit == constants.TEST_UNIT_NAME: + if constants.DISABLED_PREFIX not in test_name: + if (time != -1): + tests_dict_cache[test_name] = tests_dict_cache.get(test_name, 0) + time + elif self._split_unit == constants.SUITE_UNIT_NAME: + if constants.DISABLED_PREFIX not in test_suite: + if (time == -1): + tests_dict_cache[test_suite] = tests_dict_cache.get(test_suite, -1) + else: + tests_dict_cache[test_suite] = tests_dict_cache.get(test_suite, 0) + time + + logger.info(f"Len tests_dict_cache: {len(tests_dict_cache)}") + return tests_dict_cache + + def __generate_test_lists(self, test_dict_cache: dict, test_dict_runtime: dict): + cached_test_dict = dict() + runtime_test_dict = dict() + + for test in test_dict_cache: + if test in test_dict_runtime and test not in self._excluded_tests: + cached_test_dict[test] = test_dict_cache[test] + + for test in test_dict_runtime: + if test not in cached_test_dict and test not in self._excluded_tests: + runtime_test_dict[test] = test_dict_runtime[test] + + if len(runtime_test_dict) > 0: logger.warning(f'Cache file is not relevant the run. The will works in hybrid mode.') - logger.info(f'Test count from cache: {len(cached_test_list)}') - logger.info(f'Test count from runtime: {len(runtime_test_test)}') - return cached_test_list, runtime_test_test + logger.info(f'{self._split_unit.title()} count from cache: {len(cached_test_dict)}') + logger.info(f'{self._split_unit.title()} count from runtime: {len(runtime_test_dict)}') + return cached_test_dict, runtime_test_dict - def __prepare_smart_filters(self, proved_test_list:list): - res_test_filters = list() + def __prepare_smart_filters(self, proved_test_dict: dict): def_length = len(self._command) + len(" --gtest_filter=") - idx = len(proved_test_list) - for i in range(len(proved_test_list)): - if proved_test_list[i]._time == -1: - idx = i - break - - # Run crashed tests in a separed thread - if idx < len(proved_test_list): - while proved_test_list[idx]._time == -1: - test = proved_test_list.pop(idx) - res_test_filters.append(test._name) - if idx >= len(proved_test_list): - break + if constants.IS_WIN: + # subprocess add cmd.exe to the command line on Windows if shell=True + def_length += len(f'{os.environ.get("COMSPEC", "cmd.exe")} /C ') longest_device = "" for device in self._available_devices: if len(device) > len(longest_device): longest_device = device - # prepare gtest filters per worker according command line length limitation - while len(proved_test_list) > 0: - test_times = [] - is_not_full = True - worker_test_filters = list() + real_worker_num = self._worker_num * len(self._available_devices) - real_worker_num = self._worker_num * len(self._available_devices) + tasks_crashed = [] + tasks_full = [] + tasks_not_full = [] + tests_sorted = sorted(proved_test_dict.items(), key=lambda i: i[1], reverse=True) + for test_pattern, test_time in tests_sorted: + test_pattern = f'{self.__replace_restricted_symbols(test_pattern)}' - for _ in range(real_worker_num): - if len(proved_test_list) == 0: - break - worker_test_filters.append(f'"{self.__replace_restricted_symbols(proved_test_list[0]._name)}":') - test = proved_test_list.pop(0) - test_times.append(test._time) - while is_not_full and len(proved_test_list) > 0: - for i in range(real_worker_num): - if i >= len(proved_test_list): + if self._split_unit == constants.SUITE_UNIT_NAME: + # fix the suite filters to execute the right amount of the tests + test_pattern = f'{self.__get_suite_filter(self._gtest_filter, test_pattern)}:' + else: + # add quotes and pattern splitter + test_pattern = f'"{test_pattern}":' + + if test_time == -1: + tasks_crashed.append((test_time, test_pattern)) + else: + while len(tasks_not_full) > 0: + t_time, t_pattern = tasks_not_full[0] + length = len(t_pattern) + def_length + len(test_pattern.replace(self._device, longest_device)) + if length < MAX_LENGHT: break - if i == 0: - continue - while test_times[0] > test_times[i] + proved_test_list[len(proved_test_list) - 1]._time: - final_pos = len(proved_test_list) - 1 - filter = proved_test_list[final_pos]._name - if len(worker_test_filters[i]) + def_length + len(filter.replace(self._device, longest_device)) < MAX_LENGHT: - worker_test_filters[i] += f'"{self.__replace_restricted_symbols(filter)}":' - test_times[i] += proved_test_list[final_pos]._time - proved_test_list.pop(final_pos) - else: - is_not_full = False - break - if len(proved_test_list) == 0: - break - if is_not_full and len(proved_test_list) > 0: - filter = proved_test_list[0]._name - if len(worker_test_filters[0]) + def_length + len(filter.replace(self._device, longest_device)) < MAX_LENGHT: - worker_test_filters[0] += f'"{self.__replace_restricted_symbols(filter)}":' - test_times[0] += proved_test_list[0]._time - proved_test_list.pop(0) else: - is_not_full = False - for filter in worker_test_filters: - res_test_filters.append(filter) - is_not_full = True - # logging for debug - for i in range(len(res_test_filters)): - filter = res_test_filters[i] - cnt = filter.count('\":') - self._total_test_cnt += cnt - # logger.info(f"Number of tests in job_{i}: {cnt}") - return res_test_filters - + tasks_full.append(tasks_not_full.pop()) + + if len(tasks_not_full) < real_worker_num: + heapq.heappush(tasks_not_full, (test_time, test_pattern)) + else: + heapq.heapreplace(tasks_not_full, (t_time + test_time, t_pattern + test_pattern)) + + test_filters = tasks_full + tasks_not_full + tasks_crashed + test_filters.sort(reverse=True) + # convert to list and exlude empty jobs + test_filters = [task[1] for task in test_filters if task[1]] + return test_filters + def __get_filters(self): if not os.path.isfile(self._exec_file_path): logger.error(f"Test executable file {self._exec_file_path} is not exist!") sys.exit(-1) - - test_list_runtime = self.__get_test_list_by_runtime() - test_list_cache = self.__get_test_list_by_cache() - - cached_test_list, runtime_test_list = self.__generate_test_lists(test_list_cache, test_list_runtime) - if len(cached_test_list) > 0: + test_dict_runtime = self.__get_test_list_by_runtime(self._split_unit) + test_dict_cache = self.__get_test_list_by_cache() + + cached_test_dict, runtime_test_dist = self.__generate_test_lists(test_dict_cache, test_dict_runtime) + + cached_test_list = list() + if len(cached_test_dict) > 0: self._is_save_cache = False - cached_test_list = self.__prepare_smart_filters(cached_test_list) - if len(runtime_test_list) > 0: + cached_test_list = self.__prepare_smart_filters(cached_test_dict) + runtime_test_list = list() + if len(runtime_test_dist) > 0: self._is_save_cache = True - self._total_test_cnt += len(runtime_test_list) - runtime_test_list.reverse() + runtime_test_list = self.__prepare_smart_filters(runtime_test_dist) logger.info(f"Total test counter is {self._total_test_cnt}") return cached_test_list, runtime_test_list - + def __execute_tests(self, filters: list(), prev_worker_cnt = 0): commands = [f'{self._command} --gtest_filter={filter}' for filter in filters] tmp_log_dir = os.path.join(self._working_dir, "temp") @@ -463,7 +487,7 @@ def __find_not_runned_tests(self): test_name = line[line.find(constants.RUN) + len(constants.RUN) + 1:-1:] has_status = False if test_name is not None: - test_names.add(f'"{self.__replace_restricted_symbols(test_name)}":') + test_names.add(test_name) for _, status_messages in constants.TEST_STATUS.items(): for status_msg in status_messages: if status_msg in line: @@ -471,12 +495,12 @@ def __find_not_runned_tests(self): break if has_status: break - if not has_status: - interapted_tests.append(f'"{test_name}":') + if not has_status and test_name: + interapted_tests.append(test_name) log_file.close() test_list_runtime = set(self.__get_test_list_by_runtime()) - not_runned_tests = test_list_runtime.difference(test_names).difference(self._excluded_tests_re) - interapted_tests = set(interapted_tests).difference(self._excluded_tests_re) + not_runned_tests = test_list_runtime.difference(test_names).difference(self._excluded_tests) + interapted_tests = set(interapted_tests).difference(self._excluded_tests) return list(not_runned_tests), list(interapted_tests) def run(self): @@ -486,26 +510,29 @@ def run(self): if len(self._available_devices) > 1: logger.info(f"Tests will be run over devices: {self._available_devices} instead of {self._device}") t_start = datetime.datetime.now() - + filters_cache, filters_runtime = self.__get_filters() + # it is better to reuse workes for both cached and runtime tasks + test_filters = filters_cache + filters_runtime worker_cnt = 0 - if len(filters_cache): - logger.info(f"Execute jobs taken from cache") - worker_cnt += self.__execute_tests(filters_cache, worker_cnt) + if len(test_filters): + logger.info(f"Execute jobs taken from cache and runtime") + worker_cnt += self.__execute_tests(test_filters, worker_cnt) # 15m for one test in one process if TaskManager.process_timeout == -1 or TaskManager.process_timeout == DEFAULT_PROCESS_TIMEOUT: - TaskManager.process_timeout = DEFAULT_TEST_TIMEOUT - if len(filters_runtime): - logger.info(f"Execute jobs taken from runtime") - worker_cnt += self.__execute_tests(filters_runtime, worker_cnt) - not_runned_test_filter, interapted_tests = self.__find_not_runned_tests() - if len(not_runned_test_filter) > 0: - logger.info(f"Execute not runned {len(not_runned_test_filter)} tests") - worker_cnt += self.__execute_tests(not_runned_test_filter, worker_cnt) - if len(interapted_tests) > 0: - logger.info(f"Execute interapted {len(interapted_tests)} tests") - worker_cnt += self.__execute_tests(interapted_tests, worker_cnt) + TaskManager.process_timeout = DEFAULT_SUITE_TIMEOUT if self._split_unit == constants.SUITE_UNIT_NAME else DEFAULT_TEST_TIMEOUT + + not_runned_tests, interapted_tests = self.__find_not_runned_tests() + if (self._repeat_failed > 0): + if len(not_runned_tests) > 0: + logger.info(f"Execute not runned {len(not_runned_tests)} tests") + not_runned_test_filters = [f'"{self.__replace_restricted_symbols(test)}"' for test in not_runned_tests] + worker_cnt += self.__execute_tests(not_runned_test_filters, worker_cnt) + if len(interapted_tests) > 0: + logger.info(f"Execute interapted {len(interapted_tests)} tests") + interapted_tests_filters = [f'"{self.__replace_restricted_symbols(test)}"' for test in interapted_tests] + worker_cnt += self.__execute_tests(interapted_tests_filters, worker_cnt) t_end = datetime.datetime.now() total_seconds = (t_end - t_start).total_seconds() @@ -547,7 +574,7 @@ def __save_log(logs_dir, dir, test_name): with open(test_log_filename, "w") as log: log.writelines(test_log) log.close() - saved_tests.append(f'\"{test_name}\":') + saved_tests.append(test_name) return True logs_dir = os.path.join(self._working_dir, "logs") @@ -566,6 +593,7 @@ def __save_log(logs_dir, dir, test_name): with open(log_filename, "r") as log_file: test_name = None test_log = list() + test_suites = set() dir = None test_cnt_expected = test_cnt_real_saved_now = 0 ref_k = None @@ -580,6 +608,7 @@ def __save_log(logs_dir, dir, test_name): test_cnt_expected = line.count(':') if constants.RUN in line: test_name = line[line.find(constants.RUN) + len(constants.RUN) + 1:-1:] + dir = None if self._device != None and self._available_devices != None: for device_name in self._available_devices: if device_name in test_name: @@ -599,6 +628,8 @@ def __save_log(logs_dir, dir, test_name): if (constants.PG_ERR in line) or (constants.PG_WARN in line): test_log.append(line) if test_name is not None: + test_suite = test_name[:test_name.find(".")] + test_suites.add(test_suite) test_log.append(line) if dir: if __save_log(logs_dir, dir, test_name): @@ -617,17 +648,22 @@ def __save_log(logs_dir, dir, test_name): test_cnt_real_saved_now += 1 test_name = None test_log = list() - dir = None log_file.close() if test_name != None: dir = INTERAPTED_DIR if __save_log(logs_dir, dir, test_name): interapted_tests.add(test_name) - test_cnt_real = test_cnt_real_saved_now + + if (self._split_unit == constants.SUITE_UNIT_NAME): + test_cnt_real = len(test_suites) + else: + test_cnt_real = test_cnt_real_saved_now + if test_cnt_real < test_cnt_expected: - logger.error(f"Number of tests in {log}: {test_cnt_real}. Expected is {test_cnt_expected} tests") + logger.error(f"Number of {self._split_unit}s in {log}: {test_cnt_real}. Expected is {test_cnt_expected} {self._split_unit}") else: os.remove(log_filename) + if len(list(Path(os.path.join(self._working_dir, "temp")).rglob("log_*.log"))) == 0: rmtree(os.path.join(self._working_dir, "temp")) for test_name in interapted_tests: @@ -645,7 +681,7 @@ def __save_log(logs_dir, dir, test_name): if self._is_save_cache: test_times.sort(reverse=True) with open(self._cache_path, "w") as cache_file: - cache_file.writelines([f"{time}:\"" + test_name + "\":\n" for time, test_name in test_times]) + cache_file.writelines([f"{time}:{test_name}\n" for time, test_name in test_times]) cache_file.close() logger.info(f"Test cache test is saved to: {self._cache_path}") hash_table_path = os.path.join(logs_dir, "hash_table.csv") @@ -671,7 +707,7 @@ def __save_log(logs_dir, dir, test_name): _, tail = os.path.split(ir_hash) ir_hash, _ = os.path.splitext(tail) ir_hashes.append(ir_hash) - + logger.info(f"Fix priorities list is saved to: {fix_priority_path}") # Find all irs for failed tests failed_ir_dir = os.path.join(self._working_dir, f'{self._device}_failed_ir') @@ -689,7 +725,7 @@ def __save_log(logs_dir, dir, test_name): xml_file = correct_ir bin_file = prefix + constants.BIN_EXTENSION meta_file = prefix + constants.META_EXTENSION - + failed_ir_xml = xml_file.replace(head, failed_ir_dir) failed_ir_bin = bin_file.replace(head, failed_ir_dir) failed_ir_meta = meta_file.replace(head, failed_ir_dir) @@ -731,16 +767,16 @@ def __save_log(logs_dir, dir, test_name): not_run_tests_path = os.path.join(logs_dir, "not_run_tests.log") with open(not_run_tests_path, "w") as not_run_tests_path_file: test_list_runtime = self.__get_test_list_by_runtime() - diff_set = set(test_list_runtime).difference(set(saved_tests)).difference(self._orig_excluded_tests) + diff_set = set(saved_tests).intersection(test_list_runtime).difference(set(saved_tests)).difference(self._excluded_tests) diff_list = list() for item in diff_set: diff_list.append(f"{item}\n") not_run_tests_path_file.writelines(diff_list) not_run_tests_path_file.close() - logger.info(f"Not run test list is saved to: {not_run_tests_path}") l = len(diff_list) if l > 0: logger.warning(f"Not run test test counter is: {len(diff_list)}") + logger.info(f"Not run test list is saved to: {not_run_tests_path}") is_successfull_run = True test_cnt = 0 @@ -751,8 +787,11 @@ def __save_log(logs_dir, dir, test_name): is_successfull_run = False if len(self._disabled_tests): logger.info(f"disabled test counter is: {len(self._disabled_tests)}") - if self._total_test_cnt != test_cnt: + + diff_set = set(saved_tests).difference(set(test_list_runtime)) + if diff_set: logger.error(f"Total test count is {test_cnt} is different with expected {self._total_test_cnt} tests") + [logger.error(f'Missed test: {test}') for test in diff_set] is_successfull_run = False logger.info(f"Total test count with disabled tests is {test_cnt + len(self._disabled_tests)}. All logs is saved to {logs_dir}") return is_successfull_run @@ -766,11 +805,20 @@ def __save_log(logs_dir, dir, test_name): logger.info(f"[ARGUMENTS] --cache_path={args.cache_path}") logger.info(f"[ARGUMENTS] --workers={args.workers}") logger.info(f"[ARGUMENTS] --parallel_devices={args.parallel_devices}") + logger.info(f"[ARGUMENTS] --split_unit={args.split_unit}") + logger.info(f"[ARGUMENTS] --repeat_failed={args.repeat_failed}") logger.info(f"[ARGUMENTS] Executable file arguments = {exec_file_args}") TaskManager.process_timeout = args.process_timeout - conformance = TestParallelRunner(args.exec_file, exec_file_args, args.workers, args.working_dir, args.cache_path, args.parallel_devices) - conformance.run() - if not conformance.postprocess_logs(): + test_runner = TestParallelRunner(exec_file_path = args.exec_file, + test_command_line = exec_file_args, + worker_num = args.workers, + working_dir = args.working_dir, + cache_path = args.cache_path, + split_unit = args.split_unit, + repeat_failed = args.repeat_failed, + is_parallel_devices = args.parallel_devices) + test_runner.run() + if not test_runner.postprocess_logs(): logger.error("Run is not successful") sys.exit(-1) else: diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 825e599d52ea07..906229228ccc80 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -16,6 +16,9 @@ PG_ERR = "PG ERROR" PG_WARN = "PG WARN" REF_COEF = "[ CONFORMANCE ] Influence coefficient: " +TEST_UNIT_NAME = "test" +SUITE_UNIT_NAME = "suite" +UNIT_NAMES = [TEST_UNIT_NAME, SUITE_UNIT_NAME] IS_WIN = "windows" in platform or "win32" in platform IS_MACOS = "darwin" in platform From 8f6b30a8f9c492ee70041426f0452ac68380dce2 Mon Sep 17 00:00:00 2001 From: Maciej Smyk Date: Tue, 5 Sep 2023 16:59:06 +0200 Subject: [PATCH 06/31] link fix (#19624) --- .../120-tensorflow-object-detection-to-openvino-with-output.rst | 2 +- docs/notebooks/230-yolov8-optimization-with-output.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/notebooks/120-tensorflow-object-detection-to-openvino-with-output.rst b/docs/notebooks/120-tensorflow-object-detection-to-openvino-with-output.rst index a66dcefb6a4884..c1478cc5294bf3 100644 --- a/docs/notebooks/120-tensorflow-object-detection-to-openvino-with-output.rst +++ b/docs/notebooks/120-tensorflow-object-detection-to-openvino-with-output.rst @@ -694,4 +694,4 @@ utilization. For more information, refer to the `Optimize Preprocessing tutorial <118-optimize-preprocessing-with-output.html>`__ -and to the overview of :doc:`Preprocessing API ` . +and to the overview of `Preprocessing API `__ . diff --git a/docs/notebooks/230-yolov8-optimization-with-output.rst b/docs/notebooks/230-yolov8-optimization-with-output.rst index e8a9f31bcd6d0b..54ba88729f8191 100644 --- a/docs/notebooks/230-yolov8-optimization-with-output.rst +++ b/docs/notebooks/230-yolov8-optimization-with-output.rst @@ -1680,7 +1680,7 @@ on a selected device (CPU/GPU etc.) rather than always being executed on CPU as part of an application. This will improve selected device utilization. -For more information, refer to the overview of :doc:`Preprocessing API ` . +For more information, refer to the overview of `Preprocessing API `__ . For example, we can integrate converting input data layout and normalization defined in ``image_to_tensor`` function. From 1d62f0141dcfff64ba67678a110b666abaee7f74 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 5 Sep 2023 21:31:52 +0400 Subject: [PATCH 07/31] Rename cmake ie_ macros and ie_parallel script (#19606) * Rename cmake ie_ macros and ie_parallel script * Add warning messages --- cmake/developer_package/IEDevScriptsConfig.cmake | 7 ++++--- src/cmake/install_tbb.cmake | 2 +- src/cmake/openvino.cmake | 6 +++--- src/cmake/{ie_parallel.cmake => ov_parallel.cmake} | 9 +++++++-- src/common/low_precision_transformations/CMakeLists.txt | 2 +- src/common/preprocessing/src/CMakeLists.txt | 6 +++--- src/common/snippets/CMakeLists.txt | 2 +- src/common/transformations/CMakeLists.txt | 2 +- src/core/CMakeLists.txt | 2 +- src/core/reference/CMakeLists.txt | 2 +- src/inference/CMakeLists.txt | 8 ++++---- src/plugins/auto/CMakeLists.txt | 4 ++-- src/plugins/auto/tests/unit/CMakeLists.txt | 2 +- src/plugins/auto_batch/tests/functional/CMakeLists.txt | 2 +- src/plugins/auto_batch/tests/unit/CMakeLists.txt | 2 +- src/plugins/intel_cpu/CMakeLists.txt | 6 +++--- src/plugins/intel_cpu/tests/functional/CMakeLists.txt | 2 +- .../intel_cpu/tests/functional/specific_tests.cmake | 2 +- .../intel_cpu/tests/functional/target_per_test.cmake | 4 ++-- src/plugins/intel_gna/CMakeLists.txt | 2 +- src/plugins/intel_gpu/src/graph/CMakeLists.txt | 2 +- src/plugins/intel_gpu/src/runtime/CMakeLists.txt | 2 +- src/plugins/intel_gpu/tests/unit/CMakeLists.txt | 2 +- 23 files changed, 43 insertions(+), 37 deletions(-) rename src/cmake/{ie_parallel.cmake => ov_parallel.cmake} (98%) diff --git a/cmake/developer_package/IEDevScriptsConfig.cmake b/cmake/developer_package/IEDevScriptsConfig.cmake index 66d784b2d334e3..4f6a195b293bc9 100644 --- a/cmake/developer_package/IEDevScriptsConfig.cmake +++ b/cmake/developer_package/IEDevScriptsConfig.cmake @@ -255,7 +255,7 @@ get_linux_name(LINUX_OS_NAME) # macro to mark target as conditionally compiled -function(ie_mark_target_as_cc TARGET_NAME) +function(ov_mark_target_as_cc TARGET_NAME) set(cc_library openvino::conditional_compilation) if(TARGET IE::conditional_compilation) set(cc_library IE::conditional_compilation) @@ -275,8 +275,9 @@ function(ie_mark_target_as_cc TARGET_NAME) add_dependencies(${TARGET_NAME} conditional_compilation_gen) endfunction() -function(ov_mark_target_as_cc) - ie_mark_target_as_cc(${ARGN}) +function(ie_mark_target_as_cc TARGET_NAME) + message(WARNING "This function is deprecated. Please use ov_mark_target_as_cc(TARGET_NAME) instead.") + ov_mark_target_as_cc(${TARGET_NAME}) endfunction() include(python_requirements) diff --git a/src/cmake/install_tbb.cmake b/src/cmake/install_tbb.cmake index bd4acb1a4b4540..d5e3e7037ed3f9 100644 --- a/src/cmake/install_tbb.cmake +++ b/src/cmake/install_tbb.cmake @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # -include(cmake/ie_parallel.cmake) +include(cmake/ov_parallel.cmake) # pre-find TBB: need to provide TBB_IMPORTED_TARGETS used for installation ov_find_package_tbb() diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index 872358e3a683ad..685a5e50051b3c 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -64,8 +64,8 @@ if(WIN32) set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}) endif() -set_ie_threading_interface_for(${TARGET_NAME}) -ie_mark_target_as_cc(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) +ov_mark_target_as_cc(${TARGET_NAME}) # must be called after all target_link_libraries ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME} EXTRA ${TBB_IMPORTED_TARGETS}) @@ -107,7 +107,7 @@ target_compile_definitions(${TARGET_NAME}_dev INTERFACE target_link_libraries(${TARGET_NAME}_dev INTERFACE ${TARGET_NAME} openvino::core::dev) -set_ie_threading_interface_for(${TARGET_NAME}_dev) +ov_set_threading_interface_for(${TARGET_NAME}_dev) set_target_properties(${TARGET_NAME}_dev PROPERTIES EXPORT_NAME runtime::dev) openvino_developer_export_targets(COMPONENT core TARGETS openvino::runtime::dev) diff --git a/src/cmake/ie_parallel.cmake b/src/cmake/ov_parallel.cmake similarity index 98% rename from src/cmake/ie_parallel.cmake rename to src/cmake/ov_parallel.cmake index 62e5d2d06f4fa1..2d66146c6994a8 100644 --- a/src/cmake/ie_parallel.cmake +++ b/src/cmake/ov_parallel.cmake @@ -242,7 +242,7 @@ macro(ov_find_package_tbb) endif() endmacro() -function(set_ie_threading_interface_for TARGET_NAME) +function(ov_set_threading_interface_for TARGET_NAME) if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND) # find TBB ov_find_package_tbb() @@ -331,7 +331,7 @@ function(set_ie_threading_interface_for TARGET_NAME) endif () if (NOT OpenVINO_SOURCE_DIR) - # TODO: dead code since ie_parallel.cmake is not used outside of OpenVINO build + # TODO: dead code since ov_parallel.cmake is not used outside of OpenVINO build if (WIN32) set(lib_rel_path ${IE_LIB_REL_DIR}) set(lib_dbg_path ${IE_LIB_DBG_DIR}) @@ -398,4 +398,9 @@ function(set_ie_threading_interface_for TARGET_NAME) find_package(Threads REQUIRED) ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} Threads::Threads) endif() +endfunction(ov_set_threading_interface_for) + +function(set_ie_threading_interface_for TARGET_NAME) + message(WARNING "This function is deprecated. Please use ov_set_threading_interface_for(TARGET_NAME) instead.") + ov_set_threading_interface_for(${TARGET_NAME}) endfunction(set_ie_threading_interface_for) diff --git a/src/common/low_precision_transformations/CMakeLists.txt b/src/common/low_precision_transformations/CMakeLists.txt index fea803cc7fdc70..bacf03ce3b8440 100644 --- a/src/common/low_precision_transformations/CMakeLists.txt +++ b/src/common/low_precision_transformations/CMakeLists.txt @@ -33,7 +33,7 @@ target_include_directories(${TARGET_NAME}_obj PRIVATE $ $) - set_ie_threading_interface_for(${TARGET_NAME}_obj) + ov_set_threading_interface_for(${TARGET_NAME}_obj) add_cpplint_target(${TARGET_NAME}_obj_cpplint FOR_TARGETS ${TARGET_NAME}_obj) @@ -135,7 +135,7 @@ endif() add_library(${TARGET_NAME} ${library_type} ${library_sources}) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) if(ENABLE_GAPI_PREPROCESSING) target_compile_definitions(${TARGET_NAME} PUBLIC ENABLE_GAPI_PREPROCESSING) @@ -182,7 +182,7 @@ if(ENABLE_GAPI_PREPROCESSING) add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL $) - set_ie_threading_interface_for(${TARGET_NAME}_s) + ov_set_threading_interface_for(${TARGET_NAME}_s) target_include_directories(${TARGET_NAME}_s INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/src/common/snippets/CMakeLists.txt b/src/common/snippets/CMakeLists.txt index 31726fcd9efc43..ceb0374e0853ce 100644 --- a/src/common/snippets/CMakeLists.txt +++ b/src/common/snippets/CMakeLists.txt @@ -36,7 +36,7 @@ target_include_directories(${TARGET_NAME} PUBLIC $ need to mark this library as important for ABI free ov_abi_free_target(ngraph_obj) diff --git a/src/core/reference/CMakeLists.txt b/src/core/reference/CMakeLists.txt index c9039f1b4d5f85..3e42d75747cc13 100644 --- a/src/core/reference/CMakeLists.txt +++ b/src/core/reference/CMakeLists.txt @@ -25,7 +25,7 @@ ie_faster_build(${TARGET_NAME} UNITY PCH PRIVATE "src/precomp.hpp") -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) target_compile_definitions(${TARGET_NAME} PRIVATE XBYAK_NO_OP_NAMES XBYAK64) diff --git a/src/inference/CMakeLists.txt b/src/inference/CMakeLists.txt index d50bc84013ac39..0234bbb51c3fcf 100644 --- a/src/inference/CMakeLists.txt +++ b/src/inference/CMakeLists.txt @@ -101,7 +101,7 @@ target_compile_definitions(${TARGET_NAME}_plugin_api INTERFACE target_link_libraries(${TARGET_NAME}_plugin_api INTERFACE openvino::pugixml openvino::itt openvino::util) -set_ie_threading_interface_for(${TARGET_NAME}_plugin_api) +ov_set_threading_interface_for(${TARGET_NAME}_plugin_api) file(GLOB_RECURSE plugin_api_src "${CMAKE_CURRENT_SOURCE_DIR}/dev_api/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/dev_api/*.h") @@ -155,12 +155,12 @@ target_include_directories(${TARGET_NAME}_obj PRIVATE $) target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt openvino::util openvino::core::dev) -ie_mark_target_as_cc(${TARGET_NAME}_obj) +ov_mark_target_as_cc(${TARGET_NAME}_obj) # IE is public API => need to mark this library as important for ABI free ov_abi_free_target(${TARGET_NAME}_obj) -set_ie_threading_interface_for(${TARGET_NAME}_obj) +ov_set_threading_interface_for(${TARGET_NAME}_obj) if (TBBBIND_2_5_FOUND) target_link_libraries(${TARGET_NAME}_obj PRIVATE ${TBBBIND_2_5_IMPORTED_TARGETS}) endif() @@ -184,7 +184,7 @@ add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL $<$:$> $) -set_ie_threading_interface_for(${TARGET_NAME}_s) +ov_set_threading_interface_for(${TARGET_NAME}_s) if (TBBBIND_2_5_FOUND) target_link_libraries(${TARGET_NAME}_s PRIVATE ${TBBBIND_2_5_IMPORTED_TARGETS}) endif() diff --git a/src/plugins/auto/CMakeLists.txt b/src/plugins/auto/CMakeLists.txt index 312ac4a7966d3a..6eeb4ea4ef2379 100644 --- a/src/plugins/auto/CMakeLists.txt +++ b/src/plugins/auto/CMakeLists.txt @@ -39,9 +39,9 @@ if(ENABLE_TESTS) add_subdirectory(tests) endif() -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) # must be called after all target_link_libraries ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME}) -set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) \ No newline at end of file +set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) diff --git a/src/plugins/auto/tests/unit/CMakeLists.txt b/src/plugins/auto/tests/unit/CMakeLists.txt index b967ef3fb700ed..e4b392c8146a76 100644 --- a/src/plugins/auto/tests/unit/CMakeLists.txt +++ b/src/plugins/auto/tests/unit/CMakeLists.txt @@ -27,4 +27,4 @@ ov_add_test_target( ) ov_add_version_defines(${OpenVINO_SOURCE_DIR}/src/plugins/auto/src/plugin.cpp ${TARGET_NAME}) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) diff --git a/src/plugins/auto_batch/tests/functional/CMakeLists.txt b/src/plugins/auto_batch/tests/functional/CMakeLists.txt index 41ed2140234993..7c5137f9b565f8 100644 --- a/src/plugins/auto_batch/tests/functional/CMakeLists.txt +++ b/src/plugins/auto_batch/tests/functional/CMakeLists.txt @@ -22,4 +22,4 @@ addIeTargetTest( Auto_Batch ) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) diff --git a/src/plugins/auto_batch/tests/unit/CMakeLists.txt b/src/plugins/auto_batch/tests/unit/CMakeLists.txt index e1b217342841df..4b44fc47fa9055 100644 --- a/src/plugins/auto_batch/tests/unit/CMakeLists.txt +++ b/src/plugins/auto_batch/tests/unit/CMakeLists.txt @@ -31,4 +31,4 @@ addIeTargetTest( ) ov_add_version_defines(${OpenVINO_SOURCE_DIR}/src/plugins/auto_batch/src/plugin.cpp ${TARGET_NAME}) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) diff --git a/src/plugins/intel_cpu/CMakeLists.txt b/src/plugins/intel_cpu/CMakeLists.txt index 3212bdefc7d05a..1279bfd12696dc 100644 --- a/src/plugins/intel_cpu/CMakeLists.txt +++ b/src/plugins/intel_cpu/CMakeLists.txt @@ -113,7 +113,7 @@ elseif(RISCV64) set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "openvino_riscv_cpu_plugin") endif() -ie_mark_target_as_cc(${TARGET_NAME}) +ov_mark_target_as_cc(${TARGET_NAME}) target_link_libraries(${TARGET_NAME} PRIVATE dnnl openvino::shape_inference @@ -139,7 +139,7 @@ cross_compiled_file(${TARGET_NAME} # system dependencies must go last target_link_libraries(${TARGET_NAME} PRIVATE openvino::pugixml) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) # must be called after all target_link_libraries ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME}) @@ -173,7 +173,7 @@ if(BUILD_SHARED_LIBS) target_include_directories(${TARGET_NAME}_obj SYSTEM PUBLIC $) endif() - set_ie_threading_interface_for(${TARGET_NAME}_obj) + ov_set_threading_interface_for(${TARGET_NAME}_obj) target_compile_definitions(${TARGET_NAME}_obj PRIVATE USE_STATIC_IE IMPLEMENT_INFERENCE_ENGINE_PLUGIN IMPLEMENT_INFERENCE_EXTENSION_API diff --git a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt index 281c6eb8b19933..f79ca57304524c 100644 --- a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt @@ -54,7 +54,7 @@ addIeTargetTest( LABELS CPU ) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) include(specific_tests.cmake) include(target_per_test.cmake) diff --git a/src/plugins/intel_cpu/tests/functional/specific_tests.cmake b/src/plugins/intel_cpu/tests/functional/specific_tests.cmake index 25dfe9291d718b..1a3025966a4437 100644 --- a/src/plugins/intel_cpu/tests/functional/specific_tests.cmake +++ b/src/plugins/intel_cpu/tests/functional/specific_tests.cmake @@ -53,5 +53,5 @@ if(DEFINED ENABLE_CPU_SUBSET_TESTS_PATH) CPU ) - set_ie_threading_interface_for(${SUBSET_TARGET_NAME}) + ov_set_threading_interface_for(${SUBSET_TARGET_NAME}) endif() diff --git a/src/plugins/intel_cpu/tests/functional/target_per_test.cmake b/src/plugins/intel_cpu/tests/functional/target_per_test.cmake index f5ebcfc40f5d86..4d783a270f8943 100644 --- a/src/plugins/intel_cpu/tests/functional/target_per_test.cmake +++ b/src/plugins/intel_cpu/tests/functional/target_per_test.cmake @@ -39,7 +39,7 @@ function(create_target_per_test_for_directory TEST_DIR TARGET_PREFIX) CPU ) - set_ie_threading_interface_for(${TEST_TARGET_NAME}) + ov_set_threading_interface_for(${TEST_TARGET_NAME}) # avoid building binaries for every test in case target 'all' is used set_target_properties(${TEST_TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL ON) @@ -78,7 +78,7 @@ function(create_target_per_test_for_directory TEST_DIR TARGET_PREFIX) CPU ) - set_ie_threading_interface_for(${TEST_TARGET_NAME}) + ov_set_threading_interface_for(${TEST_TARGET_NAME}) # avoid building binaries for every test in case target 'all' is used set_target_properties(${TEST_TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL ON) diff --git a/src/plugins/intel_gna/CMakeLists.txt b/src/plugins/intel_gna/CMakeLists.txt index 0c20423448fb41..f2befa4d32361d 100644 --- a/src/plugins/intel_gna/CMakeLists.txt +++ b/src/plugins/intel_gna/CMakeLists.txt @@ -46,7 +46,7 @@ ov_add_plugin(NAME ${TARGET_NAME} ADD_CLANG_FORMAT) # Enable support of CC for the plugin -ie_mark_target_as_cc(${TARGET_NAME}) +ov_mark_target_as_cc(${TARGET_NAME}) target_link_libraries(${TARGET_NAME} PRIVATE inference_engine_legacy Threads::Threads libGNA) diff --git a/src/plugins/intel_gpu/src/graph/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/CMakeLists.txt index 0b2093d2a04ac3..3831742ace55f6 100644 --- a/src/plugins/intel_gpu/src/graph/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/graph/CMakeLists.txt @@ -48,7 +48,7 @@ if(COMMAND add_cpplint_target) add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}) endif() -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) diff --git a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt index c442f65575d739..47c9139a4f9f8b 100644 --- a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt @@ -44,7 +44,7 @@ target_compile_options(${TARGET_NAME} PRIVATE add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) target_link_libraries(${TARGET_NAME} PRIVATE OpenCL::OpenCL diff --git a/src/plugins/intel_gpu/tests/unit/CMakeLists.txt b/src/plugins/intel_gpu/tests/unit/CMakeLists.txt index fd5d039fe877ab..1cdcbd91c0f4fd 100644 --- a/src/plugins/intel_gpu/tests/unit/CMakeLists.txt +++ b/src/plugins/intel_gpu/tests/unit/CMakeLists.txt @@ -48,7 +48,7 @@ set(SOURCES_ALL add_executable(${TARGET_NAME} ${SOURCES_ALL}) -set_ie_threading_interface_for(${TARGET_NAME}) +ov_set_threading_interface_for(${TARGET_NAME}) # Workaround to avoid warnings during LTO build if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") From dc1339d8e3614f7c8ea54927428e8fd8ccdc9581 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 5 Sep 2023 22:16:18 +0400 Subject: [PATCH 08/31] Remove legacy API from samples (#19608) --- samples/cpp/benchmark_app/utils.hpp | 2 +- samples/cpp/common/utils/include/samples/common.hpp | 2 -- samples/cpp/model_creation_sample/main.cpp | 5 ++--- samples/cpp/speech_sample/main.cpp | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/samples/cpp/benchmark_app/utils.hpp b/samples/cpp/benchmark_app/utils.hpp index 2fa20f040cb1f9..e3277eaea60f67 100644 --- a/samples/cpp/benchmark_app/utils.hpp +++ b/samples/cpp/benchmark_app/utils.hpp @@ -55,7 +55,7 @@ struct InputInfo { std::vector fileNames; }; using InputsInfo = std::map; -using PartialShapes = std::map; +using PartialShapes = std::map; } // namespace benchmark_app bool can_measure_as_static(const std::vector& app_input_info); diff --git a/samples/cpp/common/utils/include/samples/common.hpp b/samples/cpp/common/utils/include/samples/common.hpp index f637d952118418..6b3f7270c546c5 100644 --- a/samples/cpp/common/utils/include/samples/common.hpp +++ b/samples/cpp/common/utils/include/samples/common.hpp @@ -23,8 +23,6 @@ #include #include -using std::setprecision; - // clang-format off #include "openvino/openvino.hpp" #include "slog.hpp" diff --git a/samples/cpp/model_creation_sample/main.cpp b/samples/cpp/model_creation_sample/main.cpp index 2c793dc76c21f1..078bf6b7d0eb1a 100644 --- a/samples/cpp/model_creation_sample/main.cpp +++ b/samples/cpp/model_creation_sample/main.cpp @@ -14,7 +14,6 @@ #include "openvino/openvino.hpp" #include "openvino/opsets/opset1.hpp" #include "openvino/opsets/opset8.hpp" -#include "ngraph/util.hpp" #include "samples/args_helper.hpp" #include "samples/common.hpp" @@ -74,8 +73,8 @@ ov::Tensor read_weights(const std::string& filepath) { } /** - * @brief Create ngraph function - * @return Ptr to ngraph function + * @brief Create ov::Model + * @return Ptr to ov::Model */ std::shared_ptr create_model(const std::string& path_to_weights) { const ov::Tensor weights = read_weights(path_to_weights); diff --git a/samples/cpp/speech_sample/main.cpp b/samples/cpp/speech_sample/main.cpp index 3f7856aebd9f82..d92c365d8f5756 100644 --- a/samples/cpp/speech_sample/main.cpp +++ b/samples/cpp/speech_sample/main.cpp @@ -293,7 +293,7 @@ int main(int argc, char* argv[]) { } } } - // --------------------------- Exporting gna model using InferenceEngine AOT API--------------------- + // --------------------------- Exporting gna model using OpenVINO API--------------------- if (!FLAGS_wg.empty()) { slog::info << "Writing GNA Model to file " << FLAGS_wg << slog::endl; t0 = Time::now(); From 954536d2d6eeb76ff38b7b93954537c10a446d56 Mon Sep 17 00:00:00 2001 From: HARI CHAND BALASUBRAMANIAM Date: Wed, 6 Sep 2023 11:27:12 +0800 Subject: [PATCH 09/31] Create documentation.yml (#18926) This is for customer to report any issue regarding documentation. Co-authored-by: Ilya Churaev --- .github/ISSUE_TEMPLATE/documentation.yml | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/documentation.yml diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 00000000000000..6dba3cd05f03ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,30 @@ +name: Documentation issue Report +description: This report is related to the documentation +title: "[Docs]: " +labels: ["docs", "support_request"] +body: + - type: markdown + attributes: + value: | + Please provide all the necessary information to expedite the response. + - type: input + id: doc_link + attributes: + label: Documentation link + description: Please provide the link for the documentation issue + placeholder: e.g. intel.com/content/www/us/en/developer/tools/openvino-toolkit/system-requirements.html + validations: + required: true + - type: textarea + id: build_description + attributes: + label: Build issue description + description: What issue are you facing during the build/installation? + placeholder: Please provide a detailed description of what happened + validations: + required: true + label: Issue submission checklist + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/intel/intel-one-mono/blob/main/CODE_OF_CONDUCT.md) + options: + - label: I report the documentation issue. It's not a question + required: true From be23ac7c260df0ae1e36a25ff7fddc69ef654bc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Sep 2023 07:29:13 +0400 Subject: [PATCH 10/31] Bump actions/checkout from 3 to 4 (#19602) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build_doc.yml | 2 +- .github/workflows/check_pr_commits.yml | 2 +- .github/workflows/code_snippets.yml | 2 +- .github/workflows/code_style.yml | 6 +++--- .github/workflows/coverage.yml | 2 +- .github/workflows/dependency_review.yml | 2 +- .github/workflows/files_size.yml | 2 +- .github/workflows/linux.yml | 8 ++++---- .github/workflows/linux_debian.yml | 4 ++-- .github/workflows/mo.yml | 2 +- .github/workflows/py_checks.yml | 2 +- .github/workflows/windows.yml | 10 +++++----- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index f0a34186ce4537..1f65c76afd6259 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true lfs: true diff --git a/.github/workflows/check_pr_commits.yml b/.github/workflows/check_pr_commits.yml index 41d1564a0cad1d..27af2c56013a36 100644 --- a/.github/workflows/check_pr_commits.yml +++ b/.github/workflows/check_pr_commits.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: python3 -m pip install -r ./.github/github_org_control/requirements.txt diff --git a/.github/workflows/code_snippets.yml b/.github/workflows/code_snippets.yml index 559d3c064a7942..a65ab62b2f155d 100644 --- a/.github/workflows/code_snippets.yml +++ b/.github/workflows/code_snippets.yml @@ -25,7 +25,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive lfs: true diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index 905f462c8e583b..dbc3245055af47 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -11,7 +11,7 @@ jobs: permissions: pull-requests: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -47,7 +47,7 @@ jobs: permissions: pull-requests: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -78,7 +78,7 @@ jobs: NamingConventionCheck: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index e71cd5f4546976..4a68a7a7f93b74 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -28,7 +28,7 @@ jobs: max-size: 50G - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/dependency_review.yml b/.github/workflows/dependency_review.yml index 8e93de51b5c767..cadf46ab3b9d1c 100644 --- a/.github/workflows/dependency_review.yml +++ b/.github/workflows/dependency_review.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Dependency Review uses: actions/dependency-review-action@v3 diff --git a/.github/workflows/files_size.yml b/.github/workflows/files_size.yml index ce9757af172ba8..56485765b057b2 100644 --- a/.github/workflows/files_size.yml +++ b/.github/workflows/files_size.yml @@ -9,7 +9,7 @@ jobs: Check_Files_Size: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: git ls-tree run: git ls-tree -r -t -l --full-name HEAD | sort -n -r -k 4 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 3dc75adf3c9384..5e0fb067078993 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -49,20 +49,20 @@ jobs: PYTHON_STATIC_ARGS: -m "not dynamic_library" steps: - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: 'openvino' submodules: 'recursive' - name: Clone OpenVINO Contrib - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'openvinotoolkit/openvino_contrib' path: 'openvino_contrib' submodules: 'recursive' - name: Clone testdata for C API tests - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'openvinotoolkit/testdata' path: 'testdata' @@ -505,7 +505,7 @@ jobs: mkdir -p ${{ env.INSTALL_DIR }} ${{ env.INSTALL_TEST_DIR }} - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: 'openvino' submodules: 'recursive' diff --git a/.github/workflows/linux_debian.yml b/.github/workflows/linux_debian.yml index 3150b5fbaa36bc..04283c15455224 100644 --- a/.github/workflows/linux_debian.yml +++ b/.github/workflows/linux_debian.yml @@ -55,13 +55,13 @@ jobs: PYTHON_STATIC_ARGS: -m "not dynamic_library and not template_plugin" steps: - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: 'openvino' submodules: 'recursive' - name: Clone testdata for C API tests - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'openvinotoolkit/testdata' path: 'testdata' diff --git a/.github/workflows/mo.yml b/.github/workflows/mo.yml index 125db3b85075f5..eab7664a776333 100644 --- a/.github/workflows/mo.yml +++ b/.github/workflows/mo.yml @@ -20,7 +20,7 @@ jobs: Pylint-UT: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/py_checks.yml b/.github/workflows/py_checks.yml index c068fe31ee74ac..399c118b40a40c 100644 --- a/.github/workflows/py_checks.yml +++ b/.github/workflows/py_checks.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Code checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8d29de04ba07d3..b47502a290eae9 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -50,20 +50,20 @@ jobs: runs-on: windows-latest-8-cores steps: - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: 'openvino' submodules: 'recursive' - name: Clone OpenVINO Contrib - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'openvinotoolkit/openvino_contrib' path: 'openvino_contrib' submodules: 'recursive' - name: Clone testdata for C API tests - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'openvinotoolkit/testdata' path: 'testdata' @@ -303,13 +303,13 @@ jobs: ls "${{ env.INSTALL_TEST_DIR }}" - name: Clone OpenVINO - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: 'openvino' submodules: 'recursive' - name: Clone OpenVINO Contrib - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'openvinotoolkit/openvino_contrib' path: 'openvino_contrib' From b7758b05048dbdab6e1dac47da8e9f5152d36f79 Mon Sep 17 00:00:00 2001 From: Sungeun Kim Date: Wed, 6 Sep 2023 13:30:53 +0900 Subject: [PATCH 11/31] [GPU] update the data-type of primitive from ops (#19302) * set the data-type of transpose by dt of ops. * set output_data in calc_output_layouts --- src/plugins/intel_gpu/src/graph/permute.cpp | 9 ++++----- src/plugins/intel_gpu/src/plugin/ops/transpose.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/permute.cpp b/src/plugins/intel_gpu/src/graph/permute.cpp index 924891fbf703de..ea4f6e507f1b89 100644 --- a/src/plugins/intel_gpu/src/graph/permute.cpp +++ b/src/plugins/intel_gpu/src/graph/permute.cpp @@ -14,8 +14,6 @@ namespace cldnn { GPU_DEFINE_PRIMITIVE_TYPE_ID(permute) layout permute_inst::calc_output_layout(permute_node const& node, kernel_impl_params const& impl_param) { - assert(static_cast(impl_param.desc->output_data_types[0]) == false && - "Output data type forcing is not supported for permute_node!"); auto desc = impl_param.typed_desc(); auto input_layout = impl_param.get_input_layout(); auto permute_order = desc->permute_order; @@ -34,8 +32,9 @@ layout permute_inst::calc_output_layout(permute_node const& node, kernel_impl_pa auto output_size = tensor(format::get_default_format(input_layout.get_rank()), output_shape); auto op = desc->output_paddings[0]; + auto output_type = desc->output_data_types[0].value_or(input_layout.data_type); if (impl_param.has_fused_primitives()) { - input_layout.data_type = impl_param.get_fused_output_layout().data_type; + output_type = impl_param.get_fused_output_layout().data_type; } // Adjust output format for optimizing out of transpose related to acdb format. @@ -44,7 +43,7 @@ layout permute_inst::calc_output_layout(permute_node const& node, kernel_impl_pa out_fmt = node.get_preferred_output_fmt(); } - return layout(input_layout.data_type, out_fmt, output_size, op); + return layout(output_type, out_fmt, output_size, op); } template @@ -52,7 +51,7 @@ std::vector permute_inst::calc_output_layouts(permute_node const& /*node auto desc = impl_param.typed_desc(); auto input_layout = impl_param.get_input_layout(); - auto output_type = input_layout.data_type; + auto output_type = desc->output_data_types[0].value_or(input_layout.data_type); if (impl_param.has_fused_primitives()) { output_type = impl_param.get_fused_output_layout().data_type; } diff --git a/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp b/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp index b84b45facb8d28..00837c3601d42e 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp @@ -73,7 +73,7 @@ static void CreateTransposeOp(ProgramBuilder& p, const std::shared_ptrget_output_element_type(0)); p.add_primitive(*op, permutePrim); } From 8d6083e08ef63e35f8ef1783f66125844cabe640 Mon Sep 17 00:00:00 2001 From: Yury Gaydaychuk Date: Wed, 6 Sep 2023 07:12:17 +0200 Subject: [PATCH 12/31] [Commit slider] Skipping for commits (#18966) --- .../tools/commit_slider/commit_slider.py | 4 +- .../tools/commit_slider/utils/cfg.json | 35 ++++ .../tools/commit_slider/utils/common_mode.py | 197 ++++++++++++------ .../tools/commit_slider/utils/helpers.py | 93 +++++++-- .../tools/commit_slider/utils/modes.py | 79 ++++--- 5 files changed, 272 insertions(+), 136 deletions(-) diff --git a/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py b/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py index 0c853ba0bec691..4c130518e675d3 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py +++ b/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py @@ -33,8 +33,8 @@ commitList.reverse() p = Mode.factory(cfgData) - p.run(0, len(commitList) - 1, commitList, cfgData) - p.getResult() + p.run(commitList, cfgData) + p.printResult() else: workPath = cfgData["workPath"] diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json index 9d258b5db68de4..ee821254dfded4 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json @@ -11,6 +11,7 @@ "checkCommitSet" : "IterateOverSuspiciousCommits", "bruteForce" : "BruteForce" }, + "extendBuildCommand" : false, "commandList" : [ {"cmd" : "git checkout -- .", "path" : "{gitPath}"}, {"cmd" : "git clean -fxd", "path" : "{gitPath}", "tag" : "clean"}, @@ -19,9 +20,43 @@ {"cmd" : "git submodule init", "path" : "{gitPath}"}, {"cmd" : "git submodule update --recursive", "path" : "{buildPath}"}, {"cmd" : "{makeCmd}", "catchMsg" : "CMake Error", "path" : "{buildPath}"}, + {"cmd" : "make --jobs=4", "catchMsg" : "Error", "path" : "{buildPath}"}, + {"cmd" : "git checkout -- .", "path" : "{gitPath}"} + ], + "extendedCommandList" : [ + {"cmd" : "git rm --cached -r .", "path" : "{gitPath}"}, + {"cmd" : "git reset --hard", "path" : "{gitPath}"}, + {"cmd" : "git rm .gitattributes", "path" : "{gitPath}"}, + {"cmd" : "git reset .", "path" : "{gitPath}"}, + {"cmd" : "git checkout -- .", "path" : "{gitPath}"}, + {"cmd" : "git rm --cached -r .", "path" : "{gitPath}"}, + {"cmd" : "git reset --hard", "path" : "{gitPath}"}, + {"cmd" : "git rm .gitattributes", "path" : "{gitPath}"}, + {"cmd" : "git reset .", "path" : "{gitPath}"}, + {"cmd" : "git checkout -- .", "path" : "{gitPath}"}, + {"cmd" : "git clean -fxd", "path" : "{gitPath}"}, + {"cmd" : "mkdir -p build", "path" : "{gitPath}"}, + {"cmd" : "git checkout {commit}", "catchMsg" : "error", "path" : "{gitPath}"}, + {"cmd" : "git submodule init", "path" : "{gitPath}"}, + {"cmd" : "git submodule update --recursive", "path" : "{buildPath}"}, + {"cmd" : "{makeCmd}", "catchMsg" : "CMake Error", "path" : "{buildPath}"}, {"cmd" : "make --jobs=4", "path" : "{buildPath}"}, {"cmd" : "git checkout -- .", "path" : "{gitPath}"} ], + "skipMode" : { + "modeName" : "rebuild", + "flagSet" : { + "comment_1" : "\"flagSet\" ignored if modeName is defined", + "enforceSkips" : "enabled automatically when double-build failed", + "enableRebuild" : false, + "switchOnExtendedBuild" : false, + "switchOnSimpleBuild" : false, + "comment_2" : "additional params, to-be considered in complex modes", + "buildTryCount" : 0, + "failedCommand" : "checkout | make" + }, + "comment" : "modes: {skip (for developer purpose) | rebuild (simple user mode)}" + }, "makeCmd" : "cmake ..", "returnCmd" : "git checkout master", "gitPath" : "../../../../../", diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py b/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py index 44e9817fea2279..a07761ffa0f239 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py @@ -75,18 +75,42 @@ def setCommitCash(self, commit, valueToCache): cacheDump.truncate() cacheDump.close() + def getPseudoMetric(self, commit, cfg): + raise NotImplementedError("getPseudoMetric() is not implemented") + + def compareCommits(self, c1, c2, list, cfg): + raise NotImplementedError("compareCommits() is not implemented") + def checkCfg(self, cfg): if not ("traversal" in cfg["runConfig"]): raise util.CfgError("traversal is not configured") - def prepareRun(self, i1, i2, list, cfg): + def prepareRun(self, list, cfg): + self.normalizeCfg(cfg) cfg["serviceConfig"] = {} if cfg["checkIfBordersDiffer"] and not self.checkIfListBordersDiffer( list, cfg): raise util.RepoError("Borders {i1} and {i2} doesn't differ".format( - i1=i1, i2=i2)) + i1=0, i2=len(list) - 1)) self.commitList = list + def normalizeCfg(self, cfg): + if "modeName" in cfg["skipMode"]: + errorHandlingMode = cfg["skipMode"]["modeName"] + if errorHandlingMode == "skip": + cfg["skipMode"]["flagSet"] = {} + cfg["skipMode"]["flagSet"]["enableSkips"] = True + elif (errorHandlingMode == "rebuild"): + cfg["skipMode"]["flagSet"] = {} + cfg["skipMode"]["flagSet"]["enableSkips"] = False + cfg["skipMode"]["flagSet"]["enableRebuild"] = True + cfg["skipMode"]["flagSet"]["switchOnSimpleBuild"] = True + cfg["skipMode"]["flagSet"]["switchOnExtendedBuild"] = False + else: + raise util.CfgError( + "Error handling mode {} is not supported".format(errorHandlingMode) + ) + def postRun(self, list): util.returnToActualVersion(self.cfg) if "printCSV" in self.cfg and self.cfg["printCSV"]: @@ -109,10 +133,12 @@ def postRun(self, list): csvwriter.writerow(fields) csvwriter.writerows(rows) - def run(self, i1, i2, list, cfg) -> int: - self.prepareRun(i1, i2, list, cfg) - self.traversal.bypass( - i1, i2, list, cfg, self.commitPath + def run(self, list, cfg) -> int: + self.prepareRun(list, cfg) + for i, item in enumerate(list): + list[i] = item.replace('"', "") + self.traversal.wrappedBypass( + list, list, cfg ) self.postRun(list) @@ -120,18 +146,17 @@ def setOutputInfo(self, pathCommit): # override if you need more details in output representation pass - def getResult(self): - # override if you need more details in output representation + def printResult(self): for pathcommit in self.commitPath.getList(): - print("Break commit: {c}".format( - c=self.commitList[pathcommit.id]) - ) + print(self.getCommitInfo(pathcommit)) - def checkIfBordersDiffer(self, i1, i2, list, cfg): - raise NotImplementedError("checkIfBordersDiffer() is not implemented") + def getCommitInfo(self, commit): + # override if you need more details in output representation + return "Break commit: {c}, state: {s}".format( + c=commit.cHash, s=commit.state) def checkIfListBordersDiffer(self, list, cfg): - return self.checkIfBordersDiffer(0, len(list) - 1, list, cfg) + return self.compareCommits(list[0], list[-1], list, cfg) class CommitPath: @@ -146,8 +171,8 @@ class CommitState(Enum): SKIPPED = 2 class PathCommit: - def __init__(self, id, state): - self.id = id + def __init__(self, cHash, state): + self.cHash = cHash self.state = state def append(self, commit): @@ -160,14 +185,45 @@ def getList(self): return self.commitList class Traversal(ABC): - def bypass(self, i1, i2, list, cfg, commitPath) -> int: + def bypass(self, curList, list, cfg) -> int: raise NotImplementedError() + def wrappedBypass(self, curList, list, cfg) -> int: + try: + self.bypass(curList, list, cfg) + except util.BuildError as be: + if be.errType == util.BuildError.BuildErrType.TO_SKIP: + self.skipCommit(be.commit, curList, cfg) + self.wrappedBypass(curList, list, cfg) + elif be.errType == util.BuildError.BuildErrType.TO_REBUILD: + cfg["extendBuildCommand"] = True + self.wrappedBypass(curList, list, cfg) + else: + # exception must be reported to user + pass + + + def skipCommit(self, commit, curList, cfg): + curList.remove(commit) + pc = Mode.CommitPath.PathCommit( + commit, + Mode.CommitPath.CommitState.SKIPPED + ) + self.mode.commonLogger.info( + "Skipped commit {}".format(commit) + ) + self.mode.setOutputInfo(pc) + self.mode.commitPath.accept(self, pc) + + def visit(self, cPath, commitToReport): cPath.append(commitToReport) - def prepBypass(self, i1, i2, list, cfg): + + def prepBypass(self, curList, list, cfg): skipInterval = cfg["noCleanInterval"] + i1 = list.index(curList[0]) + i2 = list.index(curList[-1]) cfg["serviceConfig"]["skipCleanInterval"] = i2 - i1 < skipInterval self.mode.commonLogger.info( "Check interval {i1}..{i2}".format(i1=i1, i2=i2) @@ -183,103 +239,108 @@ class FirstFailedVersion(Traversal): def __init__(self, mode) -> None: super().__init__(mode) - def bypass(self, i1, i2, list, cfg, commitPath) -> int: - self.prepBypass(i1, i2, list, cfg) - sampleCommit = 0 + def bypass(self, curList, list, cfg) -> int: + self.prepBypass(curList, list, cfg) + sampleCommit = curList[0] + curLen = len(curList) if "sampleCommit" in cfg["serviceConfig"]: sampleCommit = cfg["serviceConfig"]["sampleCommit"] - if i1 + 1 >= i2: - isBad = self.mode.checkIfBordersDiffer( - sampleCommit, i1, list, cfg) - breakCommit = i1 if isBad else i2 + if curLen <= 2: + isBad = self.mode.compareCommits( + sampleCommit, curList[0], list, cfg) + breakCommit = curList[0] if isBad else curList[-1] pc = Mode.CommitPath.PathCommit( breakCommit, Mode.CommitPath.CommitState.BREAK ) self.mode.setOutputInfo(pc) - commitPath.accept(self, pc) + self.mode.commitPath.accept(self, pc) return - mid = (int)((i1 + i2) / 2) - isBad = self.mode.checkIfBordersDiffer( - sampleCommit, mid, list, cfg) + mid = (int)((curLen - 1) / 2) + isBad = self.mode.compareCommits( + sampleCommit, curList[mid], list, cfg) if isBad: - self.bypass( - i1, mid, list, cfg, commitPath + self.wrappedBypass( + curList[0 : mid + 1], list, cfg ) else: - self.bypass( - mid, i2, list, cfg, commitPath + self.wrappedBypass( + curList[mid :], list, cfg ) class FirstFixedVersion(Traversal): def __init__(self, mode) -> None: super().__init__(mode) - def bypass(self, i1, i2, list, cfg, commitPath) -> int: - self.prepBypass(i1, i2, list, cfg) - sampleCommit = 0 + def bypass(self, curList, list, cfg) -> int: + self.prepBypass(curList, list, cfg) + sampleCommit = curList[0] + curLen = len(curList) if "sampleCommit" in cfg["serviceConfig"]: sampleCommit = cfg["serviceConfig"]["sampleCommit"] - if i1 + 1 >= i2: - isBad = self.mode.checkIfBordersDiffer( - sampleCommit, i1, list, cfg) - breakCommit = i2 if isBad else i1 + if curLen <= 2: + isBad = self.mode.compareCommits( + sampleCommit, curList[0], list, cfg) + breakCommit = curList[-1] if isBad else curList[0] pc = Mode.CommitPath.PathCommit( breakCommit, Mode.CommitPath.CommitState.BREAK ) self.mode.setOutputInfo(pc) - commitPath.accept(self, pc) + self.mode.commitPath.accept(self, pc) return - mid = (int)((i1 + i2) / 2) - isBad = self.mode.checkIfBordersDiffer( - sampleCommit, mid, list, cfg) + mid = (int)((curLen - 1) / 2) + isBad = self.mode.compareCommits( + sampleCommit, curList[mid], list, cfg) if isBad: - self.bypass( - mid, i2, list, cfg, commitPath + self.wrappedBypass( + curList[mid :], list, cfg ) else: - self.bypass( - i1, mid, list, cfg, commitPath + self.wrappedBypass( + curList[0 : mid + 1], list, cfg ) class AllBreakVersions(Traversal): def __init__(self, mode) -> None: super().__init__(mode) - def bypass(self, i1, i2, list, cfg, commitPath) -> int: - self.prepBypass(i1, i2, list, cfg) - sampleCommit = 0 + def bypass(self, curList, list, cfg) -> int: + self.prepBypass(curList, list, cfg) + sampleCommit = curList[0] + curLen = len(curList) if "sampleCommit" in cfg["serviceConfig"]: sampleCommit = cfg["serviceConfig"]["sampleCommit"] - if i1 + 1 >= i2: - isBad = self.mode.checkIfBordersDiffer( - sampleCommit, i1, list, cfg) - breakCommit = i1 if isBad else i2 + if curLen <= 2: + isBad = self.mode.compareCommits( + sampleCommit, curList[0], list, cfg) + breakCommit = curList[0] if isBad else curList[-1] pc = Mode.CommitPath.PathCommit( breakCommit, Mode.CommitPath.CommitState.BREAK ) self.mode.setOutputInfo(pc) - commitPath.accept(self, pc) - lastCommit = len(list) - 1 - isTailDiffer = self.mode.checkIfBordersDiffer( + self.mode.commitPath.accept(self, pc) + lastCommit = list[-1] + isTailDiffer = self.mode.compareCommits( breakCommit, lastCommit, list, cfg) if isTailDiffer: cfg["serviceConfig"]["sampleCommit"] = breakCommit - self.bypass( - breakCommit, lastCommit, - list, cfg, commitPath + # to-do make copy without skip-commits + brIndex = list.index(breakCommit) + self.wrappedBypass( + list[brIndex :], + list, cfg ) return - mid = (int)((i1 + i2) / 2) - isBad = self.mode.checkIfBordersDiffer( - sampleCommit, mid, list, cfg) + mid = (int)((curLen - 1) / 2) + isBad = self.mode.compareCommits( + sampleCommit, curList[mid], list, cfg) if isBad: - self.bypass( - i1, mid, list, cfg, commitPath + self.wrappedBypass( + curList[0 : mid + 1], list, cfg ) else: - self.bypass( - mid, i2, list, cfg, commitPath + self.wrappedBypass( + curList[mid :], list, cfg ) diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py b/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py index 97d8056c2040ce..c30c5773467b4f 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py @@ -3,6 +3,7 @@ import os import sys import subprocess +from enum import Enum import re import json import logging as log @@ -157,15 +158,16 @@ def runCommandList(commit, cfgData, enforceClean=False): else: skipCleanInterval = cfgData["trySkipClean"] and not enforceClean commitLogger = getCommitLogger(cfgData, commit) - commandList = cfgData["commandList"] + if not cfgData["extendBuildCommand"]: + commandList = cfgData["commandList"] + else: + commandList = cfgData["extendedCommandList"] gitPath = cfgData["gitPath"] buildPath = cfgData["buildPath"] defRepo = gitPath for cmd in commandList: if "tag" in cmd: - if cmd["tag"] == "clean" and skipCleanInterval: - continue - elif cmd["tag"] == "preprocess": + if cmd["tag"] == "preprocess": if not ( "preprocess" in cfgData["runConfig"] and "name" in cfgData["runConfig"]["preprocess"] @@ -199,20 +201,16 @@ def runCommandList(commit, cfgData, enforceClean=False): pass sys.stdout.write(line) commitLogger.info(line) + if "catchMsg" in cmd: + isErrFound = re.search(cmd["catchMsg"], line) + if isErrFound: + raise BuildError( + errType=BuildError.BuildErrType.UNDEFINED, + message="error while executing: {}". + format(cmd["cmd"]), commit=commit + ) proc.wait() checkOut, err = proc.communicate() - try: - checkOut = checkOut.decode("utf-8") - except (UnicodeDecodeError, AttributeError): - pass - if "catchMsg" in cmd: - isErrFound = re.search(cmd["catchMsg"], checkOut) - if isErrFound: - if skipCleanInterval: - commitLogger.info("Build error: clean is necessary") - raise NoCleanFailedError() - else: - raise CmdError(checkOut) def fetchAppOutput(cfg, commit): @@ -245,14 +243,52 @@ def fetchAppOutput(cfg, commit): def handleCommit(commit, cfgData): + commitLogger = getCommitLogger(cfgData, commit) if "skipCleanInterval" in cfgData["serviceConfig"]: skipCleanInterval = cfgData["serviceConfig"]["skipCleanInterval"] cfgData["trySkipClean"] = skipCleanInterval try: runCommandList(commit, cfgData) - except (NoCleanFailedError): - cfgData["trySkipClean"] = False - runCommandList(commit, cfgData) + if cfgData["skipMode"]["flagSet"]["enableRebuild"]: + cfgData["skipMode"]["flagSet"]["switchOnSimpleBuild"] = True + cfgData["skipMode"]["flagSet"]["switchOnExtendedBuild"] = False + cfgData["extendBuildCommand"] = False + except BuildError as be: + if cfgData["skipMode"]["flagSet"]["enableSkips"]: + commitLogger.info("Build error: commit {} skipped".format(commit)) + raise BuildError( + errType=BuildError.BuildErrType.TO_SKIP, + message="build error handled by skip", + commit=commit + ) from be + elif cfgData["skipMode"]["flagSet"]["enableRebuild"]: + if cfgData["skipMode"]["flagSet"]["switchOnSimpleBuild"]: + cfgData["skipMode"]["flagSet"]["switchOnSimpleBuild"] = False + cfgData["skipMode"]["flagSet"]["switchOnExtendedBuild"] = True + commitLogger.info("Build error: commit {} rebuilded".format(commit)) + raise BuildError( + errType=BuildError.BuildErrType.TO_REBUILD, + message="build error handled by rebuilding", + commit=commit + ) from be + elif cfgData["skipMode"]["flagSet"]["switchOnExtendedBuild"]: + raise BuildError( + errType=BuildError.BuildErrType.TO_STOP, + message="cannot rebuild commit", + commit=commit + ) from be + else: + raise BuildError( + errType=BuildError.BuildErrType.WRONG_STATE, + message="incorrect case with commit", + commit=commit + ) from be + else: + raise BuildError( + message = "error occured during handling", + errType = BuildError.BuildErrType.WRONG_STATE, + commit=commit + ) def returnToActualVersion(cfg): @@ -324,12 +360,25 @@ class CmdError(Exception): pass -class NoCleanFailedError(Exception): +class RepoError(Exception): pass -class RepoError(Exception): - pass +class BuildError(Exception): + class BuildErrType(Enum): + # Undefined - unresolved behaviour, to-do ... + UNDEFINED = 0 + TO_REBUILD = 1 + TO_SKIP = 2 + TO_STOP = 3 + # throwed in unexpected case + WRONG_STATE = 4 + def __init__(self, commit, message, errType): + self.message = message + self.errType = errType + self.commit = commit + def __str__(self): + return self.message def checkAndGetClassnameByConfig(cfg, mapName, specialCfg): diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py b/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py index 6ebdb1bb51aae5..ec990ad89e183a 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py @@ -1,7 +1,7 @@ import os from utils.helpers import fetchAppOutput, getActualPath from utils.helpers import getMeaningfullCommitTail -from utils.helpers import handleCommit, runCommandList, getBlobDiff +from utils.helpers import handleCommit, getBlobDiff from utils.helpers import getCommitLogger, CashError, CfgError, CmdError import re import shutil @@ -18,23 +18,19 @@ def checkCfg(self, cfg): if not ("stopPattern" in cfg["runConfig"]): raise CfgError("stopPattern is not configured") - def checkIfBordersDiffer(self, i1, i2, list, cfg): - isLeftBorderFailed = False - if i1 != 0 or cfg["checkIfBordersDiffer"]: - isLeftBorderFailed = self.isBadVersion(list[i1], cfg) - - isRightBorderGood = not self.isBadVersion(list[i2], cfg) - rightCommit = list[i2] - rightCommit = rightCommit.replace('"', "") - commitLogger = getCommitLogger(cfg, rightCommit) + def compareCommits(self, lCommit, rCommit, list, cfg): + isLeftBorderFailed = self.getPseudoMetric(lCommit, cfg) + isRightBorderGood = not self.getPseudoMetric(rCommit, cfg) + curCommit = rCommit.replace('"', "") + commitLogger = getCommitLogger(cfg, curCommit) commitLogger.info( "Commit {c} is {status}".format( status=("good" if isRightBorderGood else "bad"), - c=list[i2]) + c=rCommit) ) return isLeftBorderFailed == isRightBorderGood - def isBadVersion(self, commit, cfg): + def getPseudoMetric(self, commit, cfg): commit = commit.replace('"', "") checkOut = "" commitLogger = getCommitLogger(cfg, commit) @@ -66,9 +62,9 @@ def __init__(self, cfg): self.perfRel = 0 self.createCash() - def prepareRun(self, i1, i2, list, cfg): - super().prepareRun(i1, i2, list, cfg) - sampleCommit = list[i1] + def prepareRun(self, list, cfg): + super().prepareRun(list, cfg) + sampleCommit = list[0] sampleCommit = sampleCommit.replace('"', "") self.commonLogger.info( "Prepare sample commit - {commit}".format(commit=sampleCommit) @@ -82,7 +78,7 @@ def prepareRun(self, i1, i2, list, cfg): commitLogger.info(logMsg) foundThroughput = cashedThroughput else: - runCommandList(sampleCommit, cfg, enforceClean=True) + handleCommit(sampleCommit, cfg) output = fetchAppOutput(cfg, sampleCommit) commitLogger.info(output) foundThroughput = re.search( @@ -98,23 +94,22 @@ def checkCfg(self, cfg): else: self.apprDev = cfg["runConfig"]["perfAppropriateDeviation"] - def checkIfBordersDiffer(self, i1, i2, list, cfg): - leftThroughput = self.getThroughputByCommit(list[i1], cfg) - rightCommit = list[i2] - rightThroughput = self.getThroughputByCommit(rightCommit, cfg) + def compareCommits(self, lCommit, rCommit, list, cfg): + leftThroughput = self.getPseudoMetric(lCommit, cfg) + rightThroughput = self.getPseudoMetric(rCommit, cfg) curRel = rightThroughput / leftThroughput isBad = not ((1 - curRel) < self.apprDev) if isBad: self.perfRel = curRel - rightCommit = rightCommit.replace('"', "") - commitLogger = getCommitLogger(cfg, rightCommit) + curCommit = rCommit.replace('"', "") + commitLogger = getCommitLogger(cfg, curCommit) commitLogger.info("Performance relation is {rel}".format(rel=curRel)) commitLogger.info( "Commit is {status}".format(status=("bad" if isBad else "good")) ) return isBad - def getThroughputByCommit(self, commit, cfg): + def getPseudoMetric(self, commit, cfg): commit = commit.replace('"', "") curThroughput = 0 commitLogger = getCommitLogger(cfg, commit) @@ -141,12 +136,10 @@ def getThroughputByCommit(self, commit, cfg): def setOutputInfo(self, pathCommit): pathCommit.perfRel = self.perfRel - def getResult(self): - for pathCommit in self.commitPath.getList(): - print("Break commit: {c}, perf. ratio = {d}".format( - c=self.commitList[pathCommit.id], - d=pathCommit.perfRel) - ) + def getCommitInfo(self, commit): + return "{ci}, perf. ratio = {d}".format( + ci=super().getCommitInfo(commit), + d=commit.perfRel) class CompareBlobsMode(Mode): @@ -155,7 +148,7 @@ def __init__(self, cfg): self.createCash() self.maxDiff = 0 - def getOutNameByCommit(self, commit, cfg): + def getPseudoMetric(self, commit, cfg): commit = commit.replace('"', "") commitLogger = getCommitLogger(cfg, commit) filename = '' @@ -169,26 +162,26 @@ def getOutNameByCommit(self, commit, cfg): self.commonLogger.info("New commit: {commit}".format( commit=commit) ) - runCommandList(commit, cfg, enforceClean=True) + handleCommit(commit, cfg) output = fetchAppOutput(cfg, commit) commitLogger.info(output) filename = self.setCommitCash(commit, None) return filename - def checkIfBordersDiffer(self, i1, i2, list, cfg): - leftBorderOutputName = self.getOutNameByCommit(list[i1], cfg) - rightBorderOutputName = self.getOutNameByCommit(list[i2], cfg) + def compareCommits(self, lCommit, rCommit, list, cfg): + leftBorderOutputName = self.getPseudoMetric(lCommit, cfg) + rightBorderOutputName = self.getPseudoMetric(rCommit, cfg) fullLeftFileName = os.path.join(self.cachePath, leftBorderOutputName) fullRightName = os.path.join(self.cachePath, rightBorderOutputName) curMaxDiff = getBlobDiff(fullLeftFileName, fullRightName) isDiff = True if curMaxDiff > self.limit else False - rightCommit = list[i2] - rightCommit = rightCommit.replace('"', "") - commitLogger = getCommitLogger(cfg, rightCommit) + curCommit = rCommit + curCommit = curCommit.replace('"', "") + commitLogger = getCommitLogger(cfg, curCommit) commitLogger.info( "Commit {status} from {c}".format( status=("differs" if isDiff else "don't differ"), - c=list[i2]) + c=rCommit) ) if isDiff: self.maxDiff = curMaxDiff @@ -250,9 +243,7 @@ def getCommitIfCashed(self, commit): def setOutputInfo(self, pathCommit): pathCommit.diff = self.maxDiff - def getResult(self): - for pathcommit in self.commitPath.getList(): - print("Break commit: {c}, diff = {d}".format( - c=self.commitList[pathcommit.id], - d=pathcommit.diff) - ) + def getCommitInfo(self, commit): + return "{ci}, diff = {d}".format( + ci=super().getCommitInfo(commit), + d=commit.diff) From 4598da7a5580a98c43119072abf09ffc933a9e2b Mon Sep 17 00:00:00 2001 From: Maciej Smyk Date: Wed, 6 Sep 2023 08:15:35 +0200 Subject: [PATCH 13/31] [DOCS][PT FE] Update pytorch conversion docs for master --- .../Convert_Model_From_PyTorch.md | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md index adaa969cbbfb70..055e94049a78ed 100644 --- a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md +++ b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md @@ -7,13 +7,17 @@ PyTorch format to the OpenVINO Intermediate Representation. -This page provides instructions on how to convert a model from the PyTorch format to the OpenVINO IR format using Model Optimizer. -Model Optimizer Python API allows the conversion of PyTorch models using the ``convert_model()`` method. +This page provides instructions on how to convert a model from the PyTorch format to the OpenVINO IR format. -(Experimental) Converting a PyTorch model with PyTorch Frontend +The conversion is a required step to run inference using OpenVINO API. +It is not required if you choose to work with OpenVINO under the PyTorch framework, +using its :doc:`torch.compile feature `. + +Converting a PyTorch model with PyTorch Frontend ############################################################### -Example of PyTorch model conversion: +To convert a PyTorch model to the OpenVINO IR format, use the OVC API (superseding the previously used tool, MO). To do so, use the ``convert_model()`` method, like so: + .. code-block:: py :force: @@ -31,12 +35,8 @@ Following PyTorch model formats are supported: * ``torch.jit.ScriptModule`` * ``torch.jit.ScriptFunction`` -Converting certain PyTorch models may require model tracing, which needs ``input_shape`` or ``example_input`` parameters to be set. - -* ``example_input`` is used as example input for model tracing. -* ``input_shape`` is used for constructing a float zero-filled torch.Tensor for model tracing. - -Example of using ``example_input``: +Converting certain PyTorch models may require model tracing, which needs the ``example_input`` +parameter to be set, for example: .. code-block:: py :force: @@ -46,7 +46,7 @@ Example of using ``example_input``: from openvino.tools.mo import convert_model model = torchvision.models.resnet50(pretrained=True) - ov_model = convert_model(model, example_input=torch.zeros(1, 3, 100, 100)) + ov_model = convert_model(model, example_input=torch.randn(1, 3, 100, 100)) ``example_input`` accepts the following formats: @@ -56,6 +56,10 @@ Example of using ``example_input``: * ``list`` or ``tuple`` with tensors (``openvino.runtime.Tensor`` / ``torch.Tensor`` / ``np.ndarray``) * ``dictionary`` where key is the input name, value is the tensor (``openvino.runtime.Tensor`` / ``torch.Tensor`` / ``np.ndarray``) +Sometimes ``convert_model`` will produce inputs of the model with dynamic rank or dynamic type. +Such model may not be supported by the hardware chosen for inference. To avoid this issue, +use the ``input`` argument of ``convert_model``. For more information, refer to `Convert Models Represented as Python Objects `. + .. important:: The ``convert_model()`` method returns ``ov.Model`` that you can optimize, compile, or save to a file for subsequent use. @@ -63,7 +67,7 @@ Example of using ``example_input``: Exporting a PyTorch Model to ONNX Format ######################################## -Currently, the most robust method of converting PyTorch models is exporting a PyTorch model to ONNX and then converting it to IR. To convert and deploy a PyTorch model, follow these steps: +It is also possible to export a PyTorch model to ONNX and then convert it to OpenVINO IR. To convert and deploy a PyTorch model this way, follow these steps: 1. `Export a PyTorch model to ONNX <#exporting-a-pytorch-model-to-onnx-format>`__. 2. :doc:`Convert the ONNX model ` to produce an optimized :doc:`Intermediate Representation ` of the model based on the trained network topology, weights, and biases values. @@ -90,12 +94,6 @@ To export a PyTorch model, you need to obtain the model as an instance of ``torc torch.onnx.export(model, (dummy_input, ), 'model.onnx') -Known Issues -#################### - -As of version 1.8.1, not all PyTorch operations can be exported to ONNX opset 9 which is used by default. -It is recommended to export models to opset 11 or higher when export to default opset 9 is not working. In that case, use ``opset_version`` option of the ``torch.onnx.export``. For more information about ONNX opset, refer to the `Operator Schemas `__ page. - Additional Resources #################### From a322b8256dfc3a0c2bb1c8ce7c11b2e2ad6af119 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 6 Sep 2023 10:46:37 +0400 Subject: [PATCH 14/31] Unlock custom creation of PLATFORM_TAG (#19609) --- src/bindings/python/wheel/CMakeLists.txt | 29 ++++++++++-------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/bindings/python/wheel/CMakeLists.txt b/src/bindings/python/wheel/CMakeLists.txt index 3311380557e85a..0641f6f788ddee 100644 --- a/src/bindings/python/wheel/CMakeLists.txt +++ b/src/bindings/python/wheel/CMakeLists.txt @@ -58,24 +58,19 @@ if(APPLE) elseif(LINUX) _ov_platform_arch() - if(CMAKE_CROSSCOMPILING) - # TODO: think which proper tag is needed for arm / aarch64 - set(PLATFORM_TAG "linux_${_arch}") - else() - string(REPLACE "." "_" _ov_glibc_version "${OV_GLIBC_VERSION}") - set(manylinux "manylinux_${_ov_glibc_version}") - - # convert to well-known formats according to PEP 600 - if(manylinux STREQUAL "manylinux_2_5") - set(manylinux "manylinux1") - elseif(manylinux STREQUAL "manylinux_2_12") - set(manylinux "manylinux2010") - elseif(manylinux STREQUAL "manylinux_2_17") - set(manylinux "manylinux2014") - endif() - - set(PLATFORM_TAG "${manylinux}_${_arch}") + string(REPLACE "." "_" _ov_glibc_version "${OV_GLIBC_VERSION}") + set(manylinux "manylinux_${_ov_glibc_version}") + + # convert to well-known formats according to PEP 600 + if(manylinux STREQUAL "manylinux_2_5") + set(manylinux "manylinux1") + elseif(manylinux STREQUAL "manylinux_2_12") + set(manylinux "manylinux2010") + elseif(manylinux STREQUAL "manylinux_2_17") + set(manylinux "manylinux2014") endif() + + set(PLATFORM_TAG "${manylinux}_${_arch}") endif() set(openvino_wheel_name "openvino-${WHEEL_VERSION}-${WHEEL_BUILD}-${PYTHON_TAG}-${ABI_TAG}-${PLATFORM_TAG}.whl") From 46d05cc820d3a435712b99bb461986947309122e Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 6 Sep 2023 10:48:26 +0400 Subject: [PATCH 15/31] Fixed CPU plugin compilation (#19629) --- src/plugins/intel_cpu/src/cpu_tensor.cpp | 5 +++-- src/plugins/intel_cpu/thirdparty/mlas | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/intel_cpu/src/cpu_tensor.cpp b/src/plugins/intel_cpu/src/cpu_tensor.cpp index 48d8fdd4be2e45..815edd93099749 100644 --- a/src/plugins/intel_cpu/src/cpu_tensor.cpp +++ b/src/plugins/intel_cpu/src/cpu_tensor.cpp @@ -68,8 +68,9 @@ void Tensor::update_strides() const { OPENVINO_ASSERT(blocked_desc, "not a valid blocked memory descriptor."); auto& strides = blocked_desc->getStrides(); m_strides.resize(strides.size()); - std::transform(strides.cbegin(), strides.cend(), m_strides.begin(), - std::bind1st(std::multiplies(), m_element_type.size())); + std::transform(strides.cbegin(), strides.cend(), m_strides.begin(), [this] (const size_t stride) { + return stride * m_element_type.size(); + }); } void* Tensor::data(const element::Type& element_type) const { diff --git a/src/plugins/intel_cpu/thirdparty/mlas b/src/plugins/intel_cpu/thirdparty/mlas index 8ed1c80deb0607..c7c8a631315000 160000 --- a/src/plugins/intel_cpu/thirdparty/mlas +++ b/src/plugins/intel_cpu/thirdparty/mlas @@ -1 +1 @@ -Subproject commit 8ed1c80deb0607530b3bef23a797335c09cebe1b +Subproject commit c7c8a631315000f17c650af34431009d2f22129c From 8723b5dd6d08266e3b6873c3a2a782d7659df63f Mon Sep 17 00:00:00 2001 From: Anastasia Kuporosova Date: Wed, 6 Sep 2023 10:04:52 +0200 Subject: [PATCH 16/31] resolve gil (#19631) --- src/bindings/python/CMakeLists.txt | 4 ---- .../python/src/pyopenvino/core/compiled_model.cpp | 8 ++++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index 02818d02e8c3d4..4c4c9bce4d7804 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -192,10 +192,6 @@ endif() # Build the code # -# TODO: find a real root cause and remove this workaround -# or localize it to the specific place of the code -add_definitions(-DPYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF) - find_package(pybind11 ${pybind11_min_version} QUIET) if(NOT pybind11_FOUND) diff --git a/src/bindings/python/src/pyopenvino/core/compiled_model.cpp b/src/bindings/python/src/pyopenvino/core/compiled_model.cpp index 9ddfa9e07512f6..e14e82a55f3c7f 100644 --- a/src/bindings/python/src/pyopenvino/core/compiled_model.cpp +++ b/src/bindings/python/src/pyopenvino/core/compiled_model.cpp @@ -28,9 +28,13 @@ void regclass_CompiledModel(py::module m) { "create_infer_request", [](ov::CompiledModel& self) { // Create temporary ov::InferRequest and move it to actual wrapper class. - return std::make_shared(self.create_infer_request(), self.inputs(), self.outputs()); + ov::InferRequest request; + { + py::gil_scoped_release release; + request = self.create_infer_request(); + } + return std::make_shared(std::move(request), self.inputs(), self.outputs()); }, - py::call_guard(), R"( Creates an inference request object used to infer the compiled model. The created request has allocated input and output tensors. From bd66971dd6183f8225d31390c80428511beca1e4 Mon Sep 17 00:00:00 2001 From: Katarzyna Mitrus Date: Wed, 6 Sep 2023 10:20:58 +0200 Subject: [PATCH 17/31] [ShapeInfer] FFTBase shape infer improvement - preserve input sizes bounds and labels (#19463) * Reduce number of rank checks * Preserve data shape if signal_size input is not provided * Add bounds propagation on fft input * Improved preserving bounds on fft input * Remove size_t rank cast and have_axes variable * Check refactor * Use ge helper for rank comparison * Make bounds constexpr * Pass raw pointer instead of unique_ptr ref * Use normalize_axes helper * Ensure to call set label if it's not zero --- .../include/fft_base_shape_inference.hpp | 89 ++++++--- .../include/fft_common_validation.hpp | 59 ++---- .../include/irdft_shape_inference.hpp | 3 +- .../include/rdft_shape_inference.hpp | 3 +- src/core/tests/type_prop/fft_base_complex.cpp | 180 +++++++++++++++++- src/core/tests/type_prop/irdft.cpp | 6 +- src/core/tests/type_prop/rdft.cpp | 4 +- 7 files changed, 259 insertions(+), 85 deletions(-) diff --git a/src/core/shape_inference/include/fft_base_shape_inference.hpp b/src/core/shape_inference/include/fft_base_shape_inference.hpp index a160506b75209e..a3322fa084f31a 100644 --- a/src/core/shape_inference/include/fft_base_shape_inference.hpp +++ b/src/core/shape_inference/include/fft_base_shape_inference.hpp @@ -2,57 +2,92 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include +#include "dimension_util.hpp" #include "fft_common_validation.hpp" #include "openvino/core/axis_vector.hpp" +#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/validation_util.hpp" +#include "openvino/op/util/fft_base.hpp" #include "utils.hpp" namespace ov { namespace op { + +namespace fft { +template ::value>::type* = nullptr> +void apply_dims_from_sizes(const util::FFTBase* op, + TRShape& output_shape, + const std::vector& axes, + const ITensorAccessor& ta) { + using namespace ov::util; + using DimType = typename TRShape::value_type; + + if (const auto output_bounds = get_input_bounds(op, 2, ta)) { + const auto minus_one_bound = std::make_pair(dim::inf_bound, dim::inf_bound); + const auto num_of_axes = axes.size(); + const auto labels = + op->get_input_size() > 2 ? op->get_input_source_output(2).get_tensor().get_value_label() : TensorLabel(); + const bool propagate_labels = num_of_axes <= labels.size(); + for (size_t i = 0; i < num_of_axes; ++i) { + if ((*output_bounds)[i] != minus_one_bound) { + auto& out_dim = output_shape[(axes)[i]]; + out_dim = DimType((*output_bounds)[i].first, (*output_bounds)[i].second); + if (propagate_labels && labels[i] != ov::no_label) { + DimensionTracker::set_label(out_dim, labels[i]); + } + } + } + } else { + for (auto axis : axes) { + output_shape[axis] = ov::Dimension::dynamic(); + } + } +} + +template ::value>::type* = nullptr> +void apply_dims_from_sizes(const util::FFTBase* op, + TRShape& output_shape, + const std::vector& axes, + const ITensorAccessor& ta) { + using namespace ov::util; + using DimType = typename TRShape::value_type; + + if (const auto output_dim_vals = get_input_const_data_as(op, 2, ta)) { + const auto num_of_axes = axes.size(); + for (size_t i = 0; i < num_of_axes; ++i) { + if ((*output_dim_vals)[i] != dim::inf_bound) { + output_shape[(axes)[i]] = DimType((*output_dim_vals)[i]); + } + } + } +} +} // namespace fft + template > std::vector shape_infer(const util::FFTBase* op, const std::vector& input_shapes, const ITensorAccessor& ta = make_tensor_accessor()) { - using DimType = typename T::value_type; - NODE_VALIDATION_CHECK(op, (input_shapes.size() == 2 || input_shapes.size() == 3)); const auto& input_shape = input_shapes[0]; - const auto& axes_shape = input_shapes[1]; auto output_shapes = std::vector(1); auto& output_shape = output_shapes[0]; auto axes = get_input_const_data_as(op, 1, ta); util::fft_common_validation::shape_validation(op, input_shapes, - *axes, - static_cast(axes), + axes.get(), util::fft_common_validation::FFTKind::ComplexInput); output_shape = input_shape; - - if (input_shape.rank().is_static() && axes_shape.rank().is_static() && input_shapes.size() == 3 && axes) { - const auto& signal_size_shape = input_shapes[2]; - auto signal_size = get_input_const_data_as(op, 2, ta); - - if (signal_size_shape.rank().is_static() && signal_size) { - size_t num_of_axes = axes->size(); - for (size_t i = 0; i < num_of_axes; ++i) { - if ((*signal_size)[i] == -1) { - continue; - } - output_shape[(*axes)[i]] = DimType((*signal_size)[i]); + if (input_shapes.size() == 3 && input_shape.rank().is_static()) { + if (axes) { + ov::op::fft::apply_dims_from_sizes(op, output_shape, *axes, ta); + } else { + for (size_t i = 0; i < input_shape.size() - 1; ++i) { + output_shape[i] = ov::Dimension::dynamic(); } - } else if (signal_size_shape.rank().is_static()) { - for (int64_t& axis : *axes) { - output_shape[axis] = ov::Dimension::dynamic(); - } - } - } else if (input_shape.rank().is_static() && (axes_shape.rank().is_dynamic() || !axes)) { - const auto input_rank = input_shape.size(); - for (size_t i = 0; i < input_rank - 1; ++i) { - output_shape[i] = ov::Dimension::dynamic(); } } return output_shapes; diff --git a/src/core/shape_inference/include/fft_common_validation.hpp b/src/core/shape_inference/include/fft_common_validation.hpp index 74a88b8d4e86d4..16a3692dfe08d7 100644 --- a/src/core/shape_inference/include/fft_common_validation.hpp +++ b/src/core/shape_inference/include/fft_common_validation.hpp @@ -11,15 +11,15 @@ namespace ov { namespace op { namespace util { namespace fft_common_validation { -enum class FFTKind { RealInput, ComplexInput }; +enum FFTKind { RealInput = 1, ComplexInput = 2 }; template void validate_input_rank(const ov::op::util::FFTBase* op, const std::vector& input_shapes, const T& input_shape, const T& axes_shape, - size_t input_rank, + int64_t input_rank, FFTKind fft_kind) { - const size_t min_rank = (fft_kind == FFTKind::RealInput) ? 1 : 2; + const int64_t min_rank = fft_kind; NODE_SHAPE_INFER_CHECK(op, input_shapes, input_rank >= min_rank, @@ -40,12 +40,12 @@ void validate_input_rank(const ov::op::util::FFTBase* op, if (fft_kind == FFTKind::RealInput) { NODE_SHAPE_INFER_CHECK(op, input_shapes, - input_rank >= static_cast(axes_shape[0].get_length()), + ov::cmp::ge(input_rank, axes_shape[0].get_length()), "The input rank must be greater than or equal to the number of axes. "); } else { NODE_SHAPE_INFER_CHECK(op, input_shapes, - input_rank >= static_cast(axes_shape[0].get_length() + 1), + ov::cmp::ge(input_rank, axes_shape[0].get_length() + 1), "The input rank must be greater than number of axes."); } } @@ -55,10 +55,9 @@ void validate_axes(const ov::op::util::FFTBase* op, const std::vector& input_shapes, const T& axes_shape, std::vector& axes, - size_t input_rank, - bool axes_are_known, + int64_t input_rank, FFTKind fft_kind) { - if (axes_shape.rank().is_dynamic() || !axes_are_known) { + if (axes_shape.rank().is_dynamic()) { return; } @@ -73,33 +72,11 @@ void validate_axes(const ov::op::util::FFTBase* op, // according to the RDFT operation specification, axes should be integers from -r to (r - 1) // inclusively, where r = rank(data). A negative axis 'a' is interpreted as an axis 'r + a'. const int64_t axis_correction = (fft_kind == FFTKind::RealInput) ? input_rank : (input_rank - 1); - auto axis_min_value = -static_cast(input_rank); - auto axis_max_value = static_cast(input_rank) - 1; - - // RDFT op axes can contain the last axis - if (fft_kind == FFTKind::RealInput) { - --axis_min_value; - ++axis_max_value; - } - - ov::AxisSet axes_set; - for (int64_t& axis : axes) { - NODE_SHAPE_INFER_CHECK(op, - input_shapes, - axis_min_value < axis && axis < axis_max_value, - "Axis value: ", - axis, - ", must be in range (", - axis_min_value, - ", ", - axis_max_value, - ")."); - if (axis < 0) { - axis += axis_correction; - } - axes_set.insert(static_cast(axis)); - } + OPENVINO_SUPPRESS_DEPRECATED_START + ov::normalize_axes(op, axis_correction, axes); + OPENVINO_SUPPRESS_DEPRECATED_END + auto axes_set = AxisSet(std::vector(axes.begin(), axes.end())); NODE_VALIDATION_CHECK(op, axes.size() == axes_set.size(), "Each axis must be unique."); } @@ -124,16 +101,18 @@ void validate_signal_size(const ov::op::util::FFTBase* op, template void shape_validation(const ov::op::util::FFTBase* op, const std::vector& input_shapes, - std::vector& axes, - bool axes_are_known, + std::vector* axes, FFTKind fft_kind) { const auto& input_shape = input_shapes[0]; const auto& axes_shape = input_shapes[1]; - if (input_shape.rank().is_static()) { - const auto input_rank = input_shape.size(); - validate_input_rank(op, input_shapes, input_shape, axes_shape, input_rank, fft_kind); - validate_axes(op, input_shapes, axes_shape, axes, input_rank, axes_are_known, fft_kind); + const auto input_shape_rank = input_shape.rank(); + if (input_shape_rank.is_static()) { + const auto input_rank_length = input_shape_rank.get_length(); + validate_input_rank(op, input_shapes, input_shape, axes_shape, input_rank_length, fft_kind); + if (axes) { + validate_axes(op, input_shapes, axes_shape, *axes, input_rank_length, fft_kind); + } } NODE_SHAPE_INFER_CHECK(op, input_shapes, axes_shape.rank().compatible(1), "Axes input must be 1D tensor."); diff --git a/src/core/shape_inference/include/irdft_shape_inference.hpp b/src/core/shape_inference/include/irdft_shape_inference.hpp index 33bf53f46b3b34..b44edb1be74fb2 100644 --- a/src/core/shape_inference/include/irdft_shape_inference.hpp +++ b/src/core/shape_inference/include/irdft_shape_inference.hpp @@ -28,8 +28,7 @@ std::vector shape_infer(const IRDFT* op, util::fft_common_validation::shape_validation(op, input_shapes, - *axes, - axes_are_known, + axes.get(), util::fft_common_validation::FFTKind::ComplexInput); if (input_shape.rank().is_dynamic()) { diff --git a/src/core/shape_inference/include/rdft_shape_inference.hpp b/src/core/shape_inference/include/rdft_shape_inference.hpp index 65688afc302278..ebdf9d4720c3c9 100644 --- a/src/core/shape_inference/include/rdft_shape_inference.hpp +++ b/src/core/shape_inference/include/rdft_shape_inference.hpp @@ -39,8 +39,7 @@ std::vector shape_infer(const RDFT* op, util::fft_common_validation::shape_validation(op, input_shapes, - *axes, - static_cast(axes), + axes.get(), util::fft_common_validation::FFTKind::RealInput); if (input_shape.rank().is_dynamic()) { diff --git a/src/core/tests/type_prop/fft_base_complex.cpp b/src/core/tests/type_prop/fft_base_complex.cpp index 6b8bddc55cfbc5..d3d5cd9abb7403 100644 --- a/src/core/tests/type_prop/fft_base_complex.cpp +++ b/src/core/tests/type_prop/fft_base_complex.cpp @@ -283,11 +283,8 @@ TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_no_signal_size) { auto dft = this->make_op(data, axes_input); EXPECT_EQ(dft->get_element_type(), element::f32); - EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - - std::vector expected_labels(params.input_shape.size() - 1, no_label); - expected_labels.push_back(get_shape_labels(params.input_shape).back()); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), expected_labels); + EXPECT_EQ(dft->get_output_partial_shape(0), params.input_shape); + EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), get_shape_labels(params.input_shape)); } } @@ -318,7 +315,7 @@ TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_const_signal_size) { auto axes_input = std::make_shared(element::i64, params.axes_shape); auto signal_size_input = op::v0::Constant::create(element::i64, Shape{2}, {100, 200}); - auto dft = this->make_op(data, axes_input); + auto dft = this->make_op(data, axes_input, signal_size_input); EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); @@ -417,12 +414,12 @@ TYPED_TEST_P(FFTInvalidInput, invalid_axes) { auto axes = op::v0::Constant::create(element::i64, Shape{1}, {3}); OV_EXPECT_THROW(std::ignore = this->make_op(data, axes), ov::Exception, - HasSubstr("Axis value: 3, must be in range (-3, 2)")); + HasSubstr("Parameter axis 3 out of the tensor rank range [-2, 1]")); axes = op::v0::Constant::create(element::i64, Shape{1}, {-3}); OV_EXPECT_THROW(std::ignore = this->make_op(data, axes), ov::Exception, - HasSubstr("Axis value: -3, must be in range (-3, 2)")); + HasSubstr("Parameter axis -3 out of the tensor rank range [-2, 1]")); axes = op::v0::Constant::create(element::i64, Shape{2}, {0, -2}); OV_EXPECT_THROW(std::ignore = this->make_op(data, axes), ov::Exception, HasSubstr("Each axis must be unique")); @@ -430,7 +427,7 @@ TYPED_TEST_P(FFTInvalidInput, invalid_axes) { axes = op::v0::Constant::create(element::i64, Shape{1}, {2}); OV_EXPECT_THROW(std::ignore = this->make_op(data, axes), ov::Exception, - HasSubstr("Axis value: 2, must be in range (-3, 2)")); + HasSubstr("Parameter axis 2 out of the tensor rank range [-2, 1]")); axes = op::v0::Constant::create(element::i64, Shape{1, 2}, {0, 1}); OV_EXPECT_THROW(std::ignore = this->make_op(data, axes), ov::Exception, HasSubstr("Axes input must be 1D tensor.")); @@ -477,4 +474,169 @@ TYPED_TEST_P(FFTDynamicTypes, dynamic_types) { REGISTER_TYPED_TEST_SUITE_P(FFTDynamicTypes, dynamic_types); INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, FFTDynamicTypes, FFTBaseTypes); +struct FFTConstantAxesAndShapeOfSignalSizeTestParams { + PartialShape input_shape; + PartialShape ref_output_shape; + std::vector axes; + PartialShape signal_size; + std::vector expected_labels; +}; + +template +class FFTConstantAxesAndShapeOfSignalSizeTest : public TypePropOpTest { +public: + const std::vector test_params{ + FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, + {-1, {10, 16}, {6, 8}, 4, 2}, + {2, 0, -1}, + {{6, 8}, -1, 4}, + {21, 11, 20, 22, 14}}, + FFTConstantAxesAndShapeOfSignalSizeTestParams{{{8, 129}, 50, 130, {0, 500}, 2}, + {{8, 129}, {0, 10}, -1, 40, 2}, + {1, 2, 3}, + {{0, 10}, -1, 40}, + {10, 20, 21, 22, 14}}}; +}; +TYPED_TEST_SUITE_P(FFTConstantAxesAndShapeOfSignalSizeTest); + +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size) { + for (auto params : this->test_params) { + set_shape_labels(params.input_shape, 10); + auto data = std::make_shared(element::f32, params.input_shape); + auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); + + set_shape_labels(params.signal_size, 20); + auto param_of_shape = std::make_shared(element::f32, params.signal_size); + auto signal_size_input = std::make_shared(param_of_shape, element::i64); + + auto dft = this->make_op(data, axes_input, signal_size_input); + + EXPECT_EQ(dft->get_element_type(), element::f32); + EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); + + EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + } +} + +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_first_input_labels) { + auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, + {-1, {10, 16}, {6, 8}, 4, 2}, + {2, 0, -1}, + {{6, 8}, -1, 4}, + {ov::no_label, 11, ov::no_label, ov::no_label, 14}}; + set_shape_labels(params.input_shape, 10); + auto data = std::make_shared(element::f32, params.input_shape); + auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); + + auto param_of_shape = std::make_shared(element::f32, params.signal_size); + auto signal_size_input = std::make_shared(param_of_shape, element::i64); + + auto dft = this->make_op(data, axes_input, signal_size_input); + + EXPECT_EQ(dft->get_element_type(), element::f32); + EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); + + EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); +} + +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_second_input_labels) { + auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, + {-1, {10, 16}, {6, 8}, 4, 2}, + {2, 0, -1}, + {{6, 8}, -1, 4}, + {21, ov::no_label, 20, 22, ov::no_label}}; + + auto data = std::make_shared(element::f32, params.input_shape); + auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); + + set_shape_labels(params.signal_size, 20); + auto param_of_shape = std::make_shared(element::f32, params.signal_size); + auto signal_size_input = std::make_shared(param_of_shape, element::i64); + + auto dft = this->make_op(data, axes_input, signal_size_input); + + EXPECT_EQ(dft->get_element_type(), element::f32); + EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); + + EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); +} + +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_single_label) { + auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, + {-1, {10, 16}, {6, 8}, 4, 2}, + {2, 0, -1}, + {{6, 8}, -1, 4}, + {ov::no_label, 11, 22, ov::no_label, ov::no_label}}; + ov::DimensionTracker::set_label(params.input_shape[1], 11); + + auto data = std::make_shared(element::f32, params.input_shape); + auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); + + ov::DimensionTracker::set_label(params.signal_size[0], 22); + + auto param_of_shape = std::make_shared(element::f32, params.signal_size); + auto signal_size_input = std::make_shared(param_of_shape, element::i64); + + auto dft = this->make_op(data, axes_input, signal_size_input); + + EXPECT_EQ(dft->get_element_type(), element::f32); + EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); + + EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); +} + +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_no_labels) { + auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{ + {3, {10, 16}, 18, 20, 2}, + {-1, {10, 16}, {6, 8}, 4, 2}, + {2, 0, -1}, + {{6, 8}, -1, 4}, + {ov::no_label, ov::no_label, ov::no_label, ov::no_label, ov::no_label}}; + auto data = std::make_shared(element::f32, params.input_shape); + auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); + + auto param_of_shape = std::make_shared(element::f32, params.signal_size); + auto signal_size_input = std::make_shared(param_of_shape, element::i64); + + auto dft = this->make_op(data, axes_input, signal_size_input); + + EXPECT_EQ(dft->get_element_type(), element::f32); + EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); + + EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); +} + +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_concat_signal_size) { + auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{4, {8, 16}, 24, -1, 2}, + {{5, 10}, {8, 16}, -1, 40, 2}, + {1, 0, -2, 3}, + {{5, 10}, -1, 40}, + {20, 11, 21, 22, 14}}; + set_shape_labels(params.input_shape, 10); + auto data = std::make_shared(element::f32, params.input_shape); + auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); + + set_shape_labels(params.signal_size, 20); + auto param_of_shape = std::make_shared(element::f32, params.signal_size); + auto shape_of = std::make_shared(param_of_shape, element::i64); + auto minus_one = op::v0::Constant::create(element::i64, Shape{1}, {-1}); + + auto signal_size_input = std::make_shared(OutputVector{minus_one, shape_of}, 0); + + auto dft = this->make_op(data, axes_input, signal_size_input); + + EXPECT_EQ(dft->get_element_type(), element::f32); + EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); + EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); +} + +REGISTER_TYPED_TEST_SUITE_P(FFTConstantAxesAndShapeOfSignalSizeTest, + constant_axes_and_shape_of_signal_size, + constant_axes_and_shape_of_signal_size_first_input_labels, + constant_axes_and_shape_of_signal_size_second_input_labels, + constant_axes_and_shape_of_signal_size_single_label, + constant_axes_and_shape_of_signal_size_no_labels, + constant_axes_and_shape_of_concat_signal_size); +INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, FFTConstantAxesAndShapeOfSignalSizeTest, FFTBaseTypes); + } // namespace fft_base_test diff --git a/src/core/tests/type_prop/irdft.cpp b/src/core/tests/type_prop/irdft.cpp index 7777b83eed5f72..adb4552d2b1720 100644 --- a/src/core/tests/type_prop/irdft.cpp +++ b/src/core/tests/type_prop/irdft.cpp @@ -395,12 +395,12 @@ TEST(type_prop, irdft_invalid_axes) { auto axes = op::v0::Constant::create(element::i64, Shape{1}, {3}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), Exception, - HasSubstr("Axis value: 3, must be in range (-3, 2)")); + HasSubstr("Parameter axis 3 out of the tensor rank range [-2, 1]")); axes = op::v0::Constant::create(element::i64, Shape{1}, {-3}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), Exception, - HasSubstr("Axis value: -3, must be in range (-3, 2)")); + HasSubstr("Parameter axis -3 out of the tensor rank range [-2, 1]")); axes = op::v0::Constant::create(element::i64, Shape{2}, {0, -2}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), @@ -410,7 +410,7 @@ TEST(type_prop, irdft_invalid_axes) { axes = op::v0::Constant::create(element::i64, Shape{1}, {2}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), Exception, - HasSubstr("Axis value: 2, must be in range (-3, 2)")); + HasSubstr("Parameter axis 2 out of the tensor rank range [-2, 1]")); axes = op::v0::Constant::create(element::i64, Shape{1, 2}, {0, 1}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), diff --git a/src/core/tests/type_prop/rdft.cpp b/src/core/tests/type_prop/rdft.cpp index 7895cdb7652652..dcece6e7fbc9c0 100644 --- a/src/core/tests/type_prop/rdft.cpp +++ b/src/core/tests/type_prop/rdft.cpp @@ -305,12 +305,12 @@ TEST(type_prop, rdft_invalid_axes) { auto axes = op::v0::Constant::create(element::i64, Shape{1}, {3}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), ov::Exception, - HasSubstr("Axis value: 3, must be in range (-4, 3)")); + HasSubstr("Parameter axis 3 out of the tensor rank range [-3, 2]")); axes = op::v0::Constant::create(element::i64, Shape{1}, {-4}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), ov::Exception, - HasSubstr("Axis value: -4, must be in range (-4, 3)")); + HasSubstr("Parameter axis -4 out of the tensor rank range [-3, 2]")); axes = op::v0::Constant::create(element::i64, Shape{2}, {0, -3}); OV_EXPECT_THROW(std::ignore = std::make_shared(data, axes), From 7a4e765600e669a549cc8c8f717c524f70ba2493 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 6 Sep 2023 12:24:18 +0400 Subject: [PATCH 18/31] Removed legacy API from common frontend and shared tests (#19583) * Removed legacy API from common frontend and shared tests * Fixed build --- .../openvino/frontend/extension/op.hpp | 2 +- src/frontends/onnx/tests/load_from.cpp | 2 +- .../frontend/shared/include/basic_api.hpp | 2 +- .../shared/include/conversion_extension.hpp | 4 +- .../frontend/shared/include/convert_model.hpp | 2 +- .../shared/include/cut_specific_model.hpp | 2 +- .../shared/include/library_extension.hpp | 2 +- .../frontend/shared/include/load_from.hpp | 2 +- .../frontend/shared/include/op_extension.hpp | 4 +- .../frontend/shared/include/op_fuzzy.hpp | 2 +- .../frontend/shared/include/partial_shape.hpp | 6 +- .../shared/include/set_element_type.hpp | 2 +- .../frontend/shared/include/telemetry.hpp | 2 +- .../tests/frontend/shared/include/utils.hpp | 1 - .../tests/frontend/shared/src/basic_api.cpp | 7 +-- .../tests/frontend/shared/src/conversion.cpp | 8 +-- .../frontend/shared/src/convert_model.cpp | 31 +++++----- .../shared/src/cut_specific_model.cpp | 60 +++++++++---------- .../frontend/shared/src/library_extension.cpp | 1 - .../tests/frontend/shared/src/load_from.cpp | 25 ++++---- .../frontend/shared/src/op_extension.cpp | 7 +-- .../tests/frontend/shared/src/op_fuzzy.cpp | 35 +++++------ .../frontend/shared/src/partial_shape.cpp | 19 +++--- .../frontend/shared/src/set_element_type.cpp | 13 ++-- 24 files changed, 112 insertions(+), 129 deletions(-) diff --git a/src/frontends/common/include/openvino/frontend/extension/op.hpp b/src/frontends/common/include/openvino/frontend/extension/op.hpp index 0951d18d4d052c..916426f77056b1 100644 --- a/src/frontends/common/include/openvino/frontend/extension/op.hpp +++ b/src/frontends/common/include/openvino/frontend/extension/op.hpp @@ -94,7 +94,7 @@ inline std::shared_ptr create_ov_node_by_name(const std::string& ov_ty "name ", op_name); } - return std::shared_ptr(opset.create(op_name)); + return std::shared_ptr(opset.create(op_name)); } // One-to-one operation mapping for OVOpType != void which means OV type is specified by OVOpType diff --git a/src/frontends/onnx/tests/load_from.cpp b/src/frontends/onnx/tests/load_from.cpp index 7aea8fb8cf3535..38d02b80095817 100644 --- a/src/frontends/onnx/tests/load_from.cpp +++ b/src/frontends/onnx/tests/load_from.cpp @@ -43,7 +43,7 @@ TEST_P(FrontEndLoadFromTest, testLoadFromStreamAndPassPath) { ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(is, path)) << "Could not load the model"; ASSERT_NE(m_inputModel, nullptr); - std::shared_ptr function; + std::shared_ptr function; ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)) << "Could not convert the model to OV representation"; ASSERT_NE(function, nullptr); } diff --git a/src/frontends/tests/frontend/shared/include/basic_api.hpp b/src/frontends/tests/frontend/shared/include/basic_api.hpp index 841844ee04e6d8..6de3307d7f3b56 100644 --- a/src/frontends/tests/frontend/shared/include/basic_api.hpp +++ b/src/frontends/tests/frontend/shared/include/basic_api.hpp @@ -6,7 +6,7 @@ #include -#include +#include "openvino/frontend/manager.hpp" using BasicTestParam = std::tuple -#include -#include +#include "openvino/frontend/extension/conversion.hpp" +#include "openvino/frontend/manager.hpp" struct ConversionExtensionFEParam { std::string m_frontEndName; diff --git a/src/frontends/tests/frontend/shared/include/convert_model.hpp b/src/frontends/tests/frontend/shared/include/convert_model.hpp index 4ff87ca2fedf42..5e589a0a38b8dc 100644 --- a/src/frontends/tests/frontend/shared/include/convert_model.hpp +++ b/src/frontends/tests/frontend/shared/include/convert_model.hpp @@ -6,7 +6,7 @@ #include -#include +#include "openvino/frontend/manager.hpp" using ConvertParam = std::tuple -#include +#include "openvino/frontend/manager.hpp" struct CutModelParam { std::string m_frontEndName; diff --git a/src/frontends/tests/frontend/shared/include/library_extension.hpp b/src/frontends/tests/frontend/shared/include/library_extension.hpp index e27696ebcc1946..d9208bd54b5c4c 100644 --- a/src/frontends/tests/frontend/shared/include/library_extension.hpp +++ b/src/frontends/tests/frontend/shared/include/library_extension.hpp @@ -6,7 +6,7 @@ #include -#include +#include "openvino/frontend/manager.hpp" struct FrontendLibraryExtensionTestParams { std::string m_frontEndName; diff --git a/src/frontends/tests/frontend/shared/include/load_from.hpp b/src/frontends/tests/frontend/shared/include/load_from.hpp index 48e629a1505475..7aa3ab8799ce89 100644 --- a/src/frontends/tests/frontend/shared/include/load_from.hpp +++ b/src/frontends/tests/frontend/shared/include/load_from.hpp @@ -6,7 +6,7 @@ #include -#include +#include "openvino/frontend/manager.hpp" struct LoadFromFEParam { std::string m_frontEndName; diff --git a/src/frontends/tests/frontend/shared/include/op_extension.hpp b/src/frontends/tests/frontend/shared/include/op_extension.hpp index 926153995b0d08..fd8d4ce9ed1302 100644 --- a/src/frontends/tests/frontend/shared/include/op_extension.hpp +++ b/src/frontends/tests/frontend/shared/include/op_extension.hpp @@ -6,8 +6,8 @@ #include -#include -#include +#include "openvino/frontend/extension/op.hpp" +#include "openvino/frontend/manager.hpp" struct OpExtensionFEParam { std::string m_frontEndName; diff --git a/src/frontends/tests/frontend/shared/include/op_fuzzy.hpp b/src/frontends/tests/frontend/shared/include/op_fuzzy.hpp index e3dde4bac01741..9ac3b7b162f4ac 100644 --- a/src/frontends/tests/frontend/shared/include/op_fuzzy.hpp +++ b/src/frontends/tests/frontend/shared/include/op_fuzzy.hpp @@ -6,7 +6,7 @@ #include -#include +#include "openvino/frontend/manager.hpp" using FuzzyOpTestParam = std::tuple -#include +#include "openvino/frontend/manager.hpp" struct BaseFEParam { BaseFEParam() {} @@ -20,8 +20,8 @@ struct BaseFEParam { struct PartShape { std::string m_modelName; std::string m_tensorName; - ngraph::PartialShape m_oldPartialShape; - ngraph::PartialShape m_newPartialShape; + ov::PartialShape m_oldPartialShape; + ov::PartialShape m_newPartialShape; }; using PartialShapeParam = std::tuple; diff --git a/src/frontends/tests/frontend/shared/include/set_element_type.hpp b/src/frontends/tests/frontend/shared/include/set_element_type.hpp index 6ebca847d18eaa..0a9310f1c451f1 100644 --- a/src/frontends/tests/frontend/shared/include/set_element_type.hpp +++ b/src/frontends/tests/frontend/shared/include/set_element_type.hpp @@ -6,7 +6,7 @@ #include -#include +#include "openvino/frontend/manager.hpp" struct SetTypeFEParam { std::string m_frontEndName; diff --git a/src/frontends/tests/frontend/shared/include/telemetry.hpp b/src/frontends/tests/frontend/shared/include/telemetry.hpp index 13a0b8e9f6d805..8b2e581366fbae 100644 --- a/src/frontends/tests/frontend/shared/include/telemetry.hpp +++ b/src/frontends/tests/frontend/shared/include/telemetry.hpp @@ -6,7 +6,7 @@ #include -#include +#include "openvino/frontend/manager.hpp" class TelemetryMock { public: diff --git a/src/frontends/tests/frontend/shared/include/utils.hpp b/src/frontends/tests/frontend/shared/include/utils.hpp index 2e8ff5ae9385a2..8d4cce4e5196f1 100644 --- a/src/frontends/tests/frontend/shared/include/utils.hpp +++ b/src/frontends/tests/frontend/shared/include/utils.hpp @@ -10,7 +10,6 @@ #include "common_test_utils/file_utils.hpp" #include "file_utils.h" -#include "ngraph/util.hpp" #include "openvino/util/env_util.hpp" #include "openvino/util/file_util.hpp" diff --git a/src/frontends/tests/frontend/shared/src/basic_api.cpp b/src/frontends/tests/frontend/shared/src/basic_api.cpp index 7e6020da19dde3..cff58b4dae5cc0 100644 --- a/src/frontends/tests/frontend/shared/src/basic_api.cpp +++ b/src/frontends/tests/frontend/shared/src/basic_api.cpp @@ -6,7 +6,6 @@ #include "utils.hpp" -using namespace ngraph; using namespace ov::frontend; std::string FrontEndBasicTest::getTestCaseName(const testing::TestParamInfo& obj) { @@ -32,9 +31,9 @@ void FrontEndBasicTest::doLoadFromFile() { TEST_P(FrontEndBasicTest, testLoadFromFile) { ASSERT_NO_THROW(doLoadFromFile()); ASSERT_EQ(m_frontEnd->get_name(), m_feName); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - ASSERT_NE(function, nullptr); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + ASSERT_NE(model, nullptr); } TEST_P(FrontEndBasicTest, testInputModel_getInputsOutputs) { diff --git a/src/frontends/tests/frontend/shared/src/conversion.cpp b/src/frontends/tests/frontend/shared/src/conversion.cpp index 03b96d761c4445..286a5bd638adf4 100644 --- a/src/frontends/tests/frontend/shared/src/conversion.cpp +++ b/src/frontends/tests/frontend/shared/src/conversion.cpp @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include +#include "openvino/frontend/extension/conversion.hpp" #include "common_test_utils/file_utils.hpp" #include "conversion_extension.hpp" +#include "openvino/frontend/extension/decoder_transformation.hpp" +#include "openvino/op/util/framework_node.hpp" +#include "openvino/opsets/opset8.hpp" #include "utils.hpp" using namespace ov::frontend; diff --git a/src/frontends/tests/frontend/shared/src/convert_model.cpp b/src/frontends/tests/frontend/shared/src/convert_model.cpp index 7351242fb8fb5a..bc7c661950fd3b 100644 --- a/src/frontends/tests/frontend/shared/src/convert_model.cpp +++ b/src/frontends/tests/frontend/shared/src/convert_model.cpp @@ -8,7 +8,6 @@ #include "openvino/pass/visualize_tree.hpp" #include "utils.hpp" -using namespace ngraph; using namespace ov::frontend; std::string FrontEndConvertModelTest::getTestCaseName(const testing::TestParamInfo& obj) { @@ -38,37 +37,37 @@ void FrontEndConvertModelTest::doLoadFromFile() { TEST_P(FrontEndConvertModelTest, test_convert_partially_equal_convert) { ASSERT_NO_THROW(doLoadFromFile()); - std::shared_ptr function_ref; - ASSERT_NO_THROW(function_ref = m_frontEnd->convert(m_inputModel)); - ASSERT_NE(function_ref, nullptr); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert_partially(m_inputModel)); - ASSERT_NE(function, nullptr); + std::shared_ptr model_ref; + ASSERT_NO_THROW(model_ref = m_frontEnd->convert(m_inputModel)); + ASSERT_NE(model_ref, nullptr); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert_partially(m_inputModel)); + ASSERT_NE(model, nullptr); FunctionsComparator func_comparator = FunctionsComparator::with_default(); // TODO: enable name comparison for tf when TransposeSinking is fixed, ticket 68960 if (m_frontEnd->get_name() != "tf" && m_frontEnd->get_name() != "tflite") { func_comparator.enable(FunctionsComparator::NAMES); } - const FunctionsComparator::Result res = func_comparator(function, function_ref); + const FunctionsComparator::Result res = func_comparator(model, model_ref); ASSERT_TRUE(res.valid) << res.message; } TEST_P(FrontEndConvertModelTest, test_decode_convert_equal_convert) { ASSERT_NO_THROW(doLoadFromFile()); - std::shared_ptr function_ref; - ASSERT_NO_THROW(function_ref = m_frontEnd->convert(m_inputModel)); - ASSERT_NE(function_ref, nullptr); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->decode(m_inputModel)); - ASSERT_NO_THROW(m_frontEnd->convert(function)); - ASSERT_NE(function, nullptr); + std::shared_ptr model_ref; + ASSERT_NO_THROW(model_ref = m_frontEnd->convert(m_inputModel)); + ASSERT_NE(model_ref, nullptr); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->decode(m_inputModel)); + ASSERT_NO_THROW(m_frontEnd->convert(model)); + ASSERT_NE(model, nullptr); FunctionsComparator func_comparator = FunctionsComparator::with_default(); // TODO: enable name comparison for tf when TransposeSinking is fixed, ticket 68960 if (m_frontEnd->get_name() != "tf" && m_frontEnd->get_name() != "tflite") { func_comparator.enable(FunctionsComparator::NAMES); } - const FunctionsComparator::Result res = func_comparator(function, function_ref); + const FunctionsComparator::Result res = func_comparator(model, model_ref); ASSERT_TRUE(res.valid) << res.message; } diff --git a/src/frontends/tests/frontend/shared/src/cut_specific_model.cpp b/src/frontends/tests/frontend/shared/src/cut_specific_model.cpp index fc6cbacb0322c6..c060a17321c0e3 100644 --- a/src/frontends/tests/frontend/shared/src/cut_specific_model.cpp +++ b/src/frontends/tests/frontend/shared/src/cut_specific_model.cpp @@ -4,10 +4,10 @@ #include "cut_specific_model.hpp" -#include "ngraph/opsets/opset7.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/constant.hpp" #include "utils.hpp" -using namespace ngraph; using namespace ov::frontend; static std::string joinStrings(const std::vector& strings) { @@ -100,15 +100,15 @@ TEST_P(FrontEndCutModelTest, testOverrideOutputs) { TEST_P(FrontEndCutModelTest, testOldInputs) { ASSERT_NO_THROW(doLoadFromFile()); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); // Ensure that it contains expected old inputs for (const auto& name : m_param.m_oldInputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) != ops.end()) << "Name not found:" << name; @@ -117,14 +117,14 @@ TEST_P(FrontEndCutModelTest, testOldInputs) { TEST_P(FrontEndCutModelTest, testOldOutputs) { ASSERT_NO_THROW(doLoadFromFile()); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); // Ensure that it contains expected old outputs for (const auto& name : m_param.m_oldOutputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) != ops.end()) << "Name not found:" << name; @@ -137,15 +137,15 @@ TEST_P(FrontEndCutModelTest, testNewInputs_func) { ASSERT_NO_THROW(newPlaces = constructNewInputs()); ASSERT_NO_THROW(m_inputModel->override_all_inputs(newPlaces)); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); // Ensure that it doesn't contain old inputs for (const auto& name : m_param.m_oldInputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) == ops.end()) << "Name shall not exist:" << name; @@ -155,7 +155,7 @@ TEST_P(FrontEndCutModelTest, testNewInputs_func) { for (const auto& name : m_param.m_newInputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) != ops.end()) << "Name not found:" << name; @@ -168,15 +168,15 @@ TEST_P(FrontEndCutModelTest, testNewOutputs_func) { ASSERT_NO_THROW(newPlaces = constructNewOutputs()); ASSERT_NO_THROW(m_inputModel->override_all_outputs(newPlaces)); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); // Ensure that it doesn't contain old outputs for (const auto& name : m_param.m_oldOutputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) == ops.end()) << "Name shall not exist:" << name; @@ -186,7 +186,7 @@ TEST_P(FrontEndCutModelTest, testNewOutputs_func) { for (const auto& name : m_param.m_newOutputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) != ops.end()) << "Name not found:" << name; @@ -200,15 +200,15 @@ TEST_P(FrontEndCutModelTest, testExtractSubgraph) { ASSERT_NO_THROW(newOutputs = constructNewOutputs()); ASSERT_NO_THROW(m_inputModel->extract_subgraph(newInputs, newOutputs)); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); // Ensure that it doesn't contain expected old outputs for (const auto& name : m_param.m_oldOutputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) == ops.end()) << "Name shall not exist:" << name; @@ -218,7 +218,7 @@ TEST_P(FrontEndCutModelTest, testExtractSubgraph) { for (const auto& name : m_param.m_newOutputs) { EXPECT_TRUE(std::find_if(ops.begin(), ops.end(), - [&](const std::shared_ptr& node) { + [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }) != ops.end()) << "Name not found:" << name; @@ -231,16 +231,16 @@ TEST_P(FrontEndCutModelTest, testSetTensorValue) { ASSERT_NO_THROW(place = m_inputModel->get_place_by_tensor_name(m_param.m_tensorValueName)); ASSERT_NO_THROW(m_inputModel->set_tensor_value(place, &m_param.m_tensorValue[0])); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); auto const_name = m_param.m_tensorValueName; - auto const_node_it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { + auto const_node_it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { return node->get_friendly_name().find(const_name) != std::string::npos; }); ASSERT_TRUE(const_node_it != ops.end()) << "Name shall exist:" << const_name; - auto data = std::dynamic_pointer_cast(*const_node_it)->get_vector(); + auto data = std::dynamic_pointer_cast(*const_node_it)->get_vector(); EXPECT_EQ(data.size(), m_param.m_tensorValue.size()) << "Data size must be equal to expected size"; EXPECT_TRUE(std::equal(data.begin(), data.end(), m_param.m_tensorValue.begin())) << "Data must be equal"; } diff --git a/src/frontends/tests/frontend/shared/src/library_extension.cpp b/src/frontends/tests/frontend/shared/src/library_extension.cpp index 22ce2e6c7bfc44..75f68869775520 100644 --- a/src/frontends/tests/frontend/shared/src/library_extension.cpp +++ b/src/frontends/tests/frontend/shared/src/library_extension.cpp @@ -4,7 +4,6 @@ #include "library_extension.hpp" -#include #include #include "common_test_utils/file_utils.hpp" diff --git a/src/frontends/tests/frontend/shared/src/load_from.cpp b/src/frontends/tests/frontend/shared/src/load_from.cpp index 55b6972f29ef37..202d7c13e11ff9 100644 --- a/src/frontends/tests/frontend/shared/src/load_from.cpp +++ b/src/frontends/tests/frontend/shared/src/load_from.cpp @@ -9,7 +9,6 @@ #include "openvino/core/runtime_attribute.hpp" #include "utils.hpp" -using namespace ngraph; using namespace ov::frontend; std::string FrontEndLoadFromTest::getTestCaseName(const testing::TestParamInfo& obj) { @@ -35,9 +34,9 @@ TEST_P(FrontEndLoadFromTest, testLoadFromFilePath) { ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(model_path)); ASSERT_NE(m_inputModel, nullptr); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - ASSERT_NE(function, nullptr); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + ASSERT_NE(model, nullptr); } TEST_P(FrontEndLoadFromTest, testLoadFromFilePathWithExplicitVariants) { @@ -71,9 +70,9 @@ TEST_P(FrontEndLoadFromTest, testLoadFromTwoFiles) { ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(model_path, weights_path)); ASSERT_NE(m_inputModel, nullptr); - std::shared_ptr function; - function = m_frontEnd->convert(m_inputModel); - ASSERT_NE(function, nullptr); + std::shared_ptr model; + model = m_frontEnd->convert(m_inputModel); + ASSERT_NE(model, nullptr); } TEST_P(FrontEndLoadFromTest, testLoadFromStream) { @@ -89,9 +88,9 @@ TEST_P(FrontEndLoadFromTest, testLoadFromStream) { ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(is)); ASSERT_NE(m_inputModel, nullptr); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - ASSERT_NE(function, nullptr); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + ASSERT_NE(model, nullptr); } TEST_P(FrontEndLoadFromTest, testLoadFromTwoStreams) { @@ -111,7 +110,7 @@ TEST_P(FrontEndLoadFromTest, testLoadFromTwoStreams) { ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(model_is, weights_is)); ASSERT_NE(m_inputModel, nullptr); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - ASSERT_NE(function, nullptr); + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + ASSERT_NE(model, nullptr); } diff --git a/src/frontends/tests/frontend/shared/src/op_extension.cpp b/src/frontends/tests/frontend/shared/src/op_extension.cpp index c9151703c4a84d..8c8b3dfa25a2fb 100644 --- a/src/frontends/tests/frontend/shared/src/op_extension.cpp +++ b/src/frontends/tests/frontend/shared/src/op_extension.cpp @@ -4,12 +4,7 @@ #include "op_extension.hpp" -#include -#include -#include -#include -#include - +#include "openvino/runtime/core.hpp" #include "utils.hpp" using namespace ov::frontend; diff --git a/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp b/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp index 691ecf4335c47f..8a911e6544f094 100644 --- a/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp +++ b/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp @@ -10,10 +10,6 @@ #include "common_test_utils/test_control.hpp" #include "utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; - -using namespace ngraph; using namespace ov::frontend; std::string FrontEndFuzzyOpTest::getTestCaseName(const testing::TestParamInfo& obj) { @@ -59,46 +55,45 @@ static std::string getModelFolder(const std::string& modelFile) { return modelFile.substr(0, found); }; -void FrontEndFuzzyOpTest::runConvertedModel(const std::shared_ptr function, - const std::string& modelFile) { +void FrontEndFuzzyOpTest::runConvertedModel(const std::shared_ptr model, const std::string& modelFile) { auto modelFolder = getModelFolder(modelFile); // run test - auto testCase = ov::test::TestCase(function, "CPU"); + auto testCase = ov::test::TestCase(model, "CPU"); - const auto parameters = function->get_parameters(); + const auto parameters = model->get_parameters(); for (size_t i = 0; i < parameters.size(); i++) { // read input npy file std::string dataFile = modelFolder + "/input" + std::to_string((parameters.size() - 1) - i) + ".npy"; cnpy::NpyArray input = cnpy::npy_load(dataFile); auto input_dtype = parameters[i]->get_element_type(); - if (input_dtype == element::f32) { + if (input_dtype == ov::element::f32) { addInputOutput(input, testCase, true); - } else if (input_dtype == element::i32) { + } else if (input_dtype == ov::element::i32) { addInputOutput(input, testCase, true); - } else if (input_dtype == element::i64) { + } else if (input_dtype == ov::element::i64) { addInputOutput(input, testCase, true); - } else if (input_dtype == element::boolean) { + } else if (input_dtype == ov::element::boolean) { addInputOutput(input, testCase, true); } else { throw std::runtime_error("not supported dtype in" + input_dtype.get_type_name()); } } - const auto results = function->get_results(); + const auto results = model->get_results(); bool useFloatTest = false; for (size_t i = 0; i < results.size(); i++) { // read expected output npy file std::string dataFile = modelFolder + "/output" + std::to_string(i) + ".npy"; cnpy::NpyArray output = cnpy::npy_load(dataFile); auto outputDtype = results[i]->get_element_type(); - if (outputDtype == element::f32) { + if (outputDtype == ov::element::f32) { addInputOutput(output, testCase, false); useFloatTest = true; - } else if (outputDtype == element::i32) { + } else if (outputDtype == ov::element::i32) { addInputOutput(output, testCase, false); - } else if (outputDtype == element::i64) { + } else if (outputDtype == ov::element::i64) { addInputOutput(output, testCase, false); } else { throw std::runtime_error("not supported dtype out " + outputDtype.get_type_name()); @@ -117,10 +112,10 @@ TEST_P(FrontEndFuzzyOpTest, testOpFuzzy) { ASSERT_NO_THROW(doLoadFromFile()); // convert - std::shared_ptr function; - function = m_frontEnd->convert(m_inputModel); - ASSERT_NE(function, nullptr); + std::shared_ptr model; + model = m_frontEnd->convert(m_inputModel); + ASSERT_NE(model, nullptr); // run - runConvertedModel(function, m_modelFile); + runConvertedModel(model, m_modelFile); } diff --git a/src/frontends/tests/frontend/shared/src/partial_shape.cpp b/src/frontends/tests/frontend/shared/src/partial_shape.cpp index 1305d2937aa2e8..53672b586b6671 100644 --- a/src/frontends/tests/frontend/shared/src/partial_shape.cpp +++ b/src/frontends/tests/frontend/shared/src/partial_shape.cpp @@ -6,7 +6,6 @@ #include "utils.hpp" -using namespace ngraph; using namespace ov::frontend; std::string FrontEndPartialShapeTest::getTestCaseName(const testing::TestParamInfo& obj) { @@ -40,10 +39,10 @@ void FrontEndPartialShapeTest::doLoadFromFile() { TEST_P(FrontEndPartialShapeTest, testCheckOldPartialShape) { ASSERT_NO_THROW(doLoadFromFile()); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); - auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); + auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { return node->get_friendly_name().find(m_partShape.m_tensorName) != std::string::npos; }); ASSERT_NE(it, ops.end()); @@ -56,12 +55,12 @@ TEST_P(FrontEndPartialShapeTest, testSetNewPartialShape) { Place::Ptr place; ASSERT_NO_THROW(place = m_inputModel->get_place_by_tensor_name(m_partShape.m_tensorName)); ASSERT_NE(place, nullptr); - ASSERT_NO_THROW(m_inputModel->set_partial_shape(place, PartialShape{m_partShape.m_newPartialShape})); + ASSERT_NO_THROW(m_inputModel->set_partial_shape(place, ov::PartialShape{m_partShape.m_newPartialShape})); - std::shared_ptr function; - ASSERT_NO_THROW(function = m_frontEnd->convert(m_inputModel)); - auto ops = function->get_ordered_ops(); - auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { + std::shared_ptr model; + ASSERT_NO_THROW(model = m_frontEnd->convert(m_inputModel)); + auto ops = model->get_ordered_ops(); + auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { return node->get_friendly_name().find(m_partShape.m_tensorName) != std::string::npos; }); ASSERT_NE(it, ops.end()); diff --git a/src/frontends/tests/frontend/shared/src/set_element_type.cpp b/src/frontends/tests/frontend/shared/src/set_element_type.cpp index 91f27f28d74ebe..3dc53a82c435ac 100644 --- a/src/frontends/tests/frontend/shared/src/set_element_type.cpp +++ b/src/frontends/tests/frontend/shared/src/set_element_type.cpp @@ -6,7 +6,6 @@ #include "utils.hpp" -using namespace ngraph; using namespace ov::frontend; std::string FrontEndElementTypeTest::getTestCaseName(const testing::TestParamInfo& obj) { @@ -38,14 +37,14 @@ TEST_P(FrontEndElementTypeTest, testSetElementType) { ASSERT_NE(place, nullptr); auto name = place->get_names()[0]; - ASSERT_NO_THROW(m_inputModel->set_element_type(place, element::f16)); + ASSERT_NO_THROW(m_inputModel->set_element_type(place, ov::element::f16)); - std::shared_ptr function; - function = m_frontEnd->convert(m_inputModel); - auto ops = function->get_ordered_ops(); - auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { + std::shared_ptr model; + model = m_frontEnd->convert(m_inputModel); + auto ops = model->get_ordered_ops(); + auto it = std::find_if(ops.begin(), ops.end(), [&](const std::shared_ptr& node) { return node->get_friendly_name().find(name) != std::string::npos; }); ASSERT_NE(it, ops.end()); - EXPECT_EQ((*it)->get_output_element_type(0), element::f16); + EXPECT_EQ((*it)->get_output_element_type(0), ov::element::f16); } From 45cc4fdb3372e21a35f7fbeab7fb05bb03775474 Mon Sep 17 00:00:00 2001 From: Maksim Kutakov Date: Wed, 6 Sep 2023 11:04:38 +0200 Subject: [PATCH 19/31] [CPU] Fix input output tensor binding (#19589) * Fix input output tensor binding plus test * Clean up code --- src/plugins/intel_cpu/src/infer_request.cpp | 26 +++--- .../src/concat_reshape_concat.cpp | 14 +-- .../src/input_output_tensor_reuse.cpp | 88 +++++++++++++++++++ 3 files changed, 110 insertions(+), 18 deletions(-) create mode 100644 src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp diff --git a/src/plugins/intel_cpu/src/infer_request.cpp b/src/plugins/intel_cpu/src/infer_request.cpp index f2aacbd3db42b8..749342edae152c 100644 --- a/src/plugins/intel_cpu/src/infer_request.cpp +++ b/src/plugins/intel_cpu/src/infer_request.cpp @@ -214,6 +214,19 @@ static inline void changeEdgePtr(const EdgePtr &edge, InferenceEngine::Blob::Ptr void InferRequestBase::changeDefaultPtr() { const auto& inputNodesMap = graph->GetInputNodesMap(); const auto& outputNodesMap = graph->GetOutputNodesMap(); + std::unordered_set inputPtrs; + std::function changeInpPtr; + if (Graph::Status::ReadyDynamic == graph->getStatus()) { + changeInpPtr = [&inputPtrs](const EdgePtr &edge, InferenceEngine::Blob::Ptr blob) { + changeEdgePtr(edge, blob); + inputPtrs.insert(blob->buffer()); + }; + } else { + changeInpPtr = [](const EdgePtr &edge, InferenceEngine::Blob::Ptr blob) { + changeEdgePtr(edge, blob); + }; + } + for (auto& it : externalPtr) { auto input = inputNodesMap.find(it.first); if (inputNodesMap.end() == input) { @@ -261,7 +274,7 @@ void InferRequestBase::changeDefaultPtr() { if (!e) IE_THROW() << "Node " << inputNodePtr->getName() << " contains empty child edge"; - changeEdgePtr(e, it.second); + changeInpPtr(e, it.second); } } } @@ -321,18 +334,9 @@ void InferRequestBase::changeDefaultPtr() { OPENVINO_ASSERT(outputNodesMap.end() != output, "Node with name: ", name, " is absent in the outputNodesMap"); auto parentEdge = output->second->getParentEdgeAt(0); //avoid cyclic memory use - auto parentNode = parentEdge->getParent(); - const auto& parentNodeInpEdges = parentNode->getParentEdges(); - std::unordered_set parentInputPtrs(parentNodeInpEdges.size()); - for (auto&& edge : parentNodeInpEdges) { - if (auto edgePtr = edge.lock()) { - parentInputPtrs.insert(edgePtr->getMemoryPtr()->getData()); - } - } - auto&& controlBlock = controlBlockItr->second; - std::shared_ptr memMngr = parentInputPtrs.count(controlBlock.rawPtr()) ? // same memory is used on the input and output + std::shared_ptr memMngr = inputPtrs.count(controlBlock.rawPtr()) ? // same memory is used on the input and output controlBlock.nextMemMngr() : // then swap internal buffer to avoid data corruption controlBlock.currentMemMngr(); // else reuse the existing buffer diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp index 41507b4ae9ed97..57f75c12388216 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp @@ -122,13 +122,13 @@ TEST_P(ConcatReshapeConcatSubgraphTest, CompareWithRefs) { namespace { const std::vector> inputShapes = { - // { - // // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} - // {{2, 64}, {{2, 64}}}, // input 0 - // {{2, 64}, {{2, 64}}}, // input 1 - // {{2, 64}, {{2, 64}}}, // input 2 - // {{2, 64}, {{2, 64}}} // input 3 - // }, + { + // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} + {{2, 64}, {{2, 64}}}, // input 0 + {{2, 64}, {{2, 64}}}, // input 1 + {{2, 64}, {{2, 64}}}, // input 2 + {{2, 64}, {{2, 64}}} // input 3 + }, { // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} {{2, -1}, {{2, 64}}}, // input 0 diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp new file mode 100644 index 00000000000000..f26ed8d1f8d38b --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp @@ -0,0 +1,88 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "ngraph_functions/builders.hpp" + +using namespace InferenceEngine; +using namespace ov::test; + +/*This test runs the following subgraph: + + + Param_0 Param_1 + \ | + \ Softmax + \ / + \ / + Concat + | + Softmax + | + Output_1 + + Output_1 -> Param_1 + + The main purpose of this test is checking the code path when the output tensor is reused as an input tensor of the + next infer request. +*/ + +namespace SubgraphTestsDefinitions { +class InputOutputTensorReuse : public SubgraphBaseTest { +public: + void SetUp() override { + constexpr size_t softmax_axis = 1ul; + constexpr int concat_axis = 2; + targetDevice = ov::test::utils::DEVICE_CPU; + auto netPrc = ov::element::f32; + + ov::ParameterVector input_params; + input_params.push_back(std::make_shared(netPrc, ov::PartialShape{1, 32, -1, 16})); + input_params.push_back(std::make_shared(netPrc, ov::PartialShape{1, 32, -1, 16})); + input_params[0]->set_friendly_name("Param_0"); + input_params[1]->set_friendly_name("Param_1"); + + auto first_soft_max = std::make_shared(input_params[1], softmax_axis); + auto concat = std::make_shared(ov::NodeVector{input_params[0], first_soft_max}, concat_axis); + auto last_soft_max = std::make_shared(concat, softmax_axis); + + ngraph::ResultVector results; + for (size_t i = 0; i < last_soft_max->get_output_size(); i++) + results.push_back(std::make_shared(last_soft_max->output(i))); + + results.front()->set_friendly_name("Output_1"); + + function = std::make_shared(results, input_params, "InputOutputTensorReuseTest"); + } +}; + +TEST_F(InputOutputTensorReuse, smoke_Input_Output_Binding) { + compile_model(); + std::vector inputShapes = {{1, 32, 5, 16}, {1, 32, 1, 16}}; + init_ref_function(functionRefs, inputShapes); + generate_inputs(inputShapes); + validate(); + + constexpr size_t num_iter = 10; + for (size_t i = 0; i < num_iter; i++) { + auto outputTensor = inferRequest.get_output_tensor(0); + inputShapes.back() = outputTensor.get_shape(); + init_ref_function(functionRefs, inputShapes); + auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { + return item.first->get_friendly_name() == "Param_1"; + }); + ASSERT_NE(itr, inputs.end()); + itr->second = outputTensor; + const auto& expectedOutputs = calculate_refs(); + + for (const auto& input : inputs) { + inferRequest.set_tensor(input.first, input.second); + } + inferRequest.infer(); + compare(expectedOutputs, {outputTensor}); + } +} + +} // namespace SubgraphTestsDefinitions \ No newline at end of file From 94bdaea96535f029224294be1701f0662a237980 Mon Sep 17 00:00:00 2001 From: Vladislav Golubev Date: Wed, 6 Sep 2023 14:45:50 +0200 Subject: [PATCH 20/31] [Snippets] ov::Node replaced with lowered::Expression in emitter constructors (#19481) --- .../snippets/include/snippets/emitter.hpp | 6 +- .../include/snippets/lowered/expression.hpp | 2 - .../include/snippets/lowered/linear_ir.hpp | 1 + .../include/snippets/target_machine.hpp | 28 +-- src/common/snippets/src/generator.cpp | 3 +- .../snippets/src/lowered/expression.cpp | 4 - src/common/snippets/src/lowered/linear_ir.cpp | 2 +- .../snippets/src/lowered/target_machine.cpp | 27 +++ .../snippets/tests/include/lowering_utils.hpp | 3 +- .../snippets/tests/src/lowering_utils.cpp | 3 +- .../tests/src/pass/precision_propagation.cpp | 8 +- .../src/emitters/x64/cpu_generator.cpp | 193 +++++++++--------- .../emitters/x64/jit_conversion_emitters.cpp | 2 +- .../src/emitters/x64/jit_dnnl_emitters.cpp | 2 +- .../src/emitters/x64/jit_eltwise_emitters.cpp | 60 +++--- .../src/emitters/x64/jit_eltwise_emitters.hpp | 6 +- .../src/emitters/x64/jit_emitter.hpp | 8 +- .../emitters/x64/jit_snippets_emitters.cpp | 139 ++++++------- .../emitters/x64/jit_snippets_emitters.hpp | 83 +++++--- 19 files changed, 311 insertions(+), 269 deletions(-) create mode 100644 src/common/snippets/src/lowered/target_machine.cpp diff --git a/src/common/snippets/include/snippets/emitter.hpp b/src/common/snippets/include/snippets/emitter.hpp index 7c88d07d2660b2..e1ff08abbf7da2 100644 --- a/src/common/snippets/include/snippets/emitter.hpp +++ b/src/common/snippets/include/snippets/emitter.hpp @@ -25,9 +25,7 @@ class Emitter { /** * @brief Default constructor */ - Emitter(const std::shared_ptr& n) {} - - Emitter(std::vector, RegInfo>>& region) {} + Emitter() {} /** * @brief called by generator to generate code to produce target code for a specific operation @@ -51,7 +49,5 @@ class Emitter { virtual ~Emitter() = default; }; -using AllocatedEmitter = std::pair, ov::snippets::RegInfo>; - } // namespace snippets } // namespace ov diff --git a/src/common/snippets/include/snippets/lowered/expression.hpp b/src/common/snippets/include/snippets/lowered/expression.hpp index 39fa7f79b5c729..05584347c4595b 100644 --- a/src/common/snippets/include/snippets/lowered/expression.hpp +++ b/src/common/snippets/include/snippets/lowered/expression.hpp @@ -8,7 +8,6 @@ #include #include "snippets/emitter.hpp" -#include "snippets/target_machine.hpp" #include "snippets/lowered/port_connector.hpp" #include "snippets/lowered/expression_port.hpp" @@ -47,7 +46,6 @@ class Expression : public std::enable_shared_from_this { size_t get_output_count() const { return m_output_port_connectors.size(); } void validate() const; - void init_emitter(const std::shared_ptr& target); ExpressionPort get_input_port(size_t i); ExpressionPort get_output_port(size_t i); diff --git a/src/common/snippets/include/snippets/lowered/linear_ir.hpp b/src/common/snippets/include/snippets/lowered/linear_ir.hpp index 511894a030eeb3..5e14e308c404ba 100644 --- a/src/common/snippets/include/snippets/lowered/linear_ir.hpp +++ b/src/common/snippets/include/snippets/lowered/linear_ir.hpp @@ -7,6 +7,7 @@ #include #include "expression.hpp" +#include "snippets/target_machine.hpp" namespace ov { namespace snippets { diff --git a/src/common/snippets/include/snippets/target_machine.hpp b/src/common/snippets/include/snippets/target_machine.hpp index 7bffc3af62351e..a4d15463f2972a 100644 --- a/src/common/snippets/include/snippets/target_machine.hpp +++ b/src/common/snippets/include/snippets/target_machine.hpp @@ -9,12 +9,12 @@ #pragma once #include "emitter.hpp" +#include "snippets/lowered/expression.hpp" namespace ov { namespace snippets { - -typedef std::pair(const std::shared_ptr&)>, - std::function>(const std::shared_ptr&)>> jitters_value; +typedef std::pair(const lowered::ExpressionPtr&)>, + std::function(const std::shared_ptr&)>> jitters_value; /** * @interface TargetMachine @@ -46,30 +46,14 @@ class TargetMachine { * @brief called by generator to all the emitter for a target machine * @return a map by node's type info with callbacks to create an instance of emitter for corresponding operation type */ - std::function(const std::shared_ptr)> get(const ov::DiscreteTypeInfo& type) const { - auto jitter = jitters.find(type); - if (jitter == jitters.end()) { - OPENVINO_THROW(std::string("Target code emitter is not available for ") + type.name + " operation."); - } - return jitter->second.first; - } - - std::function>(const std::shared_ptr&)> - get_supported_precisions(const ov::DiscreteTypeInfo type) const { - auto jitter = jitters.find(type); - if (jitter == jitters.end()) { - OPENVINO_THROW(std::string("Target code emitter is not available for ") + type.name + " operation."); - } - return jitter->second.second; - } + std::function(const lowered::ExpressionPtr&)> get(const ov::DiscreteTypeInfo& type) const; + std::function(const std::shared_ptr&)> get_supported_precisions(const ov::DiscreteTypeInfo& type) const; /** * @brief checks if emitter for a specific operation is supported * @return true, if supported */ - bool has(const ov::DiscreteTypeInfo type) const { - return jitters.find(type) != jitters.end(); - } + bool has(const ov::DiscreteTypeInfo& type) const; virtual ~TargetMachine() = default; protected: diff --git a/src/common/snippets/src/generator.cpp b/src/common/snippets/src/generator.cpp index fb648398488d25..1d1d733277f99b 100644 --- a/src/common/snippets/src/generator.cpp +++ b/src/common/snippets/src/generator.cpp @@ -34,7 +34,8 @@ Generator::LoweringResult Generator::generate(lowered::LinearIR& linear_ir, cons OV_ITT_TASK_NEXT(GENERATE, "::EmitCode") auto loops2DKernel = std::make_shared(linear_ir); loops2DKernel->compile_params = compile_params; - std::shared_ptr kernel = target->get(op::Kernel::get_type_info_static())(loops2DKernel); + auto loops2DKernelExpr = linear_ir.create_expression(loops2DKernel, std::vector{}); + std::shared_ptr kernel = target->get(op::Kernel::get_type_info_static())(loops2DKernelExpr); kernel->emit_code({}, {}); diff --git a/src/common/snippets/src/lowered/expression.cpp b/src/common/snippets/src/lowered/expression.cpp index 39ea35acb1ddae..cbd50f935dfa5a 100644 --- a/src/common/snippets/src/lowered/expression.cpp +++ b/src/common/snippets/src/lowered/expression.cpp @@ -78,10 +78,6 @@ void Expression::set_reg_info(RegInfo rinfo) { } } -void Expression::init_emitter(const std::shared_ptr& target) { - m_emitter = target->get(m_source_node->get_type_info())(m_source_node); -} - void Expression::validate() const { OPENVINO_ASSERT(m_input_port_descriptors.size() == m_input_port_connectors.size(), "The count of input ports and input port connectors must be equal"); diff --git a/src/common/snippets/src/lowered/linear_ir.cpp b/src/common/snippets/src/lowered/linear_ir.cpp index 6246ddef8838a4..42ac45cac33612 100644 --- a/src/common/snippets/src/lowered/linear_ir.cpp +++ b/src/common/snippets/src/lowered/linear_ir.cpp @@ -152,7 +152,7 @@ void LinearIR::debug_print(bool tds_as_pointers) const { void LinearIR::init_emitters(const std::shared_ptr& target) { for (auto& expr : m_expressions) { if (!expr->get_emitter()) - expr->init_emitter(target); + expr->m_emitter = target->get(expr->get_node()->get_type_info())(expr); } } diff --git a/src/common/snippets/src/lowered/target_machine.cpp b/src/common/snippets/src/lowered/target_machine.cpp new file mode 100644 index 00000000000000..bf84244f1889b9 --- /dev/null +++ b/src/common/snippets/src/lowered/target_machine.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "snippets/target_machine.hpp" + +using namespace ov::snippets; +std::function(const lowered::ExpressionPtr&)> TargetMachine::get(const ov::DiscreteTypeInfo& type) const { + auto jitter = jitters.find(type); + if (jitter == jitters.end()) { + OPENVINO_THROW(std::string("Target code emitter is not available for ") + type.name + " operation."); + } + return jitter->second.first; +} + +std::function(const std::shared_ptr&)> +TargetMachine::get_supported_precisions(const ov::DiscreteTypeInfo& type) const { + auto jitter = jitters.find(type); + if (jitter == jitters.end()) { + OPENVINO_THROW(std::string("Target code emitter is not available for ") + type.name + " operation."); + } + return jitter->second.second; +} + +bool TargetMachine::has(const ov::DiscreteTypeInfo& type) const { + return jitters.find(type) != jitters.end(); +} diff --git a/src/common/snippets/tests/include/lowering_utils.hpp b/src/common/snippets/tests/include/lowering_utils.hpp index 21a2d40b765782..7ca5ecc47439f4 100644 --- a/src/common/snippets/tests/include/lowering_utils.hpp +++ b/src/common/snippets/tests/include/lowering_utils.hpp @@ -15,8 +15,7 @@ using BlockedShapeVector = ov::snippets::op::Subgraph::BlockedShapeVector; class DummyEmitter : public ov::snippets::Emitter { public: - // Here I pass Add to Emitter, but could be any other op, since it's ignored anyway. - DummyEmitter(const std::vector& custom_opset = {}) : ov::snippets::Emitter(std::make_shared()) {} + DummyEmitter(const std::vector& custom_opset = {}) : ov::snippets::Emitter() {} void emit_code(const std::vector&, const std::vector&, const std::vector&, diff --git a/src/common/snippets/tests/src/lowering_utils.cpp b/src/common/snippets/tests/src/lowering_utils.cpp index c24948f8074da5..83207244ac031f 100644 --- a/src/common/snippets/tests/src/lowering_utils.cpp +++ b/src/common/snippets/tests/src/lowering_utils.cpp @@ -6,6 +6,7 @@ #include "lowering_utils.hpp" #include "snippets/pass/tokenization.hpp" #include "snippets/pass/collapse_subgraph.hpp" +#include "snippets/lowered/expression.hpp" namespace ov { @@ -14,7 +15,7 @@ namespace snippets { DummyTargetMachine::DummyTargetMachine(const std::vector&custom_opset) { auto dummy_functor = ov::snippets::jitters_value { - [](const std::shared_ptr& n) { return std::make_shared(); }, + [](const ov::snippets::lowered::ExpressionPtr& n) { return std::make_shared(); }, [](const std::shared_ptr& n) { return std::set>{};} }; diff --git a/src/common/snippets/tests/src/pass/precision_propagation.cpp b/src/common/snippets/tests/src/pass/precision_propagation.cpp index 4a93f804ec84cd..142c5561f7c8c5 100644 --- a/src/common/snippets/tests/src/pass/precision_propagation.cpp +++ b/src/common/snippets/tests/src/pass/precision_propagation.cpp @@ -5,6 +5,8 @@ #include "pass/precision_propagation.hpp" #include + +#include "snippets/lowered/expression.hpp" #include "snippets/pass/propagate_precision.hpp" #include "snippets/op/convert_saturation.hpp" #include "common_test_utils/common_utils.hpp" @@ -23,14 +25,14 @@ class DummyPrecisionPropagationTargetMachine : public DummyTargetMachine { const std::set>& op2_supported_precisions) : DummyTargetMachine() { jitters[DummyAdd::get_type_info_static()] = ov::snippets::jitters_value { - [](const std::shared_ptr& n) { return std::make_shared(); }, + [](const ov::snippets::lowered::ExpressionPtr& n) { return std::make_shared(); }, [op1_supported_precisions](const std::shared_ptr& n) { return op1_supported_precisions; }}; jitters[op::v1::Maximum::get_type_info_static()] = ov::snippets::jitters_value{ - [](const std::shared_ptr& n) { return std::make_shared(); }, + [](const ov::snippets::lowered::ExpressionPtr& n) { return std::make_shared(); }, [op2_supported_precisions](const std::shared_ptr&n) { return op2_supported_precisions; }}; auto default_jitter = ov::snippets::jitters_value{ - [](const std::shared_ptr& n) { return std::make_shared(); }, + [](const ov::snippets::lowered::ExpressionPtr& n) { return std::make_shared(); }, [](const std::shared_ptr& n) { return std::set>{};} }; jitters[ov::snippets::op::ConvertSaturation::get_type_info_static()] = default_jitter; } diff --git a/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp b/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp index 7ed8acdf7703e9..b23e068244512a 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp @@ -27,9 +27,18 @@ using namespace std; -#define CREATE_EMITTER(e_type) { \ - [this](const std::shared_ptr& n) -> std::shared_ptr { \ - return std::make_shared(h.get(), isa, n); \ +#define CREATE_SNIPPETS_EMITTER(e_type) { \ + [this](const ov::snippets::lowered::ExpressionPtr& expr) -> std::shared_ptr { \ + return std::make_shared(h.get(), isa, expr); \ + }, \ + [](const std::shared_ptr& n) -> std::set> { \ + return e_type::get_supported_precisions(n); \ + } \ +}; + +#define CREATE_CPU_EMITTER(e_type) { \ + [this](const ov::snippets::lowered::ExpressionPtr& expr) -> std::shared_ptr { \ + return std::make_shared(h.get(), isa, expr->get_node()); \ }, \ [](const std::shared_ptr& n) -> std::set> { \ return e_type::get_supported_precisions(n); \ @@ -52,101 +61,101 @@ class jit_snippet : public dnnl::impl::cpu::x64::jit_generator { ov::intel_cpu::CPUTargetMachine::CPUTargetMachine(dnnl::impl::cpu::x64::cpu_isa_t host_isa) : TargetMachine(), h(new jit_snippet()), isa(host_isa) { // data movement - jitters[ov::op::v0::Parameter::get_type_info_static()] = CREATE_EMITTER(NopEmitter); - jitters[ov::op::v0::Result::get_type_info_static()] = CREATE_EMITTER(NopEmitter); - jitters[snippets::op::Buffer::get_type_info_static()] = CREATE_EMITTER(NopEmitter); - jitters[snippets::op::VectorBuffer::get_type_info_static()] = CREATE_EMITTER(NopEmitter); - // jitters[ov::op::v1::Constant::get_type_info_static()] = CREATE_EMITTER(); // Not supported - - jitters[snippets::op::Load::get_type_info_static()] = CREATE_EMITTER(LoadEmitter); - jitters[snippets::op::LoadReshape::get_type_info_static()] = CREATE_EMITTER(LoadEmitter); - jitters[snippets::op::BroadcastLoad::get_type_info_static()] = CREATE_EMITTER(BroadcastLoadEmitter); - jitters[ov::intel_cpu::LoadConvertSaturation::get_type_info_static()] = CREATE_EMITTER(LoadConvertEmitter); - jitters[ov::intel_cpu::LoadConvertTruncation::get_type_info_static()] = CREATE_EMITTER(LoadConvertEmitter); - - jitters[snippets::op::Store::get_type_info_static()] = CREATE_EMITTER(StoreEmitter); - jitters[ov::intel_cpu::StoreConvertSaturation::get_type_info_static()] = CREATE_EMITTER(StoreConvertEmitter); - jitters[ov::intel_cpu::StoreConvertTruncation::get_type_info_static()] = CREATE_EMITTER(StoreConvertEmitter); - - jitters[snippets::op::Scalar::get_type_info_static()] = CREATE_EMITTER(ScalarEmitter); - jitters[snippets::op::BroadcastMove::get_type_info_static()] = CREATE_EMITTER(BroadcastMoveEmitter); - // jitters[snippets::op::Nop::get_type_info_static()] = CREATE_EMITTER(NopEmitter); // Not supported - // jitters[ov::op::v1::Broadcast::get_type_info_static()] = CREATE_EMITTER(); // Not supported - - jitters[snippets::op::ConvertTruncation::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_convert_truncation_emitter); - jitters[snippets::op::ConvertSaturation::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_convert_saturation_emitter); - // jitters[ov::op::v1::FakeQuantize::get_type_info_static()] = CREATE_EMITTER(); // not supported + jitters[ov::op::v0::Parameter::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); + jitters[ov::op::v0::Result::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); + jitters[snippets::op::Buffer::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); + jitters[snippets::op::VectorBuffer::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); + // jitters[ov::op::v1::Constant::get_type_info_static()] = CREATE_CPU_EMITTER(); // Not supported + + jitters[snippets::op::Load::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(LoadEmitter); + jitters[snippets::op::LoadReshape::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(LoadEmitter); + jitters[snippets::op::BroadcastLoad::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(BroadcastLoadEmitter); + jitters[ov::intel_cpu::LoadConvertSaturation::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(LoadConvertEmitter); + jitters[ov::intel_cpu::LoadConvertTruncation::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(LoadConvertEmitter); + + jitters[snippets::op::Store::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(StoreEmitter); + jitters[ov::intel_cpu::StoreConvertSaturation::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(StoreConvertEmitter); + jitters[ov::intel_cpu::StoreConvertTruncation::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(StoreConvertEmitter); + + jitters[snippets::op::Scalar::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(ScalarEmitter); + jitters[snippets::op::BroadcastMove::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(BroadcastMoveEmitter); + // jitters[snippets::op::Nop::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); // Not supported + // jitters[ov::op::v1::Broadcast::get_type_info_static()] = CREATE_CPU_EMITTER(); // Not supported + + jitters[snippets::op::ConvertTruncation::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_convert_truncation_emitter); + jitters[snippets::op::ConvertSaturation::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_convert_saturation_emitter); + // jitters[ov::op::v1::FakeQuantize::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported // ternary - jitters[ov::op::v1::Select::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_select_emitter); - jitters[ov::intel_cpu::FusedMulAdd::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_mul_add_emitter); + jitters[ov::op::v1::Select::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_select_emitter); + jitters[ov::intel_cpu::FusedMulAdd::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_mul_add_emitter); // binary - jitters[ov::op::v1::Add::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_add_emitter); - jitters[ov::op::v1::Divide::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_divide_emitter); - jitters[ov::op::v1::Equal::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_equal_emitter); - jitters[ov::op::v1::FloorMod::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_floor_mod_emitter); - jitters[ov::op::v1::Greater::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_greater_emitter); - jitters[ov::op::v1::GreaterEqual::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_greater_equal_emitter); - jitters[ov::op::v1::Less::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_less_emitter); - jitters[ov::op::v1::LessEqual::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_less_equal_emitter); - jitters[ov::op::v1::LogicalAnd::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_logical_and_emitter); - jitters[ov::op::v1::LogicalOr::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_logical_or_emitter); - jitters[ov::op::v1::LogicalXor::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_logical_xor_emitter); - jitters[ov::op::v1::Maximum::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_maximum_emitter); - jitters[ov::op::v1::Minimum::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_minimum_emitter); - jitters[ov::op::v1::Mod::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_mod_emitter); - jitters[ov::op::v1::Multiply::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_multiply_emitter); - jitters[ov::op::v1::NotEqual::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_not_equal_emitter); - jitters[snippets::op::PowerStatic::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_power_static_emitter); - jitters[ov::op::v1::Power::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_power_dynamic_emitter); - jitters[ov::op::v0::PRelu::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_prelu_emitter); - jitters[ov::op::v0::SquaredDifference::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_squared_difference_emitter); - jitters[ov::op::v1::Subtract::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_subtract_emitter); - jitters[ov::op::v0::Xor::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_logical_xor_emitter); + jitters[ov::op::v1::Add::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_add_emitter); + jitters[ov::op::v1::Divide::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_divide_emitter); + jitters[ov::op::v1::Equal::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_equal_emitter); + jitters[ov::op::v1::FloorMod::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_floor_mod_emitter); + jitters[ov::op::v1::Greater::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_greater_emitter); + jitters[ov::op::v1::GreaterEqual::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_greater_equal_emitter); + jitters[ov::op::v1::Less::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_less_emitter); + jitters[ov::op::v1::LessEqual::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_less_equal_emitter); + jitters[ov::op::v1::LogicalAnd::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_logical_and_emitter); + jitters[ov::op::v1::LogicalOr::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_logical_or_emitter); + jitters[ov::op::v1::LogicalXor::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_logical_xor_emitter); + jitters[ov::op::v1::Maximum::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_maximum_emitter); + jitters[ov::op::v1::Minimum::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_minimum_emitter); + jitters[ov::op::v1::Mod::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_mod_emitter); + jitters[ov::op::v1::Multiply::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_multiply_emitter); + jitters[ov::op::v1::NotEqual::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_not_equal_emitter); + jitters[snippets::op::PowerStatic::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_power_static_emitter); + jitters[ov::op::v1::Power::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_power_dynamic_emitter); + jitters[ov::op::v0::PRelu::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_prelu_emitter); + jitters[ov::op::v0::SquaredDifference::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_squared_difference_emitter); + jitters[ov::op::v1::Subtract::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_subtract_emitter); + jitters[ov::op::v0::Xor::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_logical_xor_emitter); // unary - jitters[ov::op::v0::Abs::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_abs_emitter); - // jitters[ov::op::v1::Acos::get_type_info_static()] = CREATE_EMITTER(); // not supported - // jitters[ov::op::v1::Asin::get_type_info_static()] = CREATE_EMITTER(); // not supported - // jitters[ov::op::v1::Atan::get_type_info_static()] = CREATE_EMITTER(); // not supported - jitters[ov::op::v0::Ceiling::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_ceiling_emitter); - jitters[ov::op::v0::Clamp::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_clamp_emitter); - // jitters[ov::op::v1::Cos::get_type_info_static()] = CREATE_EMITTER(); // not supported - // jitters[ov::op::v1::Cosh::get_type_info_static()] = CREATE_EMITTER(); // not supported - jitters[ov::op::v0::Elu::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_elu_emitter); - jitters[ov::op::v0::Erf::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_erf_emitter); - jitters[ov::op::v0::Exp::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_exp_emitter); - jitters[ov::op::v0::Floor::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_floor_emitter); - jitters[ngraph::opset5::Round::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_round_emitter); - // jitters[ov::op::v1::Log::get_type_info_static()] = CREATE_EMITTER(); // not supported - jitters[ov::op::v1::LogicalNot::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_logical_not_emitter); - jitters[ov::op::v0::Negative::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_negative_emitter); - jitters[ov::op::v0::Relu::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_relu_emitter); - // jitters[ov::op::v1::Sign::get_type_info_static()] = CREATE_EMITTER(); // not supported - jitters[ov::op::v0::Sigmoid::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_sigmoid_emitter); - // jitters[ov::op::v1::Sin::get_type_info_static()] = CREATE_EMITTER(); // not supported - // jitters[ov::op::v1::Sinh::get_type_info_static()] = CREATE_EMITTER(); // not supported - jitters[ov::op::v0::Sqrt::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_sqrt_emitter); - // jitters[ov::op::v1::Tan::get_type_info_static()] = CREATE_EMITTER(); // not supported - jitters[ov::op::v0::Tanh::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_tanh_emitter); - - jitters[ov::intel_cpu::SwishNode::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_swish_emitter); - jitters[ngraph::op::v4::HSwish::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_hswish_emitter); - // jitters[ov::op::v1::HardSigmoid::get_type_info_static()] = CREATE_EMITTER(); // not supported - // jitters[ov::op::v1::Selu::get_type_info_static()] = CREATE_EMITTER(); // not supported - jitters[ngraph::op::v0::Gelu::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_gelu_v0_emitter); - jitters[ngraph::op::v7::Gelu::get_type_info_static()] = CREATE_EMITTER(ov::intel_cpu::jit_gelu_v7_emitter); - jitters[snippets::op::Fill::get_type_info_static()] = CREATE_EMITTER(FillEmitter); - - jitters[snippets::op::HorizonMax::get_type_info_static()] = CREATE_EMITTER(HorizonEmitter); - jitters[snippets::op::HorizonSum::get_type_info_static()] = CREATE_EMITTER(HorizonEmitter); - - jitters[snippets::op::Kernel::get_type_info_static()] = CREATE_EMITTER(KernelEmitter); - jitters[snippets::op::LoopBegin::get_type_info_static()] = CREATE_EMITTER(LoopBeginEmitter); - jitters[snippets::op::LoopEnd::get_type_info_static()] = CREATE_EMITTER(LoopEndEmitter); - jitters[ov::intel_cpu::BrgemmCPU::get_type_info_static()] = CREATE_EMITTER(BrgemmEmitter); - jitters[ov::intel_cpu::BrgemmCopyB::get_type_info_static()] = CREATE_EMITTER(BrgemmCopyBEmitter); + jitters[ov::op::v0::Abs::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_abs_emitter); + // jitters[ov::op::v1::Acos::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + // jitters[ov::op::v1::Asin::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + // jitters[ov::op::v1::Atan::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + jitters[ov::op::v0::Ceiling::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_ceiling_emitter); + jitters[ov::op::v0::Clamp::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_clamp_emitter); + // jitters[ov::op::v1::Cos::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + // jitters[ov::op::v1::Cosh::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + jitters[ov::op::v0::Elu::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_elu_emitter); + jitters[ov::op::v0::Erf::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_erf_emitter); + jitters[ov::op::v0::Exp::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_exp_emitter); + jitters[ov::op::v0::Floor::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_floor_emitter); + jitters[ngraph::opset5::Round::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_round_emitter); + // jitters[ov::op::v1::Log::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + jitters[ov::op::v1::LogicalNot::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_logical_not_emitter); + jitters[ov::op::v0::Negative::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_negative_emitter); + jitters[ov::op::v0::Relu::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_relu_emitter); + // jitters[ov::op::v1::Sign::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + jitters[ov::op::v0::Sigmoid::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_sigmoid_emitter); + // jitters[ov::op::v1::Sin::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + // jitters[ov::op::v1::Sinh::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + jitters[ov::op::v0::Sqrt::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_sqrt_emitter); + // jitters[ov::op::v1::Tan::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + jitters[ov::op::v0::Tanh::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_tanh_emitter); + + jitters[ov::intel_cpu::SwishNode::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_swish_emitter); + jitters[ngraph::op::v4::HSwish::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_hswish_emitter); + // jitters[ov::op::v1::HardSigmoid::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + // jitters[ov::op::v1::Selu::get_type_info_static()] = CREATE_CPU_EMITTER(); // not supported + jitters[ngraph::op::v0::Gelu::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_gelu_v0_emitter); + jitters[ngraph::op::v7::Gelu::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_gelu_v7_emitter); + jitters[snippets::op::Fill::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(FillEmitter); + + jitters[snippets::op::HorizonMax::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(HorizonEmitter); + jitters[snippets::op::HorizonSum::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(HorizonEmitter); + + jitters[snippets::op::Kernel::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(KernelEmitter); + jitters[snippets::op::LoopBegin::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(LoopBeginEmitter); + jitters[snippets::op::LoopEnd::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(LoopEndEmitter); + jitters[ov::intel_cpu::BrgemmCPU::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(BrgemmEmitter); + jitters[ov::intel_cpu::BrgemmCopyB::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(BrgemmCopyBEmitter); } size_t ov::intel_cpu::CPUTargetMachine::get_lanes() const { diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_conversion_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_conversion_emitters.cpp index c49fbab5b32f9a..046c43284e74b9 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_conversion_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_conversion_emitters.cpp @@ -18,7 +18,7 @@ namespace ov { namespace intel_cpu { jit_convert_emitter::jit_convert_emitter(jit_generator *host, cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { input_type = node->get_input_element_type(0); output_type = node->get_output_element_type(0); diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_dnnl_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_dnnl_emitters.cpp index 416218b92a3bb6..2df36538729c44 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_dnnl_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_dnnl_emitters.cpp @@ -18,7 +18,7 @@ std::set> jit_dnnl_emitter::get_supported_precisions( } jit_dnnl_emitter::jit_dnnl_emitter(jit_generator *host, cpu_isa_t host_isa, const std::shared_ptr& node, InferenceEngine::Precision exec_prc) - : jit_emitter(host, host_isa, node, exec_prc) { + : jit_emitter(host, host_isa, exec_prc) { kind = dnnl_eltwise_tanh; alpha = 0.f; diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp index 0ba374b68b93be..d6ccd2de563227 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp @@ -36,7 +36,7 @@ InferenceEngine::Precision get_arithmetic_binary_exec_precision(const std::share /// ADD /// jit_add_emitter::jit_add_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node) -: jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) {} +: jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) {} jit_add_emitter::jit_add_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -83,7 +83,7 @@ std::set> jit_add_emitter::get_supported_precisions(c /// MUL_ADD /// jit_mul_add_emitter::jit_mul_add_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node) -: jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) {} +: jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) {} jit_mul_add_emitter::jit_mul_add_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -174,7 +174,7 @@ std::set> jit_mul_add_emitter::get_supported_precisio /// SUB /// jit_subtract_emitter::jit_subtract_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node) -: jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) {} +: jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) {} jit_subtract_emitter::jit_subtract_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -221,7 +221,7 @@ std::set> jit_subtract_emitter::get_supported_precisi /// MULTIPLY /// jit_multiply_emitter::jit_multiply_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node) -: jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) {} +: jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) {} jit_multiply_emitter::jit_multiply_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -268,7 +268,7 @@ std::set> jit_multiply_emitter::get_supported_precisi /// DIVIDE /// jit_divide_emitter::jit_divide_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) {} +: jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) {} jit_divide_emitter::jit_divide_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -333,7 +333,7 @@ size_t jit_divide_emitter::aux_vecs_count() const { /// FLOOR /// jit_floor_emitter::jit_floor_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) {} +: jit_emitter(host, host_isa, exec_prc) {} jit_floor_emitter::jit_floor_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -365,7 +365,7 @@ void jit_floor_emitter::emit_isa(const std::vector &in_vec_idxs, const s /// CEILING /// jit_ceiling_emitter::jit_ceiling_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) {} +: jit_emitter(host, host_isa, exec_prc) {} jit_ceiling_emitter::jit_ceiling_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -398,7 +398,7 @@ void jit_ceiling_emitter::emit_isa(const std::vector &in_vec_idxs, const /// FLOOR_MOD /// jit_floor_mod_emitter::jit_floor_mod_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) {} +: jit_emitter(host, host_isa, exec_prc) {} jit_floor_mod_emitter::jit_floor_mod_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -452,7 +452,7 @@ size_t jit_floor_mod_emitter::aux_vecs_count() const { /// MOD /// jit_mod_emitter::jit_mod_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) {} +: jit_emitter(host, host_isa, exec_prc) {} jit_mod_emitter::jit_mod_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -506,7 +506,7 @@ size_t jit_mod_emitter::aux_vecs_count() const { /// MAXIMUM /// jit_maximum_emitter::jit_maximum_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node) -: jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) {} +: jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) {} jit_maximum_emitter::jit_maximum_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -554,7 +554,7 @@ std::set> jit_maximum_emitter::get_supported_precisio /// MINIMUM /// jit_minimum_emitter::jit_minimum_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node) -: jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) {} +: jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) {} jit_minimum_emitter::jit_minimum_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -603,7 +603,7 @@ std::set> jit_minimum_emitter::get_supported_precisio /// SQUARED_DIFFERENCE /// jit_squared_difference_emitter::jit_squared_difference_emitter( x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) {} +: jit_emitter(host, host_isa, exec_prc) {} jit_squared_difference_emitter::jit_squared_difference_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -658,7 +658,7 @@ std::set> jit_squared_difference_emitter::get_support /// POWER_DYNAMIC /// jit_power_dynamic_emitter::jit_power_dynamic_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) - : jit_emitter(host, host_isa, node, exec_prc) {} + : jit_emitter(host, host_isa, exec_prc) {} jit_power_dynamic_emitter::jit_power_dynamic_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -769,7 +769,7 @@ void jit_power_dynamic_emitter::emit_isa(const std::vector &in_vec_idxs, /// EQUAL /// jit_equal_emitter::jit_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_equal_emitter::jit_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -832,7 +832,7 @@ size_t jit_equal_emitter::aux_vecs_count() const { /// NOT_EQUAL /// jit_not_equal_emitter::jit_not_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_not_equal_emitter::jit_not_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -895,7 +895,7 @@ size_t jit_not_equal_emitter::aux_vecs_count() const { /// GREATER /// jit_greater_emitter::jit_greater_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_greater_emitter::jit_greater_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -959,7 +959,7 @@ size_t jit_greater_emitter::aux_vecs_count() const { /// GREATER_EQUAL /// jit_greater_equal_emitter::jit_greater_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_greater_equal_emitter::jit_greater_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1022,7 +1022,7 @@ size_t jit_greater_equal_emitter::aux_vecs_count() const { /// LESS /// jit_less_emitter::jit_less_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_less_emitter::jit_less_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1085,7 +1085,7 @@ size_t jit_less_emitter::aux_vecs_count() const { /// LESS_EQUAL /// jit_less_equal_emitter::jit_less_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_less_equal_emitter::jit_less_equal_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1149,7 +1149,7 @@ size_t jit_less_equal_emitter::aux_vecs_count() const { /// LOGICAL_AND /// jit_logical_and_emitter::jit_logical_and_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_logical_and_emitter::jit_logical_and_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1233,7 +1233,7 @@ size_t jit_logical_and_emitter::aux_vecs_count() const { /// LOGICAL_OR /// jit_logical_or_emitter::jit_logical_or_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_logical_or_emitter::jit_logical_or_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1316,7 +1316,7 @@ size_t jit_logical_or_emitter::aux_vecs_count() const { /// LOGICAL_XOR /// jit_logical_xor_emitter::jit_logical_xor_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_logical_xor_emitter::jit_logical_xor_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1399,7 +1399,7 @@ size_t jit_logical_xor_emitter::aux_vecs_count() const { /// LOGICAL_NOT /// jit_logical_not_emitter::jit_logical_not_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_logical_not_emitter::jit_logical_not_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1461,7 +1461,7 @@ size_t jit_logical_not_emitter::aux_vecs_count() const { /// POWER_STATIC /// jit_power_static_emitter::jit_power_static_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { auto powerStaticNode = ov::as_type_ptr(node); if (powerStaticNode == nullptr) { IE_THROW() << "Can't cast to snippets::op::PowerStatic"; @@ -1652,7 +1652,7 @@ size_t jit_power_static_emitter::aux_vecs_count() const { /// PRELU /// jit_prelu_emitter::jit_prelu_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_prelu_emitter::jit_prelu_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -1714,7 +1714,7 @@ size_t jit_prelu_emitter::aux_vecs_count() const { /// SQRT /// jit_sqrt_emitter::jit_sqrt_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) {} +: jit_emitter(host, host_isa, exec_prc) {} jit_sqrt_emitter::jit_sqrt_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} @@ -1747,7 +1747,7 @@ void jit_sqrt_emitter::emit_isa(const std::vector &in_vec_idxs, const st /// Negate /// jit_negative_emitter::jit_negative_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) {} +: jit_emitter(host, host_isa, exec_prc) {} size_t jit_negative_emitter::get_inputs_num() const { return 1; } @@ -1783,7 +1783,7 @@ jit_erf_emitter::jit_erf_emitter(x64::jit_generator *host, x64::cpu_isa_t host_i } jit_erf_emitter::jit_erf_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } @@ -1963,7 +1963,7 @@ size_t jit_erf_emitter::aux_vecs_count() const { /// SOFT SIGN /// jit_soft_sign_emitter::jit_soft_sign_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) -: jit_emitter(host, host_isa, node, exec_prc) { +: jit_emitter(host, host_isa, exec_prc) { prepare_table(); } jit_soft_sign_emitter::jit_soft_sign_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) @@ -2182,7 +2182,7 @@ void jit_is_nan_emitter::register_table_entries() { /// SELECT /// jit_select_emitter::jit_select_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) - : jit_emitter(host, host_isa, node, exec_prc) {} + : jit_emitter(host, host_isa, exec_prc) {} jit_select_emitter::jit_select_emitter(x64::jit_generator *host, x64::cpu_isa_t host_isa, Precision exec_prc) : jit_emitter(host, host_isa, exec_prc) {} diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp index 5c00e4584b4274..e624b0f95294c0 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp @@ -574,7 +574,7 @@ class jit_is_finite_emitter : public jit_emitter { prepare_table(); } jit_is_finite_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t hostIsa, const std::shared_ptr& node, - InferenceEngine::Precision execPrc = InferenceEngine::Precision::FP32) : jit_emitter(host, hostIsa, node, execPrc) { + InferenceEngine::Precision execPrc = InferenceEngine::Precision::FP32) : jit_emitter(host, hostIsa, execPrc) { prepare_table(); } @@ -602,7 +602,7 @@ class jit_is_inf_emitter : public jit_emitter { prepare_table(); } jit_is_inf_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t hostIsa, const std::shared_ptr& node, - InferenceEngine::Precision execPrc = InferenceEngine::Precision::FP32): jit_emitter(host, hostIsa, node, execPrc) { + InferenceEngine::Precision execPrc = InferenceEngine::Precision::FP32): jit_emitter(host, hostIsa, execPrc) { prepare_table(); } @@ -632,7 +632,7 @@ class jit_is_nan_emitter : public jit_emitter { prepare_table(); } jit_is_nan_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t hostIsa, const std::shared_ptr& node, - InferenceEngine::Precision execPrc = InferenceEngine::Precision::FP32) : jit_emitter(host, hostIsa, node, execPrc) { + InferenceEngine::Precision execPrc = InferenceEngine::Precision::FP32) : jit_emitter(host, hostIsa, execPrc) { prepare_table(); } diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp index d2e3a33b914406..e7a74f2c065a30 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp @@ -32,13 +32,7 @@ class jit_emitter : public ov::snippets::Emitter { public: jit_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32, emitter_in_out_map in_out_type = emitter_in_out_map::vec_to_vec) - : Emitter(nullptr), h(host), host_isa_(host_isa), exec_prc_(exec_prc), l_table (new Xbyak::Label()), in_out_type_(in_out_type) { - k_mask = Xbyak::Opmask(1); // FIXME: in general case we need preserve k_mask state as well - } - - jit_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, const std::shared_ptr& n, - InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32, emitter_in_out_map in_out_type = emitter_in_out_map::vec_to_vec) - : Emitter(n), h(host), host_isa_(host_isa), exec_prc_(exec_prc), l_table (new Xbyak::Label()), in_out_type_(in_out_type) { + : Emitter(), h(host), host_isa_(host_isa), exec_prc_(exec_prc), l_table (new Xbyak::Label()), in_out_type_(in_out_type) { k_mask = Xbyak::Opmask(1); // FIXME: in general case we need preserve k_mask state as well } diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp index 474d689107745a..7eeb701cbfaab1 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp @@ -20,6 +20,10 @@ using namespace dnnl::impl::cpu::x64; namespace ov { namespace intel_cpu { +using jit_generator = dnnl::impl::cpu::x64::jit_generator; +using cpu_isa_t = dnnl::impl::cpu::x64::cpu_isa_t; +using ExpressionPtr = ov::snippets::lowered::ExpressionPtr; + namespace { constexpr size_t gpr_size = 8; } // namespace @@ -29,8 +33,8 @@ inline static void transform_idxs_to_regs(const std::vector& idxs, std:: std::transform(idxs.begin(), idxs.end(), regs.begin(), [](size_t idx){return Reg64(static_cast(idx));}); } -jit_container_emitter::jit_container_emitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : jit_emitter(h, isa, n) { +jit_container_emitter::jit_container_emitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : jit_emitter(h, isa) { in_out_type_ = emitter_in_out_map::gpr_to_gpr; } @@ -92,12 +96,11 @@ void jit_container_emitter::map_abstract_registers(mapping_info& gpr_map_pool, } } -KernelEmitter::KernelEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : - jit_container_emitter(h, isa, n), - reg_indexes_idx(abi_param1.getIdx()), - reg_const_params_idx(abi_param2.getIdx()) { - const auto kernel = ov::as_type_ptr(n); +KernelEmitter::KernelEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : jit_container_emitter(h, isa, expr), + reg_indexes_idx(abi_param1.getIdx()), + reg_const_params_idx(abi_param2.getIdx()) { + const auto kernel = ov::as_type_ptr(expr->get_node()); if (!kernel) IE_THROW() << "KernelEmitter invoked with invalid op argument"; if (kernel->region.empty()) @@ -312,10 +315,8 @@ void KernelEmitter::emit_impl(const std::vector& in, h->postamble(); } - -LoopBeginEmitter::LoopBeginEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : jit_emitter(h, isa, n) { - loop_begin = ov::as_type_ptr(n); +LoopBeginEmitter::LoopBeginEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : jit_emitter(h, isa) { + loop_begin = ov::as_type_ptr(expr->get_node()); if (!loop_begin) IE_THROW() << "LoopBeginEmitter invoked with invalid op argument"; const auto& target_inputs = loop_begin->output(loop_begin->get_output_size() - 1).get_target_inputs(); @@ -359,9 +360,8 @@ void LoopBeginEmitter::emit_impl(const std::vector& in, loop_begin->begin_address = h->getCurr(); } -LoopEndEmitter::LoopEndEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : jit_emitter(h, isa, n) { - loop_end = ov::as_type_ptr(n); +LoopEndEmitter::LoopEndEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : jit_emitter(h, isa) { + loop_end = ov::as_type_ptr(expr->get_node()); if (!loop_end) IE_THROW() << "LoopEndEmitter invoked with invalid op argument"; loop_begin = loop_end->get_loop_begin(); @@ -388,7 +388,7 @@ void LoopEndEmitter::emit_code(const std::vector &in, void LoopEndEmitter::validate_arguments(const std::vector &in, - const std::vector &out) const { + const std::vector &out) const { if (out.size() != num_outputs) IE_THROW() << "Invalid number of out arguments: expected " << num_outputs << " got " << out.size(); if (in.size() != num_inputs) @@ -425,18 +425,22 @@ void LoopEndEmitter::emit_impl(const std::vector& in, } } -ParameterEmitter::ParameterEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : NopEmitter(h, isa, n) { +NopEmitter::NopEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : jit_emitter(h, isa) { + in_out_type_ = emitter_in_out_map::gpr_to_gpr; +} + +ParameterEmitter::ParameterEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : NopEmitter(h, isa, expr) { in_out_type_ = emitter_in_out_map::gpr_to_gpr; } -ResultEmitter::ResultEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : NopEmitter(h, isa, n) { +ResultEmitter::ResultEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : NopEmitter(h, isa, expr) { in_out_type_ = emitter_in_out_map::gpr_to_gpr; } -BroadcastMoveEmitter::BroadcastMoveEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : jit_emitter(h, isa, n) { +BroadcastMoveEmitter::BroadcastMoveEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : jit_emitter(h, isa) { + const auto n = expr->get_node(); if (n->get_input_element_type(0) != n->get_output_element_type(0)) IE_THROW() << "BroadcastMoveEmitter supports only equal input and output types but gets: " << n->get_input_element_type(0) << " and " << n->get_output_element_type(0); @@ -456,7 +460,7 @@ void BroadcastMoveEmitter::emit_impl(const std::vector& in, } } -template +template void BroadcastMoveEmitter::emit_isa(const std::vector &in, const std::vector &out) const { using Vmm = typename dnnl::impl::utils::conditional3::type; @@ -471,9 +475,9 @@ void BroadcastMoveEmitter::emit_isa(const std::vector &in, const std::ve } } -ScalarEmitter::ScalarEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : jit_emitter(h, isa, n) { - const auto precision = n->get_output_element_type(0); +ScalarEmitter::ScalarEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : jit_emitter(h, isa) { + const auto n = expr->get_node(); + const auto& precision = n->get_output_element_type(0); switch (precision) { case element::i32: { value = ov::as_type_ptr(n)->cast_vector()[0]; @@ -504,7 +508,7 @@ void ScalarEmitter::emit_impl(const std::vector& in, } } -template +template void ScalarEmitter::emit_isa(const std::vector &in, const std::vector &out) const { using Vmm = typename dnnl::impl::utils::conditional3::type; @@ -512,19 +516,17 @@ void ScalarEmitter::emit_isa(const std::vector &in, const std::vectoruni_vbroadcastss(vmm_dst, table_val("scalar")); } - -MemoryEmitter::MemoryEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : jit_emitter(h, isa, n) { +MemoryEmitter::MemoryEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : jit_emitter(h, isa) { + const auto n = expr->get_node(); src_prc = InferenceEngine::details::convertPrecision(n->get_input_element_type(0)); dst_prc = InferenceEngine::details::convertPrecision(n->get_output_element_type(0)); } -StoreEmitter::StoreEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : MemoryEmitter(h, isa, n) { +StoreEmitter::StoreEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : MemoryEmitter(h, isa, expr) { if (src_prc != dst_prc) IE_THROW() << "StoreEmitter supports only equal input and output types but gets: " << src_prc.name() << " and " << dst_prc.name(); - const auto store = ov::as_type_ptr(n); + const auto store = ov::as_type_ptr(expr->get_node()); count = store->get_count(); byte_offset = store->get_offset(); in_out_type_ = emitter_in_out_map::vec_to_gpr; @@ -544,7 +546,7 @@ void StoreEmitter::emit_impl(const std::vector& in, } } -template +template void StoreEmitter::emit_isa(const std::vector &in, const std::vector &out) const { if (!store_emitter) IE_THROW() << "Store CPU emitter isn't initialized for StoreEmitter!"; @@ -555,12 +557,11 @@ void StoreEmitter::emit_data() const { store_emitter->emit_data(); } -LoadEmitter::LoadEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : MemoryEmitter(h, isa, n) { +LoadEmitter::LoadEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : MemoryEmitter(h, isa, expr) { if (src_prc != dst_prc) IE_THROW() << "LoadEmitter supports only equal input and output types but gets: " << src_prc.name() << " and " << dst_prc.name(); - const auto load = std::dynamic_pointer_cast(n); + const auto load = std::dynamic_pointer_cast(expr->get_node()); count = load->get_count(); byte_offset = load->get_offset(); in_out_type_ = emitter_in_out_map::gpr_to_vec; @@ -580,7 +581,7 @@ void LoadEmitter::emit_impl(const std::vector& in, } } -template +template void LoadEmitter::emit_isa(const std::vector &in, const std::vector &out) const { if (!load_emitter) IE_THROW() << "Load CPU emitter isn't initialized for LoadEmitter!"; @@ -591,12 +592,12 @@ void LoadEmitter::emit_data() const { load_emitter->emit_data(); } -BroadcastLoadEmitter::BroadcastLoadEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : MemoryEmitter(h, isa, n) { +BroadcastLoadEmitter::BroadcastLoadEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : MemoryEmitter(h, isa, expr) { if (src_prc != dst_prc) IE_THROW() << "BroadcastEmitters support only equal input and output types but gets: " << src_prc.name() << " and " << dst_prc.name(); - const auto broadcast_load = std::dynamic_pointer_cast(n); + const auto broadcast_load = std::dynamic_pointer_cast(expr->get_node()); byte_offset = broadcast_load->get_offset(); in_out_type_ = emitter_in_out_map::gpr_to_vec; } @@ -614,7 +615,7 @@ void BroadcastLoadEmitter::emit_impl(const std::vector& in, } } -template +template void BroadcastLoadEmitter::emit_isa(const std::vector &in, const std::vector &out) const { using Vmm = typename dnnl::impl::utils::conditional3::type; @@ -631,9 +632,9 @@ void BroadcastLoadEmitter::emit_isa(const std::vector &in, const std::ve } } -LoadConvertEmitter::LoadConvertEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n) - : MemoryEmitter(h, isa, n) { - const auto load = ov::as_type_ptr(n); +LoadConvertEmitter::LoadConvertEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : MemoryEmitter(h, isa, expr) { + const auto load = ov::as_type_ptr(expr->get_node()); count = load->get_count(); byte_offset = load->get_offset(); in_out_type_ = emitter_in_out_map::gpr_to_vec; @@ -653,7 +654,7 @@ void LoadConvertEmitter::emit_impl(const std::vector& in, } } -template +template void LoadConvertEmitter::emit_isa(const std::vector &in, const std::vector &out) const { if (!load_emitter) IE_THROW() << "Load CPU emitter isn't initialized for LoadEmitter!"; @@ -664,16 +665,16 @@ void LoadConvertEmitter::emit_data() const { load_emitter->emit_data(); } -StoreConvertEmitter::StoreConvertEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n) : MemoryEmitter(h, isa, n) { - const auto store = ov::as_type_ptr(n); +StoreConvertEmitter::StoreConvertEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : MemoryEmitter(h, isa, expr) { + const auto store = ov::as_type_ptr(expr->get_node()); count = store->get_count(); byte_offset = store->get_offset(); in_out_type_ = emitter_in_out_map::vec_to_gpr; - if (ov::is_type(n)) { + if (ov::is_type(expr->get_node())) { store_emitter.reset(new jit_store_emitter(h, isa, src_prc, dst_prc, count, arithmetic_mode::truncation)); - } else if (ov::is_type(n)) { + } else if (ov::is_type(expr->get_node())) { store_emitter.reset(new jit_store_emitter(h, isa, src_prc, dst_prc, count, arithmetic_mode::saturation)); } } @@ -691,7 +692,7 @@ void StoreConvertEmitter::emit_impl(const std::vector& in, } } -template +template void StoreConvertEmitter::emit_isa(const std::vector &in, const std::vector &out) const { if (!store_emitter) IE_THROW() << "Store CPU emitter isn't initialized for StoreEmitter!"; @@ -704,12 +705,12 @@ void StoreConvertEmitter::emit_data() const { size_t BrgemmEmitter::getBrgIdx(size_t kIdx, size_t nIdx) { return kIdx * BRGEMM_N_KERNEL_NUM + nIdx; } -BrgemmEmitter::BrgemmEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& node) : jit_emitter(h, isa, node) { + +BrgemmEmitter::BrgemmEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : jit_emitter(h, isa) { m_brgCtxs.fill(brgemmCtx()); std::generate(m_brgKernels.begin(), m_brgKernels.end(), [](){ return nullptr; }); in_out_type_ = emitter_in_out_map::gpr_to_gpr; - const auto& brgemm_node = as_type_ptr(node); + const auto& brgemm_node = as_type_ptr(expr->get_node()); if (brgemm_node->is_dynamic()) IE_THROW() << "Snippets don't support code generation for dynamic Brgemm"; const auto brgemm_copy = brgemm_node->is_with_data_repacking() ? brgemm_node->get_brgemm_copy() : nullptr; @@ -1190,10 +1191,10 @@ void BrgemmEmitter::kernel_execute(const brgemm_kernel_t *brg_kernel, (*brg_kernel)(&brgemm_p); } -BrgemmCopyBEmitter::BrgemmCopyBEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n) - : jit_emitter(h, isa, n) { +BrgemmCopyBEmitter::BrgemmCopyBEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : jit_emitter(h, isa) { in_out_type_ = emitter_in_out_map::gpr_to_gpr; - const auto brgemm_repack = ov::as_type_ptr(n); + const auto brgemm_repack = ov::as_type_ptr(expr->get_node()); if (!brgemm_repack) IE_THROW() << "BrgemmCopyBEmitters expects BrgemmCopyB node"; @@ -1442,11 +1443,11 @@ void BrgemmCopyBEmitter::execute(matmul::jit_brgemm_matmul_copy_b_t *kernel, con (*kernel)(&ctx); } -HorizonEmitter::HorizonEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n) : - jit_emitter(h, isa, n, Precision::FP32, emitter_in_out_map::vec_to_vec) { - if (ov::is_type(n)) { +HorizonEmitter::HorizonEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : jit_emitter(h, isa, Precision::FP32, emitter_in_out_map::vec_to_vec) { + if (ov::is_type(expr->get_node())) { m_op_type = OpType::max; - } else if (ov::is_type(n)) { + } else if (ov::is_type(expr->get_node())) { m_op_type = OpType::sum; } else { OPENVINO_THROW("HorizonEmitter exprects HorizonMax or HorizonSum ops"); @@ -1466,7 +1467,7 @@ void HorizonEmitter::emit_impl(const std::vector& in, } } -template +template void HorizonEmitter::emit_isa(const std::vector &in, const std::vector &out) const { using Vmm = typename dnnl::impl::utils::conditional3::type; @@ -1510,9 +1511,9 @@ void HorizonEmitter::perform_op(const Vmm &vmm1, const Vmm &vmm2, const Vmm &vmm } } -FillEmitter::FillEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n) : - jit_emitter(h, isa, n, Precision::FP32, emitter_in_out_map::vec_to_vec) { - const auto fill = ov::as_type_ptr(n); +FillEmitter::FillEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) + : jit_emitter(h, isa, Precision::FP32, emitter_in_out_map::vec_to_vec) { + const auto fill = ov::as_type_ptr(expr->get_node()); if (fill->get_element_type().size() != 4) { IE_THROW() << "Fill emitter supports only 4 Byte element types but gets: " << fill->get_element_type(); } @@ -1548,7 +1549,7 @@ void FillEmitter::emit_impl(const std::vector& in, } } -template +template void FillEmitter::emit_isa(const std::vector &in, const std::vector &out) const { using Vmm = typename dnnl::impl::utils::conditional3::type; @@ -1593,5 +1594,5 @@ void FillEmitter::fill_tail(const Vmm& src_vmm, const Vmm& dst_vmm) const { } } -} // namespace intel_cpu -} // namespace ov +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp index 00c35c17dc7814..d7d8922612c47b 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp @@ -8,6 +8,7 @@ #include #include "snippets/lowered/linear_ir.hpp" +#include "snippets/lowered/expression.hpp" #include "jit_emitter.hpp" #include "jit_load_store_emitters.hpp" @@ -44,8 +45,9 @@ struct jit_snippets_compile_args { /// class jit_container_emitter: public jit_emitter { public: - jit_container_emitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n); + jit_container_emitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); // mapping info contains abstract_to_physical map + regs_pool using mapping_info = std::pair, std::vector&>; protected: @@ -74,8 +76,9 @@ class jit_container_emitter: public jit_emitter { class KernelEmitter : public jit_container_emitter { public: - KernelEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n); + KernelEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 0;} void emit_code(const std::vector &in, @@ -111,7 +114,9 @@ class KernelEmitter : public jit_container_emitter { class LoopBeginEmitter : public jit_emitter { public: - LoopBeginEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + LoopBeginEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); void emit_code(const std::vector &in, const std::vector &out) const; // todo: it is purely virtual in the base class, but do we need it? @@ -131,7 +136,9 @@ class LoopBeginEmitter : public jit_emitter { class LoopEndEmitter : public jit_emitter { public: - LoopEndEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + LoopEndEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); void emit_code(const std::vector &in, const std::vector &out) const; // todo: it is purely virtual in the base class, but do we need it? @@ -161,10 +168,9 @@ class LoopEndEmitter : public jit_emitter { class NopEmitter : public jit_emitter { public: - NopEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n) - : jit_emitter(h, isa, n) { - in_out_type_ = emitter_in_out_map::gpr_to_gpr; - } + NopEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 0;} @@ -176,21 +182,26 @@ class NopEmitter : public jit_emitter { class ParameterEmitter : public NopEmitter { public: - ParameterEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, - const std::shared_ptr& n); + ParameterEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override { return 0; } }; class ResultEmitter : public NopEmitter { public: - ResultEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + ResultEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 1;} }; class BroadcastMoveEmitter : public jit_emitter { public: - BroadcastMoveEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + BroadcastMoveEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 1;} @@ -207,7 +218,9 @@ class BroadcastMoveEmitter : public jit_emitter { class ScalarEmitter : public jit_emitter { public: - ScalarEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + ScalarEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 0;} @@ -236,7 +249,9 @@ class ScalarEmitter : public jit_emitter { /// Blocked parameter to tell if input is actually blocked. Broadcast means broadcast by W in other cases no need to substitute load. class MemoryEmitter : public jit_emitter { public: - MemoryEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + MemoryEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); protected: InferenceEngine::Precision src_prc; @@ -248,7 +263,9 @@ class MemoryEmitter : public jit_emitter { class StoreEmitter : public MemoryEmitter { public: - StoreEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + StoreEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 1;} @@ -266,7 +283,9 @@ class StoreEmitter : public MemoryEmitter { class LoadEmitter : public MemoryEmitter { public: - LoadEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + LoadEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 0;} @@ -284,7 +303,9 @@ class LoadEmitter : public MemoryEmitter { class BroadcastLoadEmitter : public MemoryEmitter { public: - BroadcastLoadEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + BroadcastLoadEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 0;} @@ -298,7 +319,9 @@ class BroadcastLoadEmitter : public MemoryEmitter { class LoadConvertEmitter : public MemoryEmitter { public: - LoadConvertEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + LoadConvertEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 0;} @@ -316,7 +339,9 @@ class LoadConvertEmitter : public MemoryEmitter { class StoreConvertEmitter : public MemoryEmitter { public: - StoreConvertEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + StoreConvertEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 1;} @@ -334,7 +359,9 @@ class StoreConvertEmitter : public MemoryEmitter { class BrgemmEmitter : public jit_emitter { public: - BrgemmEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + BrgemmEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override { return m_with_scratch ? 3 : 2; } static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr); @@ -395,7 +422,9 @@ class BrgemmEmitter : public jit_emitter { class BrgemmCopyBEmitter : public jit_emitter { public: - BrgemmCopyBEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + BrgemmCopyBEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 1;} static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr) { @@ -432,7 +461,9 @@ class BrgemmCopyBEmitter : public jit_emitter { class HorizonEmitter : public jit_emitter { public: - HorizonEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + HorizonEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 1;} static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr) { @@ -457,7 +488,9 @@ class HorizonEmitter : public jit_emitter { }; class FillEmitter : public jit_emitter { public: - FillEmitter(dnnl::impl::cpu::x64::jit_generator* h, dnnl::impl::cpu::x64::cpu_isa_t isa, const std::shared_ptr& n); + FillEmitter(dnnl::impl::cpu::x64::jit_generator* h, + dnnl::impl::cpu::x64::cpu_isa_t isa, + const ov::snippets::lowered::ExpressionPtr& expr); size_t get_inputs_num() const override {return 1;} From d9952b24553ed44160309b4f87ab9bb3c07a5f12 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 6 Sep 2023 18:37:12 +0400 Subject: [PATCH 21/31] Enabled clang format for unit test utils (#19653) --- .../test_utils/unit_test_utils/CMakeLists.txt | 2 +- src/tests/test_utils/unit_test_utils/mock.cpp | 25 ++++---- .../impl/mock_async_infer_request_default.hpp | 12 ++-- .../mock_executable_thread_safe_default.hpp | 13 +++-- .../impl/mock_inference_plugin_internal.hpp | 24 ++++---- .../mock_iexecutable_network_internal.hpp | 17 +++--- .../mock_iinfer_request_internal.hpp | 7 +-- .../interface/mock_iinference_plugin.hpp | 57 ++++++++++++------- .../mock_ivariable_state_internal.hpp | 3 +- .../cpp_interfaces/mock_task_executor.hpp | 4 +- .../mocks/mock_engine/dllmain.cpp | 7 +-- .../mocks/mock_icnn_network.hpp | 52 ++++++++++------- .../mocks/mock_iexecutable_network.hpp | 33 ++++++----- .../mocks/mock_iinfer_request.hpp | 9 +-- .../mocks/mock_not_empty_icnn_network.hpp | 31 +++++----- .../runtime/mock_isync_infer_request.hpp | 1 - 16 files changed, 164 insertions(+), 133 deletions(-) diff --git a/src/tests/test_utils/unit_test_utils/CMakeLists.txt b/src/tests/test_utils/unit_test_utils/CMakeLists.txt index 158d57c393f5cc..4bdae74e806dc1 100644 --- a/src/tests/test_utils/unit_test_utils/CMakeLists.txt +++ b/src/tests/test_utils/unit_test_utils/CMakeLists.txt @@ -14,7 +14,7 @@ addIeTarget( NAME ${TARGET_NAME} TYPE STATIC ROOT ${CMAKE_CURRENT_SOURCE_DIR} - ADD_CPPLINT + ADD_CLANG_FORMAT DEVELOPER_PACKAGE tests LINK_LIBRARIES diff --git a/src/tests/test_utils/unit_test_utils/mock.cpp b/src/tests/test_utils/unit_test_utils/mock.cpp index bd117b9e751384..7f5221c69804a7 100644 --- a/src/tests/test_utils/unit_test_utils/mock.cpp +++ b/src/tests/test_utils/unit_test_utils/mock.cpp @@ -3,22 +3,19 @@ // #include "openvino/op/relu.hpp" -#include "unit_test_utils/mocks/mock_allocator.hpp" -#include "unit_test_utils/mocks/mock_icnn_network.hpp" -#include "unit_test_utils/mocks/mock_iexecutable_network.hpp" -#include "unit_test_utils/mocks/mock_iinfer_request.hpp" -#include "unit_test_utils/mocks/mock_not_empty_icnn_network.hpp" - -#include "unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp" - #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_async_infer_request_default.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" - #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" +#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" +#include "unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp" +#include "unit_test_utils/mocks/mock_allocator.hpp" +#include "unit_test_utils/mocks/mock_icnn_network.hpp" +#include "unit_test_utils/mocks/mock_iexecutable_network.hpp" +#include "unit_test_utils/mocks/mock_iinfer_request.hpp" +#include "unit_test_utils/mocks/mock_not_empty_icnn_network.hpp" using namespace InferenceEngine; @@ -29,7 +26,7 @@ void MockNotEmptyICNNNetwork::getOutputsInfo(OutputsDataMap& out) const noexcept IE_SUPPRESS_DEPRECATED_END } -void MockNotEmptyICNNNetwork::getInputsInfo(InputsDataMap &inputs) const noexcept { +void MockNotEmptyICNNNetwork::getInputsInfo(InputsDataMap& inputs) const noexcept { IE_SUPPRESS_DEPRECATED_START auto inputInfo = std::make_shared(); @@ -49,7 +46,8 @@ void MockNotEmptyICNNNetwork::getInputsInfo(InputsDataMap &inputs) const noexcep std::shared_ptr MockNotEmptyICNNNetwork::getFunction() noexcept { ngraph::ParameterVector parameters; parameters.push_back(std::make_shared( - ov::element::f32, std::vector{INPUT_DIMENSIONS.begin(), INPUT_DIMENSIONS.end()})); + ov::element::f32, + std::vector{INPUT_DIMENSIONS.begin(), INPUT_DIMENSIONS.end()})); parameters.back()->set_friendly_name(INPUT_BLOB_NAME); auto relu = std::make_shared(parameters.back()); relu->set_friendly_name(OUTPUT_BLOB_NAME); @@ -61,7 +59,8 @@ std::shared_ptr MockNotEmptyICNNNetwork::getFunction() noexcep std::shared_ptr MockNotEmptyICNNNetwork::getFunction() const noexcept { ngraph::ParameterVector parameters; parameters.push_back(std::make_shared( - ov::element::f32, std::vector{INPUT_DIMENSIONS.begin(), INPUT_DIMENSIONS.end()})); + ov::element::f32, + std::vector{INPUT_DIMENSIONS.begin(), INPUT_DIMENSIONS.end()})); parameters.back()->set_friendly_name(INPUT_BLOB_NAME); auto relu = std::make_shared(parameters.back()); relu->set_friendly_name(OUTPUT_BLOB_NAME); diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_async_infer_request_default.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_async_infer_request_default.hpp index bf439479861c18..5d1088cb938625 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_async_infer_request_default.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_async_infer_request_default.hpp @@ -4,21 +4,21 @@ #pragma once +#include + #include #include -#include - -#include +#include "cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp" using namespace InferenceEngine; class MockAsyncInferRequestDefault : public AsyncInferRequestThreadSafeDefault { public: MockAsyncInferRequestDefault(IInferRequestInternal::Ptr request, - const ITaskExecutor::Ptr &taskExecutor, - const ITaskExecutor::Ptr &callbackExecutor) - : AsyncInferRequestThreadSafeDefault(request, taskExecutor, callbackExecutor) {} + const ITaskExecutor::Ptr& taskExecutor, + const ITaskExecutor::Ptr& callbackExecutor) + : AsyncInferRequestThreadSafeDefault(request, taskExecutor, callbackExecutor) {} MOCK_METHOD0(CheckBlob, void()); }; diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp index cf761491010f6a..f2c1332889ee22 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp @@ -3,12 +3,13 @@ // #pragma once -#include -#include -#include -#include #include + #include +#include +#include +#include +#include using namespace InferenceEngine; @@ -16,6 +17,6 @@ class MockExecutableNetworkThreadSafe : public ExecutableNetworkThreadSafeDefaul public: MOCK_METHOD2(CreateInferRequestImpl, std::shared_ptr(InputsDataMap networkInputs, OutputsDataMap networkOutputs)); - MOCK_METHOD1(Export, void(const std::string &)); - void Export(std::ostream &) override {} + MOCK_METHOD1(Export, void(const std::string&)); + void Export(std::ostream&) override {} }; diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp index 50385fec1834c5..db1a288804c5a9 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp @@ -4,26 +4,30 @@ #pragma once +#include + +#include +#include #include #include - -#include "ie_icore.hpp" -#include #include #include -#include -#include + +#include "ie_icore.hpp" #include "openvino/runtime/iplugin.hpp" class MockInferencePluginInternal : public InferenceEngine::IInferencePlugin { public: - MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr( - const InferenceEngine::CNNNetwork &, const std::map &)); + MOCK_METHOD2( + LoadExeNetworkImpl, + std::shared_ptr(const InferenceEngine::CNNNetwork&, + const std::map&)); MOCK_METHOD1(AddExtension, void(const std::shared_ptr&)); - MOCK_METHOD1(SetConfig, void(const std::map &)); + MOCK_METHOD1(SetConfig, void(const std::map&)); - std::shared_ptr - ImportNetwork(std::istream& stream, const std::map &) { + std::shared_ptr ImportNetwork( + std::istream& stream, + const std::map&) { return {}; } diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp index 2e7325a1d5727e..08283dc81fb774 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp @@ -4,15 +4,14 @@ #pragma once +#include + +#include #include #include #include -#include - #include "ie_input_info.hpp" -#include - #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" using namespace InferenceEngine; @@ -22,13 +21,13 @@ class MockIExecutableNetworkInternal : public IExecutableNetworkInternal { MOCK_CONST_METHOD0(GetOutputsInfo, ConstOutputsDataMap(void)); MOCK_CONST_METHOD0(GetInputsInfo, ConstInputsDataMap(void)); MOCK_METHOD0(CreateInferRequest, IInferRequestInternal::Ptr(void)); - MOCK_METHOD1(Export, void(const std::string &)); - void Export(std::ostream &) override {}; + MOCK_METHOD1(Export, void(const std::string&)); + void Export(std::ostream&) override{}; MOCK_METHOD0(GetExecGraphInfo, std::shared_ptr(void)); - MOCK_METHOD1(SetConfig, void(const std::map &config)); - MOCK_CONST_METHOD1(GetConfig, Parameter(const std::string &name)); - MOCK_CONST_METHOD1(GetMetric, Parameter(const std::string &name)); + MOCK_METHOD1(SetConfig, void(const std::map& config)); + MOCK_CONST_METHOD1(GetConfig, Parameter(const std::string& name)); + MOCK_CONST_METHOD1(GetMetric, Parameter(const std::string& name)); MOCK_CONST_METHOD0(GetContext, std::shared_ptr(void)); void WrapOstreamExport(std::ostream& networkModel) { IExecutableNetworkInternal::Export(networkModel); diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp index 85347e2a5c68b6..11da8a6ea42fd9 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp @@ -6,13 +6,12 @@ #include +#include +#include #include #include #include -#include -#include - class MockIInferRequestInternal : public InferenceEngine::IInferRequestInternal { public: using InferenceEngine::IInferRequestInternal::IInferRequestInternal; @@ -20,7 +19,7 @@ class MockIInferRequestInternal : public InferenceEngine::IInferRequestInternal MOCK_METHOD1(Wait, InferenceEngine::StatusCode(int64_t)); MOCK_METHOD0(Infer, void()); MOCK_CONST_METHOD0(GetPerformanceCounts, std::map()); - MOCK_METHOD2(SetBlob, void(const std::string&, const InferenceEngine::Blob::Ptr &)); + MOCK_METHOD2(SetBlob, void(const std::string&, const InferenceEngine::Blob::Ptr&)); MOCK_METHOD1(GetBlob, InferenceEngine::Blob::Ptr(const std::string&)); MOCK_CONST_METHOD1(GetPreProcess, const InferenceEngine::PreProcessInfo&(const std::string&)); MOCK_METHOD1(SetCallback, void(std::function)); diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp index 55f95b435477ca..958ff721568778 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp @@ -4,44 +4,57 @@ #pragma once +#include + #include #include -#include #include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include "ie_icore.hpp" class MockIInferencePlugin : public InferenceEngine::IInferencePlugin { public: MOCK_METHOD1(AddExtension, void(const std::shared_ptr&)); - MOCK_METHOD2(LoadNetwork, std::shared_ptr( - const InferenceEngine::CNNNetwork&, const std::map&)); - MOCK_METHOD2(LoadNetwork, ov::SoPtr( - const std::string&, const std::map&)); - MOCK_METHOD2(ImportNetwork, std::shared_ptr( - const std::string&, const std::map&)); - MOCK_METHOD1(SetConfig, void(const std::map &)); + MOCK_METHOD2( + LoadNetwork, + std::shared_ptr(const InferenceEngine::CNNNetwork&, + const std::map&)); + MOCK_METHOD2(LoadNetwork, + ov::SoPtr(const std::string&, + const std::map&)); + MOCK_METHOD2( + ImportNetwork, + std::shared_ptr(const std::string&, + const std::map&)); + MOCK_METHOD1(SetConfig, void(const std::map&)); MOCK_METHOD(void, SetName, (const std::string&), (noexcept)); MOCK_METHOD(std::string, GetName, (), (const, noexcept)); MOCK_METHOD(void, SetCore, (std::weak_ptr), (noexcept)); MOCK_METHOD(std::shared_ptr, GetCore, (), (const, noexcept)); MOCK_METHOD(bool, IsNewAPI, (), (const, noexcept)); - MOCK_CONST_METHOD2(GetConfig, InferenceEngine::Parameter( - const std::string&, const std::map&)); - MOCK_CONST_METHOD2(GetMetric, InferenceEngine::Parameter( - const std::string&, const std::map&)); - MOCK_METHOD1(CreateContext, - std::shared_ptr(const InferenceEngine::ParamMap&)); + MOCK_CONST_METHOD2(GetConfig, + InferenceEngine::Parameter(const std::string&, + const std::map&)); + MOCK_CONST_METHOD2(GetMetric, + InferenceEngine::Parameter(const std::string&, + const std::map&)); + MOCK_METHOD1(CreateContext, std::shared_ptr(const InferenceEngine::ParamMap&)); MOCK_METHOD1(GetDefaultContext, std::shared_ptr(const InferenceEngine::ParamMap&)); - MOCK_METHOD3(LoadNetwork, std::shared_ptr( - const InferenceEngine::CNNNetwork&, const std::map&, - const std::shared_ptr&)); - MOCK_METHOD2(ImportNetwork, std::shared_ptr( - std::istream&, const std::map&)); - MOCK_METHOD3(ImportNetwork, std::shared_ptr( - std::istream&, const std::shared_ptr&, - const std::map&)); + MOCK_METHOD3(LoadNetwork, + std::shared_ptr( + const InferenceEngine::CNNNetwork&, + const std::map&, + const std::shared_ptr&)); + MOCK_METHOD2( + ImportNetwork, + std::shared_ptr(std::istream&, + const std::map&)); + MOCK_METHOD3(ImportNetwork, + std::shared_ptr( + std::istream&, + const std::shared_ptr&, + const std::map&)); MOCK_CONST_METHOD2(QueryNetwork, InferenceEngine::QueryNetworkResult(const InferenceEngine::CNNNetwork&, const std::map&)); diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp index 5b3dc748da5654..88fef91a51ef40 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp @@ -6,11 +6,10 @@ #include +#include #include #include -#include - class MockIVariableStateInternal : public InferenceEngine::IVariableStateInternal { public: MockIVariableStateInternal() : InferenceEngine::IVariableStateInternal{"MockIVariableStateInternal"} {} diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp index e1419ed469a1e7..1ea59a0314f5f3 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp @@ -4,9 +4,9 @@ #pragma once -#include - #include + +#include #include class MockTaskExecutor : public InferenceEngine::ITaskExecutor { diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/dllmain.cpp b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/dllmain.cpp index 0de604ca9c2451..d80324ec4218f3 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/dllmain.cpp +++ b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/dllmain.cpp @@ -3,12 +3,9 @@ // #ifdef _WIN32 -#include +# include -BOOL APIENTRY DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) { +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_icnn_network.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_icnn_network.hpp index 7c976d5e807ed6..55acbe299860b8 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_icnn_network.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/mock_icnn_network.hpp @@ -26,30 +26,42 @@ class CNNLayer; * @brief Main interface to describe the NN topology */ class MockICNNNetwork final : public InferenceEngine::ICNNNetwork { - public: +public: MOCK_METHOD(std::shared_ptr, getFunction, (), (const, noexcept)); MOCK_METHOD(std::shared_ptr, getFunction, (), (noexcept)); - MOCK_METHOD(void, getOutputsInfo, (InferenceEngine::OutputsDataMap& out), (const, noexcept)); - MOCK_METHOD(void, getInputsInfo, (InferenceEngine::InputsDataMap &inputs), (const, noexcept)); - MOCK_METHOD(InferenceEngine::InputInfo::Ptr, getInput, (const std::string &inputName), (const, noexcept)); + MOCK_METHOD(void, getOutputsInfo, (InferenceEngine::OutputsDataMap & out), (const, noexcept)); + MOCK_METHOD(void, getInputsInfo, (InferenceEngine::InputsDataMap & inputs), (const, noexcept)); + MOCK_METHOD(InferenceEngine::InputInfo::Ptr, getInput, (const std::string& inputName), (const, noexcept)); MOCK_METHOD(size_t, layerCount, (), (const, noexcept)); MOCK_METHOD(const std::string&, getName, (), (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, addOutput, - (const std::string &, size_t, InferenceEngine::ResponseDesc*), (noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, getLayerByName, - (const char* , std::shared_ptr&, InferenceEngine::ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, setBatchSize, - (const size_t size, InferenceEngine::ResponseDesc*), (noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, + addOutput, + (const std::string&, size_t, InferenceEngine::ResponseDesc*), + (noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, + getLayerByName, + (const char*, std::shared_ptr&, InferenceEngine::ResponseDesc*), + (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, + setBatchSize, + (const size_t size, InferenceEngine::ResponseDesc*), + (noexcept)); MOCK_METHOD(size_t, getBatchSize, (), (const, noexcept)); MOCK_METHOD(void, getInputShapes, (InferenceEngine::ICNNNetwork::InputShapes&), (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, reshape, - (const InferenceEngine::ICNNNetwork::InputShapes &, InferenceEngine::ResponseDesc *), - (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, serialize, - (const std::string &, const std::string &, InferenceEngine::ResponseDesc*), (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, serialize, - (std::ostream &, std::ostream &, InferenceEngine::ResponseDesc*), (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, serialize, - (std::ostream &, InferenceEngine::Blob::Ptr &, InferenceEngine::ResponseDesc*), (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, + reshape, + (const InferenceEngine::ICNNNetwork::InputShapes&, InferenceEngine::ResponseDesc*), + (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, + serialize, + (const std::string&, const std::string&, InferenceEngine::ResponseDesc*), + (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, + serialize, + (std::ostream&, std::ostream&, InferenceEngine::ResponseDesc*), + (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, + serialize, + (std::ostream&, InferenceEngine::Blob::Ptr&, InferenceEngine::ResponseDesc*), + (const, noexcept)); }; diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp index 67e985cfe199e6..7b0e59356958f9 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp @@ -22,20 +22,25 @@ IE_SUPPRESS_DEPRECATED_START class MockIExecutableNetwork : public IExecutableNetwork { public: - MOCK_METHOD(StatusCode, GetOutputsInfo, (ConstOutputsDataMap &, ResponseDesc *), (const, noexcept)); - MOCK_METHOD(StatusCode, GetInputsInfo, (ConstInputsDataMap &, ResponseDesc *), (const, noexcept)); - MOCK_METHOD(StatusCode, CreateInferRequest, (IInferRequest::Ptr &, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, Export, (const std::string &, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, Export, (std::ostream &, ResponseDesc *), (noexcept)); - MOCK_METHOD(StatusCode, GetExecGraphInfo, (ICNNNetwork::Ptr &, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, SetConfig, - ((const std::map &config), ResponseDesc *resp), (noexcept)); - MOCK_METHOD(StatusCode, GetConfig, - (const std::string &name, Parameter &result, ResponseDesc *resp), (const, noexcept)); - MOCK_METHOD(StatusCode, GetMetric, - (const std::string &name, Parameter &result, ResponseDesc *resp), (const, noexcept)); - MOCK_METHOD(StatusCode, GetContext, - (RemoteContext::Ptr &pContext, ResponseDesc *resp), (const, noexcept)); + MOCK_METHOD(StatusCode, GetOutputsInfo, (ConstOutputsDataMap&, ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, GetInputsInfo, (ConstInputsDataMap&, ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, CreateInferRequest, (IInferRequest::Ptr&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, Export, (const std::string&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, Export, (std::ostream&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, GetExecGraphInfo, (ICNNNetwork::Ptr&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, + SetConfig, + ((const std::map& config), ResponseDesc* resp), + (noexcept)); + MOCK_METHOD(StatusCode, + GetConfig, + (const std::string& name, Parameter& result, ResponseDesc* resp), + (const, noexcept)); + MOCK_METHOD(StatusCode, + GetMetric, + (const std::string& name, Parameter& result, ResponseDesc* resp), + (const, noexcept)); + MOCK_METHOD(StatusCode, GetContext, (RemoteContext::Ptr & pContext, ResponseDesc* resp), (const, noexcept)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp index e616f5460b6d52..48e42d3f9c4e4f 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp @@ -28,11 +28,12 @@ class MockIInferRequest : public IInferRequest { MOCK_METHOD(StatusCode, SetUserData, (void*, ResponseDesc*), (noexcept)); MOCK_METHOD(StatusCode, SetCompletionCallback, (IInferRequest::CompletionCallback), (noexcept)); MOCK_METHOD(StatusCode, Infer, (ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, GetPerformanceCounts, - ((std::map &), ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, + GetPerformanceCounts, + ((std::map&), ResponseDesc*), + (const, noexcept)); MOCK_METHOD(StatusCode, GetBlob, (const char*, Blob::Ptr&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, GetPreProcess, - (const char*, const PreProcessInfo**, ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, GetPreProcess, (const char*, const PreProcessInfo**, ResponseDesc*), (const, noexcept)); MOCK_METHOD(StatusCode, SetBlob, (const char*, const Blob::Ptr&, ResponseDesc*), (noexcept)); MOCK_METHOD(StatusCode, Cancel, (ResponseDesc*), (noexcept)); }; diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp index 98d70575390d85..939fb86ce18d07 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp @@ -6,8 +6,8 @@ #include -#include #include +#include #include #include "ie_icnn_network.hpp" @@ -19,30 +19,33 @@ IE_SUPPRESS_DEPRECATED_START class MockNotEmptyICNNNetwork final : public ICNNNetwork { public: static constexpr const char* INPUT_BLOB_NAME = "first_input"; - const SizeVector INPUT_DIMENSIONS = { 1, 3, 299, 299 }; + const SizeVector INPUT_DIMENSIONS = {1, 3, 299, 299}; static constexpr const char* OUTPUT_BLOB_NAME = "first_output"; - const SizeVector OUTPUT_DIMENSIONS = { 1, 3, 299, 299 }; + const SizeVector OUTPUT_DIMENSIONS = {1, 3, 299, 299}; const std::string name = "test"; const std::string& getName() const noexcept override { return name; } void getOutputsInfo(OutputsDataMap& out) const noexcept override; - void getInputsInfo(InputsDataMap &inputs) const noexcept override; + void getInputsInfo(InputsDataMap& inputs) const noexcept override; std::shared_ptr getFunction() noexcept override; std::shared_ptr getFunction() const noexcept override; - MOCK_METHOD(InputInfo::Ptr, getInput, (const std::string &inputName), (const, noexcept)); + MOCK_METHOD(InputInfo::Ptr, getInput, (const std::string& inputName), (const, noexcept)); MOCK_METHOD(size_t, layerCount, (), (const, noexcept)); - MOCK_METHOD(StatusCode, addOutput, (const std::string &, size_t , ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, addOutput, (const std::string&, size_t, ResponseDesc*), (noexcept)); MOCK_METHOD(StatusCode, setBatchSize, (const size_t size, ResponseDesc*), (noexcept)); MOCK_METHOD(size_t, getBatchSize, (), (const, noexcept)); - MOCK_METHOD(void, getInputShapes, (ICNNNetwork::InputShapes &), (const, noexcept)); - MOCK_METHOD(StatusCode, reshape, (const ICNNNetwork::InputShapes &, ResponseDesc *), (noexcept)); - MOCK_METHOD(StatusCode, serialize, - (const std::string &, const std::string &, InferenceEngine::ResponseDesc*), (const, noexcept)); - MOCK_METHOD(StatusCode, serialize, - (std::ostream &, std::ostream &, InferenceEngine::ResponseDesc*), (const, noexcept)); - MOCK_METHOD(StatusCode, serialize, - (std::ostream &, Blob::Ptr &, InferenceEngine::ResponseDesc*), (const, noexcept)); + MOCK_METHOD(void, getInputShapes, (ICNNNetwork::InputShapes&), (const, noexcept)); + MOCK_METHOD(StatusCode, reshape, (const ICNNNetwork::InputShapes&, ResponseDesc*), (noexcept)); + MOCK_METHOD(StatusCode, + serialize, + (const std::string&, const std::string&, InferenceEngine::ResponseDesc*), + (const, noexcept)); + MOCK_METHOD(StatusCode, + serialize, + (std::ostream&, std::ostream&, InferenceEngine::ResponseDesc*), + (const, noexcept)); + MOCK_METHOD(StatusCode, serialize, (std::ostream&, Blob::Ptr&, InferenceEngine::ResponseDesc*), (const, noexcept)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_isync_infer_request.hpp b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_isync_infer_request.hpp index 657fa94ba068e9..92a3d842762a29 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_isync_infer_request.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_isync_infer_request.hpp @@ -22,4 +22,3 @@ class MockISyncInferRequest : public ov::ISyncInferRequest { }; } // namespace ov - From 023a2f462aae44c2985131c213e9c99f64ac0059 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Wed, 6 Sep 2023 18:43:30 +0400 Subject: [PATCH 22/31] [TF Hub][Notebook] Secure future notebook models in the precommit (#19652) Signed-off-by: Kazantsev, Roman --- tests/model_hub_tests/models_hub_common/utils.py | 3 +++ tests/model_hub_tests/tf_hub_tests/precommit_models | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/model_hub_tests/models_hub_common/utils.py b/tests/model_hub_tests/models_hub_common/utils.py index 3c4d16402de4d2..6e8e9b7ea66f8d 100644 --- a/tests/model_hub_tests/models_hub_common/utils.py +++ b/tests/model_hub_tests/models_hub_common/utils.py @@ -10,6 +10,9 @@ def get_models_list(file_name: str): models = [] with open(file_name) as f: for model_info in f: + # skip comment in model scope file + if model_info.startswith('#'): + continue mark = None reason = None assert len(model_info.split(',')) == 2 or len(model_info.split(',')) == 4, \ diff --git a/tests/model_hub_tests/tf_hub_tests/precommit_models b/tests/model_hub_tests/tf_hub_tests/precommit_models index 63fbdbb63bb418..7b663b5046df77 100644 --- a/tests/model_hub_tests/tf_hub_tests/precommit_models +++ b/tests/model_hub_tests/tf_hub_tests/precommit_models @@ -6,4 +6,10 @@ imagenet/mobilenet_v2_100_224/feature_vector,https://tfhub.dev/google/imagenet/m efficientnet/lite0/classification,https://tfhub.dev/tensorflow/efficientnet/lite0/classification/2?tf-hub-format=compressed movenet/multipose/lightning,https://tfhub.dev/google/movenet/multipose/lightning/1?tf-hub-format=compressed imagenet/efficientnet_v2_imagenet1k_b0/feature_vector,https://tfhub.dev/google/imagenet/efficientnet_v2_imagenet1k_b0/feature_vector/2?tf-hub-format=compressed -imagenet/mobilenet_v1_100_224/classification,https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/5?tf-hub-format=compressed,skip,119718 - Accuracy issue \ No newline at end of file +imagenet/mobilenet_v1_100_224/classification,https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/5?tf-hub-format=compressed,skip,119718 - Accuracy issue +# secure notebook models +unet/industrial/class_1,https://tfhub.dev/nvidia/unet/industrial/class_1/1?tf-hub-format=compressed +movenet/singlepose/thunder,https://tfhub.dev/google/movenet/singlepose/thunder/4?tf-hub-format=compressed +esrgan-tf2,https://tfhub.dev/captain-pool/esrgan-tf2/1?tf-hub-format=compressed +film,https://tfhub.dev/google/film/1?tf-hub-format=compressed,skip,119907 - incorrect test data +planet/vision/classifier/planet_v2,https://tfhub.dev/google/planet/vision/classifier/planet_v2/1?tf-hub-format=compressed \ No newline at end of file From 4f7ac430fce91c7d6c7ddf62c13a6ffa911974a3 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Wed, 6 Sep 2023 19:02:59 +0400 Subject: [PATCH 23/31] [TF Hub][TF FE][GA] Establish regular validation for all TF Hub models (#19649) * [TF Hub][TF FE] Establish regular validation for all TF Hub models Signed-off-by: Kazantsev, Roman * Correct names of reports * Simplify configuration --------- Signed-off-by: Kazantsev, Roman --- .github/workflows/linux.yml | 10 ++++++++-- tests/model_hub_tests/tf_hub_tests/nightly_models_tmp | 2 ++ .../tf_hub_tests/test_tf_hub_convert_model.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/model_hub_tests/tf_hub_tests/nightly_models_tmp diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5e0fb067078993..1c6e73c8d763b7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,5 +1,8 @@ name: Tests on Linux (Ubuntu 22.04, Python 3.11) on: + schedule: + # - cron: '0 20/72 * * *' + - cron: '10 * * * *' workflow_dispatch: pull_request: paths-ignore: @@ -674,8 +677,9 @@ jobs: source ${{ env.INSTALL_DIR }}/setupvars.sh - python3 -m pytest ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/tf_hub_tests/ -m precommit --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_hub_tf_fe.xml + python3 -m pytest ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/tf_hub_tests/ -m ${{ env.TYPE }} --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_hub_tf_fe.xml --html TEST-tf_hub_tf_fe.html --self-contained-html env: + TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}} TEST_DEVICE: CPU - name: TensorFlow 1 Layer Tests - Legacy FE @@ -741,7 +745,9 @@ jobs: if: ${{ always() }} with: name: test-results-python - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml + path: | + ${{ env.INSTALL_TEST_DIR }}/TEST*.html + ${{ env.INSTALL_TEST_DIR }}/TEST*.xml if-no-files-found: 'error' CPU_Functional_Tests: diff --git a/tests/model_hub_tests/tf_hub_tests/nightly_models_tmp b/tests/model_hub_tests/tf_hub_tests/nightly_models_tmp new file mode 100644 index 00000000000000..6233759b6afb30 --- /dev/null +++ b/tests/model_hub_tests/tf_hub_tests/nightly_models_tmp @@ -0,0 +1,2 @@ +vision/embedder/fungi_V2,https://tfhub.dev/svampeatlas/vision/embedder/fungi_V2/1?tf-hub-format=compressed +universal-sentence-encoder,https://tfhub.dev/google/universal-sentence-encoder/4?tf-hub-format=compressed \ No newline at end of file diff --git a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py index 2640e8214e9044..c5cb9fb3b2f3dd 100644 --- a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py +++ b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py @@ -106,7 +106,7 @@ def test_convert_model_precommit(self, model_name, model_link, mark, reason, ie_ self.run(model_name, model_link, ie_device) @pytest.mark.parametrize("model_name,model_link,mark,reason", - get_models_list(os.path.join(os.path.dirname(__file__), "nightly_models"))) + get_models_list(os.path.join(os.path.dirname(__file__), "nightly_models_tmp"))) @pytest.mark.nightly def test_convert_model_all_models(self, model_name, model_link, mark, reason, ie_device): assert mark is None or mark == 'skip', "Incorrect test case: {}, {}".format(model_name, model_link) From 5644ca40f662e5c55020d0d6af5ee8521b7e70a3 Mon Sep 17 00:00:00 2001 From: Andrey Kashchikhin Date: Wed, 6 Sep 2023 16:45:00 +0100 Subject: [PATCH 24/31] [GA] ccache: specify key (#19519) Co-authored-by: Mikhail Ryzhov --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1c6e73c8d763b7..527ee86daebae0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -132,9 +132,9 @@ jobs: # github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push save: ${{ github.ref_name == 'master' && 'true' || 'false' }} verbose: 2 - key: ${{ github.job }}-linux + key: linux-ubuntu restore-keys: | - ${{ github.job }}-linux + linux-ubuntu - name: Get tools versions run: | From c123843d0d64b699559fe8bf0d3664aead45ce3d Mon Sep 17 00:00:00 2001 From: Karol Blaszczak Date: Wed, 6 Sep 2023 17:46:55 +0200 Subject: [PATCH 25/31] [DOCS] installation guide restructuring 23.1 master (#19241) --- .../Getting_performance_numbers.md | 23 +- .../convert_model/Convert_Model_From_ONNX.md | 6 +- .../Convert_Model_From_TensorFlow.md | 2 - docs/OV_Runtime_UG/Samples_Overview.md | 12 +- .../migration_ov_2_0/deployment_migration.md | 21 +- docs/get_started/get_started_demos.md | 6 + ...ols.md => --installing-model-dev-tools.md} | 0 .../--installing-openvino-macos.md | 16 -- ...alling-openvino-raspbian-removedfromtoc.md | 201 ------------------ .../--installing-openvino-runtime.md | 28 --- .../--installing-openvino-windows.md | 12 -- .../install_guides/--uninstalling-openvino.md | 53 ----- docs/install_guides/configurations-header.md | 22 +- .../install_guides/installing-openvino-apt.md | 77 ++----- .../installing-openvino-brew.md | 42 ++-- .../installing-openvino-conda.md | 44 ++-- .../installing-openvino-from-archive-linux.md | 89 ++++---- .../installing-openvino-from-archive-macos.md | 65 +++--- ...nstalling-openvino-from-archive-windows.md | 94 ++++---- .../installing-openvino-linux-header.md | 1 + .../installing-openvino-macos-header.md | 3 +- .../installing-openvino-overview.md | 66 +++--- .../install_guides/installing-openvino-pip.md | 42 ++-- .../installing-openvino-vcpkg.md | 95 +++++++++ .../installing-openvino-windows-header.md | 2 + .../installing-openvino-yocto.md | 3 - .../install_guides/installing-openvino-yum.md | 68 ++---- docs/install_guides/troubleshooting.md | 9 +- docs/notebooks-installation.md | 131 +++--------- 29 files changed, 455 insertions(+), 778 deletions(-) rename docs/install_guides/{installing-model-dev-tools.md => --installing-model-dev-tools.md} (100%) delete mode 100644 docs/install_guides/--installing-openvino-macos.md delete mode 100644 docs/install_guides/--installing-openvino-raspbian-removedfromtoc.md delete mode 100644 docs/install_guides/--installing-openvino-runtime.md delete mode 100644 docs/install_guides/--installing-openvino-windows.md delete mode 100644 docs/install_guides/--uninstalling-openvino.md create mode 100644 docs/install_guides/installing-openvino-vcpkg.md diff --git a/docs/MO_DG/prepare_model/Getting_performance_numbers.md b/docs/MO_DG/prepare_model/Getting_performance_numbers.md index 2627618aa799ec..3ffbf7a9693be9 100644 --- a/docs/MO_DG/prepare_model/Getting_performance_numbers.md +++ b/docs/MO_DG/prepare_model/Getting_performance_numbers.md @@ -10,30 +10,21 @@ information on using ITT and Intel® VTune™ Profiler to get performance insigh Test performance with the benchmark_app ########################################################### -Prerequisites -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -To run benchmarks, you need both OpenVINO developer tools and Runtime installed. Follow the -:doc:`Installation guide ` and make sure to install the latest -general release package with support for frameworks of the models you want to test. -To test performance of your model, make sure you :doc:`prepare the model for use with OpenVINO `. -For example, if you use :doc:`OpenVINO's automation tools `, these two lines of code will download the -resnet-50-tf and convert it to OpenVINO IR. -.. code-block:: sh +You can run OpenVINO benchmarks in both C++ and Python APIs, yet the experience differs in each case. +The Python one is part of OpenVINO Runtime installation, while C++ is available as a code sample. +For a detailed description, see: +* :doc:`benchmark_app for C++ ` +* :doc:`benchmark_app for Python `. - omz_downloader --name resnet-50-tf - omz_converter --name resnet-50-tf +Make sure to install the latest release package with support for frameworks of the models you want to test. +For the most reliable performance benchmarks, :doc:`prepare the model for use with OpenVINO `. Running the benchmark application +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -For a detailed description, see the dedicated articles: -:doc:`benchmark_app for C++ ` and -:doc:`benchmark_app for Python `. - The benchmark_app includes a lot of device-specific options, but the primary usage is as simple as: .. code-block:: sh diff --git a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_ONNX.md b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_ONNX.md index d15ef4ca9ba4b1..b160667fee62d2 100644 --- a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_ONNX.md +++ b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_ONNX.md @@ -17,9 +17,9 @@ Introduction to ONNX Converting an ONNX Model ######################## -This page provides instructions on model conversion from the ONNX format to the OpenVINO IR format. To use model conversion API, install OpenVINO Development Tools by following the :doc:`installation instructions `. +This page provides instructions on model conversion from the ONNX format to the OpenVINO IR format. -Model conversion process assumes you have an ONNX model that was directly downloaded from a public repository or converted from any framework that supports exporting to the ONNX format. +The model conversion process assumes you have an ONNX model that was directly downloaded from a public repository or converted from any framework that supports exporting to the ONNX format. .. tab-set:: @@ -48,7 +48,7 @@ Model conversion process assumes you have an ONNX model that was directly downlo mo --input_model .onnx -There are no ONNX specific parameters, so only framework-agnostic parameters are available to convert your model. For details, see the *General Conversion Parameters* section in the :doc:`Converting a Model to Intermediate Representation (IR) ` guide. +There are no ONNX-specific parameters, so only framework-agnostic parameters are available to convert your model. For details, see the *General Conversion Parameters* section in the :doc:`Converting a Model to Intermediate Representation (IR) ` guide. Supported ONNX Layers ##################### diff --git a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md index 1f460d94f26b23..e565638c444913 100644 --- a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md +++ b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_TensorFlow.md @@ -11,8 +11,6 @@ This page provides general instructions on how to run model conversion from a Te .. note:: TensorFlow models are supported via :doc:`FrontEnd API `. You may skip conversion to IR and read models directly by OpenVINO runtime API. Refer to the :doc:`inference example ` for more details. Using ``convert_model`` is still necessary in more complex cases, such as new custom inputs/outputs in model pruning, adding pre-processing, or using Python conversion extensions. -To use model conversion API, install OpenVINO Development Tools by following the :doc:`installation instructions `. - Converting TensorFlow 1 Models ############################### diff --git a/docs/OV_Runtime_UG/Samples_Overview.md b/docs/OV_Runtime_UG/Samples_Overview.md index 686fdee7fae825..2a6bf54aadef46 100644 --- a/docs/OV_Runtime_UG/Samples_Overview.md +++ b/docs/OV_Runtime_UG/Samples_Overview.md @@ -51,7 +51,7 @@ If you installed OpenVINO via PyPI, download `the OpenVINO repository ` - :doc:`Automatic Speech Recognition Python Sample ` @@ -98,13 +98,15 @@ The applications include: - **Benchmark Application** – Estimates deep learning inference performance on supported devices for synchronous and asynchronous modes. - :doc:`Benchmark C++ Tool ` - - Note that the Python version of the benchmark tool is currently available only through the :doc:`OpenVINO Development Tools installation `. It is not created in the samples directory but can be launched with the following command: ``benchmark_app -m -i -d ``. For more information, check the :doc:`Benchmark Python Tool ` documentation. + Note that the Python version of the benchmark tool is a core component of the OpenVINO installation package and + may be executed with the following command: ``benchmark_app -m -i -d ``. + For more information, check the :doc:`Benchmark Python Tool `. .. note:: - All C++ samples support input paths containing only ASCII characters, except for the Hello Classification Sample, that supports Unicode. + All C++ samples support input paths containing only ASCII characters, except for the Hello Classification Sample, which supports Unicode. + Media Files Available for Samples ################################# @@ -119,7 +121,7 @@ To run the sample, you can use :doc:`public ` or :doc:` Build the Sample Applications ############################# -.. _build-samples-linux: + Build the Sample Applications on Linux ++++++++++++++++++++++++++++++++++++++ diff --git a/docs/OV_Runtime_UG/migration_ov_2_0/deployment_migration.md b/docs/OV_Runtime_UG/migration_ov_2_0/deployment_migration.md index 37a9a25053e107..ac7826c8bb3931 100644 --- a/docs/OV_Runtime_UG/migration_ov_2_0/deployment_migration.md +++ b/docs/OV_Runtime_UG/migration_ov_2_0/deployment_migration.md @@ -16,7 +16,19 @@ One of the main concepts for OpenVINO™ API 2.0 is being "easy to use", which i * Development and deployment of OpenVINO-based applications. -To accomplish that, the 2022.1 release OpenVINO introduced significant changes to the installation and deployment processes. This guide will walk you through these changes. +To accomplish that, the 2022.1 release OpenVINO introduced significant changes to the installation +and deployment processes. Further changes were implemented in 2023.1, aiming at making the installation +process even simpler. + +.. tip:: + + These instructions are largely deprecated and should be used for versions prior to 2023.1. + + OpenVINO Development Tools is being deprecated and will be discontinued entirely in 2025. + With this change, the OpenVINO Runtime package has become the default choice for installing the + software. It now includes all components necessary to utilize OpenVINO's functionality. + + The Installer Package Contains OpenVINO™ Runtime Only ##################################################### @@ -47,8 +59,8 @@ In previous versions, OpenVINO Development Tools was a part of the main package. $ mo.py -h -For 2022.1 and After -++++++++++++++++++++ +For 2022.1 and After (prior to 2023.1) +++++++++++++++++++++++++++++++++++++++++++ In OpenVINO 2022.1 and later, you can install the development tools only from a `PyPI `__ repository, using the following command (taking TensorFlow as an example): @@ -67,7 +79,8 @@ Then, the tools can be used by commands like: $ pot -h -Installation of any other dependencies is not required. For more details on the installation steps, see the :doc:`Install OpenVINO Development Tools `. +Installation of any other dependencies is not required. For more details on the installation steps, see the +`Install OpenVINO Development Tools `__ prior to OpenVINO 2023.1. Interface Changes for Building C/C++ Applications ################################################# diff --git a/docs/get_started/get_started_demos.md b/docs/get_started/get_started_demos.md index 5c87b89c8275b1..61e6e60c600c7b 100644 --- a/docs/get_started/get_started_demos.md +++ b/docs/get_started/get_started_demos.md @@ -35,6 +35,8 @@ To use sample applications, install OpenVINO Runtime via one of the following di Make sure that you also `install OpenCV `__ , as it's required for running sample applications. + + Install OpenVINO Development Tools ++++++++++++++++++++++++++++++++++ @@ -49,6 +51,10 @@ To install OpenVINO Development Tools, follow the :doc:`instructions for C++ dev pip install openvino-dev[caffe] + + + + Build Samples +++++++++++++ diff --git a/docs/install_guides/installing-model-dev-tools.md b/docs/install_guides/--installing-model-dev-tools.md similarity index 100% rename from docs/install_guides/installing-model-dev-tools.md rename to docs/install_guides/--installing-model-dev-tools.md diff --git a/docs/install_guides/--installing-openvino-macos.md b/docs/install_guides/--installing-openvino-macos.md deleted file mode 100644 index 4723a80c789339..00000000000000 --- a/docs/install_guides/--installing-openvino-macos.md +++ /dev/null @@ -1,16 +0,0 @@ -# Install OpenVINO™ Runtime for macOS from Installer - -@sphinxdirective - -Currently only the following ways are provided to install OpenVINO™ on macOS: - -* :doc:`Install OpenVINO Runtime using an Archive File ` -* :doc:`Install OpenVINO Runtime using Homebrew ` -* :doc:`Install OpenVINO using PyPI ` -* :doc:`Install OpenVINO using Conda Forge ` -* `Build From Source `__ - -The other installation methods are temporarily unavailable. - - -@endsphinxdirective \ No newline at end of file diff --git a/docs/install_guides/--installing-openvino-raspbian-removedfromtoc.md b/docs/install_guides/--installing-openvino-raspbian-removedfromtoc.md deleted file mode 100644 index 6803e3d5a9e7c8..00000000000000 --- a/docs/install_guides/--installing-openvino-raspbian-removedfromtoc.md +++ /dev/null @@ -1,201 +0,0 @@ -# Install OpenVINO™ Runtime for Raspbian OS - -@sphinxdirective - -.. note:: - - * These steps apply to Raspbian OS (the official OS for Raspberry Pi boards). - * These steps have been validated with Raspberry Pi 3. - * There is also an open-source version of OpenVINO™ that can be compiled for aarch64 (see `build instructions `_). - -Development and Target Systems -############################### - -.. tab-set:: - - .. tab-item:: System Requirements - :sync: system-requirements - - | Full requirement listing is available in: - | `System Requirements Page `_ - - .. tab-item:: Software Requirements - :sync: software-requirements - - * CMake 3.10 or higher - * Python 3.7 - 3.11 - - -.. _install-openvino: - -Step 1: Download and Install OpenVINO Runtime -############################################# - - -1. Open the Terminal or your preferred console application. -2. Create an installation folder for OpenVINO. If the folder already exists, skip this step. - - .. code-block:: sh - - sudo mkdir -p /opt/intel - - .. note:: - - The ``/opt/intel`` path is the recommended folder path for administrators or root users. If you prefer to install OpenVINO in regular userspace, the recommended path is ``/home//intel``. You may use a different path if desired. - -3. Go to your ``~/Downloads`` directory and download OpenVINO Runtime archive file for Debian from `OpenVINO package repository `_. - - .. tab-set:: - - .. tab-item:: ARM 64-bit - :sync: arm-64 - - .. code-block:: sh - - cd ~/Downloads/ - sudo wget https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0/linux/l_openvino_toolkit_debian9_2023.0.0.10926.b4452d56304_arm64.tgz -O openvino_2023.0.0.tgz - - .. tab-item:: ARM 32-bit - :sync: arm-32 - - .. code-block:: sh - - cd ~/Downloads/ - sudo wget https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0/linux/l_openvino_toolkit_debian9_2023.0.0.10926.b4452d56304_armhf.tgz -O openvino_2023.0.0.tgz - -4. Extract the archive file and move it to the installation folder: - - .. tab-set:: - - .. tab-item:: ARM 64-bit - :sync: arm-64 - - .. code-block:: sh - - sudo tar -xf openvino_2023.0.0.tgz - sudo mv l_openvino_toolkit_debian9_2023.0.0.10926.b4452d56304_arm64 /opt/intel/openvino_2023.0.0 - - .. tab-item:: ARM 32-bit - :sync: arm-32 - - .. code-block:: sh - - sudo tar -xf openvino_2023.0.0.tgz - sudo mv l_openvino_toolkit_debian9_2023.0.0.10926.b4452d56304_armhf /opt/intel/openvino_2023.0.0 - - -5. Install required system dependencies on Linux. To do this, OpenVINO provides a script in the extracted installation directory. Run the following command: - - .. code-block:: sh - - sudo -E ./install_dependencies/install_openvino_dependencies.sh - -6. For simplicity, it is useful to create a symbolic link as below: - - .. code-block:: sh - - sudo ln -s openvino_2023.0.0 openvino_2023 - - .. note:: - - If you have already installed a previous release of OpenVINO 2023, a symbolic link to the ``openvino_2023`` folder may already exist. Unlink the previous link with ``sudo unlink openvino_2023``, and then re-run the command above. - - -Congratulations, you finished the installation! The ``/opt/intel/openvino_2023`` folder now contains the core components for OpenVINO. If you used a different path in Step 2, for example, ``/home//intel/``, OpenVINO is then installed in ``/home//intel/openvino_2023``. The path to the ``openvino_2023`` directory is also referred as ```` throughout the OpenVINO documentation. - -.. _install-external-dependencies: - -Step 2: Install External Software Dependencies -############################################## - -CMake version 3.10 or higher is required for building the OpenVINO™ toolkit sample application. To install, open a Terminal window and run the following command: - -.. code-block:: sh - - sudo apt install cmake - - -CMake is installed. Continue to the next section to set the environment variables. - -.. _set-the-environment-variables-raspbian: - -Step 3: Set the Environment Variables -##################################### - -You must update several environment variables before you can compile and run OpenVINO applications. Open a terminal window and run the ``setupvars.sh`` script as shown below to temporarily set your environment variables. If your is not ``/opt/intel/openvino_2023``, use the correct one instead. - -.. code-block:: sh - - source /opt/intel/openvino_2023/setupvars.sh - - -If you have more than one OpenVINO version on your machine, you can easily switch its version by sourcing the ``setupvars.sh`` of your choice. - -.. note:: - - The above command must be re-run every time you start a new terminal session. To set up Linux to automatically run the command every time a new terminal is opened, open ``~/.bashrc`` in your favorite editor and add ``source /opt/intel/openvino_2023/setupvars.sh`` after the last line. Next time when you open a terminal, you will see ``[setupvars.sh] OpenVINO™ environment initialized``. Changing ``.bashrc`` is not recommended when you have multiple OpenVINO versions on your machine and want to switch among them. - -The environment variables are set. Continue to the next section if you want to download any additional components. - -.. _model-optimizer: - -Step 4 (Optional): Install Additional Components -################################################ - -If you want to use your model for inference, the model must be converted to the ``.bin`` and ``.xml`` Intermediate Representation (IR) files that are used as input by OpenVINO Runtime. To get the optimized models, you can use one of the following options: - -* Download public and Intel's pre-trained models from the `Open Model Zoo `_ using :doc:`Model Downloader tool `. For more information on pre-trained models, see :doc:`Pre-Trained Models Documentation `. - - * OpenCV is necessary to run demos from Open Model Zoo (OMZ). Some OpenVINO samples can also extend their capabilities when compiled with OpenCV as a dependency. To install OpenCV for OpenVINO, see the `instructions on Github `_. - -* Convert the models using the model conversion API, which is included in OpenVINO Development Tools. - - * OpenVINO Development Tools is a set of utilities for working with OpenVINO and OpenVINO models. It provides tools like model conversion API, Benchmark Tool, Post-Training Optimization Tool, and Open Model Zoo Downloader. See the :doc:`Install OpenVINO Development Tools ` page for step-by-step installation instructions. - -What's Next? -#################### - -Now that you've installed OpenVINO Runtime, you're ready to run your own machine learning applications! Learn more about how to integrate a model in OpenVINO applications by trying out the following tutorials. - -.. tab-set:: - - .. tab-item:: Get started with Python - :sync: get-started-python - - Try the `Python Quick Start Example `__ to estimate depth in a scene using an OpenVINO monodepth model in a Jupyter Notebook inside your web browser. - - .. image:: https://user-images.githubusercontent.com/15709723/127752390-f6aa371f-31b5-4846-84b9-18dd4f662406.gif - :width: 400 - - Visit the :ref:`Tutorials ` page for more Jupyter Notebooks to get you started with OpenVINO, such as: - - * `OpenVINO Python API Tutorial `__ - * `Basic image classification program with Hello Image Classification `__ - * `Convert a PyTorch model and use it for image background removal `__ - - - .. tab-item:: Get started with C++ - :sync: get-started-python - - Try the `C++ Quick Start Example `_ for step-by-step instructions on building and running a basic image classification C++ application. - - .. image:: https://user-images.githubusercontent.com/36741649/127170593-86976dc3-e5e4-40be-b0a6-206379cd7df5.jpg - :width: 400 - - Visit the :ref:`Samples ` page for other C++ example applications to get you started with OpenVINO, such as: - - * `Basic object detection with the Hello Reshape SSD C++ sample `_ - * `Automatic speech recognition C++ sample `_ - - -Additional Resources -#################### - -* :ref:`Troubleshooting Guide for OpenVINO Installation & Configuration ` -* Converting models for use with OpenVINO™: :ref:`Model Optimizer User Guide ` -* Writing your own OpenVINO™ applications: :ref:`OpenVINO™ Runtime User Guide ` -* Sample applications: :ref:`OpenVINO™ Toolkit Samples Overview ` -* Pre-trained deep learning models: :ref:`Overview of OpenVINO™ Toolkit Pre-Trained Models ` -* IoT libraries and code samples in the GitHUB repository: `Intel® IoT Developer Kit `__ - -@endsphinxdirective diff --git a/docs/install_guides/--installing-openvino-runtime.md b/docs/install_guides/--installing-openvino-runtime.md deleted file mode 100644 index 4af90ab562698a..00000000000000 --- a/docs/install_guides/--installing-openvino-runtime.md +++ /dev/null @@ -1,28 +0,0 @@ -# Install OpenVINO™ Runtime - -@sphinxdirective - -.. meta:: - :description: Learn how to install OpenVINO™ Runtime on Windows, macOS, and - Linux operating systems, using various installation methods. - - -.. toctree:: - :maxdepth: 2 - :hidden: - - Linux - Windows - macOS - - -You can choose how to install OpenVINO™ Runtime according to your operating system: - -* :doc:`Install OpenVINO Runtime on Linux ` -* :doc:`Install OpenVINO Runtime on Windows ` -* :doc:`Install OpenVINO Runtime on macOS ` - -Enjoy your journey with OpenVINO. - - -@endsphinxdirective diff --git a/docs/install_guides/--installing-openvino-windows.md b/docs/install_guides/--installing-openvino-windows.md deleted file mode 100644 index c73bf03b5fa204..00000000000000 --- a/docs/install_guides/--installing-openvino-windows.md +++ /dev/null @@ -1,12 +0,0 @@ -# Install OpenVINO™ Runtime on Windows from Installer - -Currently only the following ways are provided to install OpenVINO™: - -* [Install OpenVINO Runtime from an Archive File](installing-openvino-from-archive-windows.md) -* [Install OpenVINO from PyPI](installing-openvino-pip.md) -* [Install OpenVINO with Docker](installing-openvino-docker-windows.md) -* [Build From Source](https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build.md) - -The other installation methods are temporarily unavailable. - - diff --git a/docs/install_guides/--uninstalling-openvino.md b/docs/install_guides/--uninstalling-openvino.md deleted file mode 100644 index ae06acd75f483d..00000000000000 --- a/docs/install_guides/--uninstalling-openvino.md +++ /dev/null @@ -1,53 +0,0 @@ -# Uninstalling the Intel® Distribution of OpenVINO™ Toolkit - -@sphinxdirective - -.. meta:: - :description: Learn how to uninstall Intel® Distribution of OpenVINO™ Toolkit from your - operating system. - - -.. note:: - - Uninstallation procedures remove all Intel® Distribution of OpenVINO™ Toolkit component files but don't affect user files in the installation directory. - -Uninstall Using the Original Installation Package -################################################# - -If you have installed OpenVINO Runtime from archive files, you can uninstall it by deleting the archive files and the extracted folders. - -.. tab-set:: - - .. tab-item:: Windows - :sync: windows - - If you have created the symbolic link, remove the link first. - - Use either of the following methods to delete the files: - - * Use Windows Explorer to remove the files. - * Open a Command Prompt and run: - - .. code-block:: sh - - rmdir /s - del - - - .. tab-item:: Linux & macOS - :sync: linux-and-macos - - If you have created the symbolic link, remove the link first: - - .. code-block:: sh - - sudo rm /opt/intel/openvino_2023 - - To delete the files: - - .. code-block:: sh - - rm -r && rm - -@endsphinxdirective - diff --git a/docs/install_guides/configurations-header.md b/docs/install_guides/configurations-header.md index 2dfdaf6db82e1e..6928f48276ff4e 100644 --- a/docs/install_guides/configurations-header.md +++ b/docs/install_guides/configurations-header.md @@ -17,10 +17,26 @@ For GNA -After you have installed OpenVINO™ Runtime, you may also need do some additional configurations for your device to work with OpenVINO™. See the following pages: +For certain use cases, you may need to install additional software, to get the full +potential of OpenVINO™. Check the following list for components pertaining to your +workflow: + +| **Open Computer Vision Library** +| OpenCV is used to extend the capabilities of some models, for example enhance some of + OpenVINO samples, when used as a dependency in compilation. To install OpenCV for OpenVINO, see the + `instructions on GtHub `__. + +| **GPU drivers** +| If you want to run inference on a GPU, make sure your GPU's drivers are properly installed. + See the :doc:`guide on GPU configuration ` + for details. + +| **GNA drivers** +| If you want to run inference on a GNA (note that it is currently being deprecated and will no longer + be supported beyond 2023.2), make sure your GPU's drivers are properly installed. See the + :doc:`guide on GNA configuration ` + for details. -* :doc:`Configurations for GPU ` -* :doc:`Configurations for GNA ` @endsphinxdirective diff --git a/docs/install_guides/installing-openvino-apt.md b/docs/install_guides/installing-openvino-apt.md index 004f44f449545f..3ab31f5658b316 100644 --- a/docs/install_guides/installing-openvino-apt.md +++ b/docs/install_guides/installing-openvino-apt.md @@ -1,37 +1,21 @@ # Install Intel® Distribution of OpenVINO™ Toolkit for Linux Using APT Repository {#openvino_docs_install_guides_installing_openvino_apt} - - @sphinxdirective .. meta:: - :description: Learn how to install OpenVINO™ Runtime on Linux operating - system, using the APT repository, which is a recommended - installation method for C++ developers. - - -With the OpenVINO™ 2023.0 release, you can install OpenVINO Runtime on Linux using the APT repository. -OpenVINO™ Development Tools can be installed via PyPI only. -See `Installing Additional Components `__ for more information. - -See the `Release Notes `__ -for more information on updates in the latest release. - -Installing OpenVINO Runtime from APT is recommended for C++ developers. If you are working with Python, -the PyPI package has everything needed for Python development and deployment on CPU and GPUs. Visit the -:doc:`Install OpenVINO from PyPI ` page for instructions -on how to install OpenVINO Runtime for Python using PyPI. + :description: Learn how to install OpenVINO™ Runtime on the Linux operating + system, using the APT repository. -.. warning:: +.. note:: + + Note that the APT distribution: - By downloading and using this container and the included software, you agree to the terms and - conditions of the - `software license agreements `__. + * offers both C++ and Python APIs + * does not offer support for GNA and NPU inference + * additionally includes code samples + * is dedicated to Linux users. -Prerequisites -####################################### - .. tab-set:: .. tab-item:: System Requirements @@ -43,8 +27,8 @@ Prerequisites .. tab-item:: Processor Notes :sync: processor-notes - Processor graphics are not included in all processors. - See `Product Specifications `__ for information about your processor. + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ .. tab-item:: Software Requirements :sync: software-requirements @@ -60,8 +44,6 @@ Installing OpenVINO Runtime Step 1: Set Up the OpenVINO Toolkit APT Repository +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - 1. Install the GPG key for the repository a. Download the `GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB `__ @@ -130,8 +112,8 @@ Step 1: Set Up the OpenVINO Toolkit APT Repository Step 2: Install OpenVINO Runtime Using the APT Package Manager ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -Install OpenVINO Runtime ------------------------- +1. Install OpenVINO Runtime + .. tab-set:: @@ -172,8 +154,7 @@ Install OpenVINO Runtime Keep in mind that the build tools must be installed **separately** if you want to compile the samples. -Check for Installed Packages and Versions ------------------------------------------ +2. Check for Installed Packages and Versions Run the following command: @@ -182,27 +163,14 @@ Run the following command: apt list --installed | grep openvino -Step 3 (Optional): Install Additional Components -++++++++++++++++++++++++++++++++++++++++++++++++ - -OpenVINO Development Tools is a set of utilities for working with OpenVINO and OpenVINO models. -It provides tools like Model Optimizer, Benchmark Tool, Post-Training Optimization Tool, and Open Model Zoo Downloader. -If you installed OpenVINO Runtime using APT, OpenVINO Development Tools must be installed separately. - -See the **For C++ Developers** section on the :doc:`Install OpenVINO Development Tools ` page for instructions. - - -Step 4 (Optional): Configure Inference on Non-CPU Devices -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Congratulations! You've just Installed OpenVINO! For some use cases you may still +need to install additional components. Check the +:doc:`list of additional configurations ` +to see if your case needs any of them. -To enable the toolkit components to use processor graphics (GPU) on your system, follow the steps -in :doc:`GPU Setup Guide `. - - -Step 5: Build Samples -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -To build the C++ or C sample applications for Linux, run the ``build_samples.sh`` script: +With the APT distribution, you can build OpenVINO sample files, as explained in the +:doc:`guide for OpenVINO sample applications `. +For C++ and C, just run the ``build_samples.sh`` script: .. tab-set:: @@ -220,9 +188,6 @@ To build the C++ or C sample applications for Linux, run the ``build_samples.sh` /usr/share/openvino/samples/c/build_samples.sh -For more information, refer to :ref:`Build the Sample Applications on Linux `. - - Uninstalling OpenVINO Runtime ####################################### diff --git a/docs/install_guides/installing-openvino-brew.md b/docs/install_guides/installing-openvino-brew.md index a6d02d79e96930..cee801cce4b22e 100644 --- a/docs/install_guides/installing-openvino-brew.md +++ b/docs/install_guides/installing-openvino-brew.md @@ -4,24 +4,15 @@ .. meta:: :description: Learn how to install OpenVINO™ Runtime on Linux and macOS - operating systems, using Homebrew, which is a recommended - installation method for C++ developers. - + operating systems, using Homebrew. .. note:: + + Note that the `Homebrew `__ distribution: - Installing OpenVINO Runtime from Homebrew is recommended for C++ developers. - If you work with Python, consider :doc:`installing OpenVINO from PyPI ` - -You can use `Homebrew `__ to install OpenVINO Runtime on macOS and Linux. -OpenVINO™ Development Tools can be installed via PyPI only. -See `Installing Additional Components <#optional-installing-additional-components>`__ for more information. - - -.. warning:: - - By downloading and using this container and the included software, you agree to the terms and conditions of the - `software license agreements `_. + * offers both C++ and Python APIs + * does not offer support for GNA and NPU inference + * is dedicated to macOS users. .. tab-set:: @@ -32,6 +23,12 @@ See `Installing Additional Components <#optional-installing-additional-component | Full requirement listing is available in: | `System Requirements Page `__ + .. tab-item:: Processor Notes + :sync: processor-notes + + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ + .. tab-item:: Software Requirements :sync: software-requirements @@ -55,13 +52,12 @@ See `Installing Additional Components <#optional-installing-additional-component * (Optional) Apple Xcode IDE (not required for OpenVINO™, but useful for development) - Installing OpenVINO Runtime ########################### 1. Make sure that you have installed Homebrew on your system. If not, follow the instructions on `the Homebrew website `__ to install and configure it. -2. Open a command prompt terminal window, and run the following command to install OpenVINO Runtime: +2. Run the following command in the terminal: .. code-block:: sh @@ -74,16 +70,12 @@ Installing OpenVINO Runtime brew list -Congratulations, you've finished the installation! - -(Optional) Installing Additional Components -########################################### - -OpenVINO Development Tools is a set of utilities for working with OpenVINO and OpenVINO models. It provides tools like Model Optimizer, Benchmark Tool, Post-Training Optimization Tool, and Open Model Zoo Downloader. If you installed OpenVINO Runtime using Homebrew, OpenVINO Development Tools must be installed separately. +Congratulations! You've just Installed OpenVINO! For some use cases you may still +need to install additional components. Check the +:doc:`list of additional configurations ` +to see if your case needs any of them. -See the **For C++ Developers** section on the :doc:`Install OpenVINO Development Tools ` page for instructions. -OpenCV is necessary to run demos from Open Model Zoo (OMZ). Some OpenVINO samples can also extend their capabilities when compiled with OpenCV as a dependency. To install OpenCV for OpenVINO, see the `instructions on GitHub `__. Uninstalling OpenVINO ##################### diff --git a/docs/install_guides/installing-openvino-conda.md b/docs/install_guides/installing-openvino-conda.md index 571e88c28387ea..79ebe571696303 100644 --- a/docs/install_guides/installing-openvino-conda.md +++ b/docs/install_guides/installing-openvino-conda.md @@ -4,14 +4,17 @@ .. meta:: :description: Learn how to install OpenVINO™ Runtime on Windows, Linux, and - macOS operating systems, using Conda Forge - a recommended - installation method for C++ developers. + macOS operating systems, using Conda Forge. .. note:: + + Note that the Conda Forge distribution: + + * offers both C++ and Python APIs + * does not offer support for GNA and NPU inference + * is dedicated to users of all major OSs: Windows, Linux, macOS. - Installing OpenVINO Runtime from Conda Forge is recommended for C++ developers, as it provides only the C++ Runtime API. - If you work with Python, consider :doc:`installing OpenVINO from PyPI ` .. tab-set:: @@ -21,16 +24,14 @@ | Full requirement listing is available in: | `System Requirements Page `__ - .. comment to publish in the future, when gpu support comes back: - - .. tab-set:: - - .. tab-item:: Processor Notes - :sync: processor-notes - - | Not all Intel CPUs include integrated graphics processors. - | See `Product Specifications `__ for information about your hardware. + + .. tab-item:: Processor Notes + :sync: processor-notes + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ + + .. tab-item:: Software :sync: software @@ -63,10 +64,13 @@ Installing OpenVINO Runtime with Anaconda Package Manager conda install -c conda-forge openvino=2023.0.1 - Congratulations! You have finished installing OpenVINO Runtime. +Congratulations! You've just Installed OpenVINO! For some use cases you may still +need to install additional components. Check the description below, as well as the +:doc:`list of additional configurations ` +to see if your case needs any of them. Compiling with OpenVINO Runtime from Conda-Forge on Linux -########################################################### ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ When linking OpenVINO libraries from Conda on Linux, ensure that you have the necessary Conda compilers installed. To do so, run the following command in your Conda environment: @@ -84,7 +88,9 @@ To reactivate your Conda environment, execute the following command: conda activate py310 -Once you have reactivated your Conda environment, make sure that all the necessary environment variables are properly set and proceed with linking the OpenVINO libraries. +Once you have reactivated your Conda environment, make sure that all the necessary environment +variables are properly set and proceed with linking the OpenVINO libraries. + Uninstalling OpenVINO™ Runtime ########################################################### @@ -115,12 +121,6 @@ Visit the :doc:`Samples ` page for other C * `Automatic speech recognition C++ sample `__ -Additional Resources -########################################################### - -* `OpenVINO Runtime Conda Forge `__ -* :doc:`OpenVINO™ Toolkit Samples Overview ` - @endsphinxdirective diff --git a/docs/install_guides/installing-openvino-from-archive-linux.md b/docs/install_guides/installing-openvino-from-archive-linux.md index 0b047034994695..33aeb246a7a22b 100644 --- a/docs/install_guides/installing-openvino-from-archive-linux.md +++ b/docs/install_guides/installing-openvino-from-archive-linux.md @@ -1,38 +1,54 @@ # Install OpenVINO™ Runtime on Linux from an Archive File {#openvino_docs_install_guides_installing_openvino_from_archive_linux} - @sphinxdirective .. meta:: - :description: Learn how to install OpenVINO™ Runtime on Linux operating - system, using an archive file, which is a recommended - installation method for C++ developers. - + :description: Learn how to install OpenVINO™ Runtime on the Linux operating + system, using an archive file. -Installing OpenVINO Runtime from archive files is recommended for C++ developers. It will contain code samples, -as well as pre-built binaries and library files needed for OpenVINO Runtime. If you work with Python, -the PyPI package may be a better choice. See the :doc:`Install OpenVINO from PyPI ` -page for instructions on how to install OpenVINO Runtime for Python using PyPI. .. note:: + + Note that the Archive distribution: + + * offers both C++ and Python APIs + * additionally includes code samples + * is dedicated to users of all major OSs: Windows, Linux, macOS + * may offer different hardware support under different operating systems + (see the drop-down below for more details). + + .. dropdown:: Inference Options + + =================== ===== ===== ===== ===== ======== ============= ======== ======== + Operating System CPU GPU GNA NPU AUTO Auto-batch HETERO MULTI + =================== ===== ===== ===== ===== ======== ============= ======== ======== + Debian9 armhf V n/a n/a n/a V V V n/a + Debian9 arm64 V n/a n/a n/a V V V n/a + CentOS7 x86_64 V V V n/a V V V V + Ubuntu18 x86_64 V V V n/a V V V V + Ubuntu20 x86_64 V V V V V V V V + Ubuntu22 x86_64 V V V V V V V V + RHEL8 x86_64 V V V n/a V V V V + Windows x86_64 V V V V V V V V + MacOS x86_64 V n/a n/a n/a V V V n/a + MacOS arm64 V n/a n/a n/a V V V n/a + =================== ===== ===== ===== ===== ======== ============= ======== ======== - The following development tools can be installed via `pypi.org `__ only: - model conversion API, Post-Training Optimization Tool, Model Downloader and other Open Model Zoo tools, - Accuracy Checker, and Annotation Converter. -See the `Release Notes `__ for more information on updates in the latest release. .. tab-set:: .. tab-item:: System Requirements :sync: system-requirements - - Full requirement listing is available in `System Requirements Page `__ + + | Full requirement listing is available in: + | `System Requirements Page `__ .. tab-item:: Processor Notes :sync: processor-notes - Processor graphics are not included in all processors. See `Product Specifications `__ for information about your processor. + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ .. tab-item:: Software :sync: software @@ -80,6 +96,9 @@ See the `Release Notes /intel/openvino_2023``. The path to the ``openv also referred as ```` throughout the OpenVINO documentation. + + + Step 2: Configure the Environment ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -237,41 +259,8 @@ If you have more than one OpenVINO version installed on your system, you can eas Next time when you open a terminal, you will see ``[setupvars.sh] OpenVINO™ environment initialized``. Changing ``.bashrc`` is not recommended when you have multiple OpenVINO versions on your machine and want to switch among them. -The environment variables are set. Continue to the next section if you want to download any additional components. - -Step 3 (Optional): Install Additional Components -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -OpenVINO Development Tools is a set of utilities for working with OpenVINO and OpenVINO models. -It provides tools like model conversion API, Benchmark Tool, Post-Training Optimization Tool, and Open Model Zoo Downloader. -If you install OpenVINO Runtime using archive files, OpenVINO Development Tools must be installed separately. - -See the :doc:`Install OpenVINO Development Tools ` -page for step-by-step installation instructions. - -OpenCV is necessary to run demos from Open Model Zoo (OMZ). Some OpenVINO samples can also extend their -capabilities when compiled with OpenCV as a dependency. To install OpenCV for OpenVINO, see the -`instructions on GitHub `__. - -Step 4 (Optional): Configure Inference on Non-CPU Devices -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -OpenVINO Runtime has a plugin architecture that enables you to run inference on multiple devices -without rewriting your code. Supported devices include integrated GPUs, discrete GPUs and GNAs. -See the instructions below to set up OpenVINO on these devices. +The environment variables are set. -.. tab-set:: - - .. tab-item:: GPU - :sync: gpu - - To enable the toolkit components to use processor graphics (GPU) on your system, follow the steps in :ref:`GPU Setup Guide `. - - .. tab-item:: GNA - :sync: gna - - To enable the toolkit components to use Intel® Gaussian & Neural Accelerator (GNA) on your system, follow the steps in :ref:`GNA Setup Guide `. - What's Next? diff --git a/docs/install_guides/installing-openvino-from-archive-macos.md b/docs/install_guides/installing-openvino-from-archive-macos.md index fcbec96e4cdb31..7f0dc4b648c766 100644 --- a/docs/install_guides/installing-openvino-from-archive-macos.md +++ b/docs/install_guides/installing-openvino-from-archive-macos.md @@ -4,18 +4,36 @@ .. meta:: :description: Learn how to install OpenVINO™ Runtime on macOS operating - system, using an archive file, which is a recommended - installation method for C++ developers. + system, using an archive file. -With the OpenVINO™ 2023.0 release, you can download and use archive files to install OpenVINO Runtime. The archive files contain pre-built binaries and library files needed for OpenVINO Runtime, as well as code samples. - -Installing OpenVINO Runtime from archive files is recommended for C++ developers. If you are working with Python, the PyPI package has everything needed for Python development and deployment on CPU and GPUs. Visit the :doc:`Install OpenVINO from PyPI ` page for instructions on how to install OpenVINO Runtime for Python using PyPI. - -See the `Release Notes `__ for more information on updates in the latest release. .. note:: + + Note that the Archive distribution: + + * offers both C++ and Python APIs + * additionally includes code samples + * is dedicated to users of all major OSs: Windows, Linux, macOS + * may offer different hardware support under different operating systems + (see the drop-down below for more details) + + .. dropdown:: Inference Options + + =================== ===== ===== ===== ===== ======== ============= ======== ======== + Operating System CPU GPU GNA NPU AUTO Auto-batch HETERO MULTI + =================== ===== ===== ===== ===== ======== ============= ======== ======== + Debian9 armhf V n/a n/a n/a V V V n/a + Debian9 arm64 V n/a n/a n/a V V V n/a + CentOS7 x86_64 V V V n/a V V V V + Ubuntu18 x86_64 V V V n/a V V V V + Ubuntu20 x86_64 V V V V V V V V + Ubuntu22 x86_64 V V V V V V V V + RHEL8 x86_64 V V V n/a V V V V + Windows x86_64 V V V V V V V V + MacOS x86_64 V n/a n/a n/a V V V n/a + MacOS arm64 V n/a n/a n/a V V V n/a + =================== ===== ===== ===== ===== ======== ============= ======== ======== - Since the OpenVINO™ 2022.1 release, the following development tools: Model Optimizer, Post-Training Optimization Tool, Model Downloader and other Open Model Zoo tools, Accuracy Checker, and Annotation Converter can be installed via `pypi.org `__ only. .. tab-set:: @@ -24,7 +42,7 @@ See the `Release Notes `__ - + .. tab-item:: Software Requirements :sync: software-requirements @@ -108,12 +126,18 @@ Step 1: Install OpenVINO Core Components If you have already installed a previous release of OpenVINO 2023, a symbolic link to the ``openvino_2023`` folder may already exist. Unlink the previous link with ``sudo unlink openvino_2023``, and then re-run the command above. -Congratulations, you finished the installation! The ``/opt/intel/openvino_2023`` folder now contains the core components for OpenVINO. If you used a different path in Step 2, you will find the ``openvino_2023`` folder there. The path to the ``openvino_2023`` directory is also referred as ```` throughout the OpenVINO documentation. +Congratulations, you have finished the installation! The ``/opt/intel/openvino_2023`` folder now contains +the core components for OpenVINO. If you used a different path in Step 2, for example, ``/home//intel/``, +OpenVINO is now in ``/home//intel/openvino_2023``. The path to the ``openvino_2023`` directory is +also referred as ```` throughout the OpenVINO documentation. + Step 2: Configure the Environment +++++++++++++++++++++++++++++++++ -You must update several environment variables before you can compile and run OpenVINO applications. Open a terminal window and run the ``setupvars.sh`` script as shown below to temporarily set your environment variables. If your ```` is not ``/opt/intel/openvino_2023``, use the correct one instead. +You must update several environment variables before you can compile and run OpenVINO applications. Open a terminal window and run the ``setupvars.sh`` +script as shown below to temporarily set your environment variables. If your ```` (the folder you used to install OpenVINO) is not +the default ``/opt/intel/openvino_2023``, use the correct one instead. .. code-block:: sh @@ -127,16 +151,7 @@ If you have more than one OpenVINO™ version on your machine, you can easily sw The above command must be re-run every time you start a new terminal session. To set up macOS to automatically run the command every time a new terminal is opened, open ``~/.zshrc`` in your favorite editor and add ``source /opt/intel/openvino_2023/setupvars.sh`` after the last line. Next time when you open a terminal, you will see ``[setupvars.sh] OpenVINO™ environment initialized``. Changing ``~/.zshrc`` is not recommended when you have multiple OpenVINO versions on your machine and want to switch among them. -The environment variables are set. Continue to the next section if you want to download any additional components. - -Step 3 (Optional): Install Additional Components -++++++++++++++++++++++++++++++++++++++++++++++++ - -OpenVINO Development Tools is a set of utilities for working with OpenVINO and OpenVINO models. It provides tools like Model Optimizer, Benchmark Tool, Post-Training Optimization Tool, and Open Model Zoo Downloader. If you install OpenVINO Runtime using archive files, OpenVINO Development Tools must be installed separately. -See the :doc:`Install OpenVINO Development Tools ` page for step-by-step installation instructions. - -OpenCV is necessary to run demos from Open Model Zoo (OMZ). Some OpenVINO samples can also extend their capabilities when compiled with OpenCV as a dependency. To install OpenCV for OpenVINO, see the `instructions on GitHub `__. What's Next? #################### @@ -201,14 +216,6 @@ Additional Resources * Pre-trained deep learning models: :ref:`Overview of OpenVINO™ Toolkit Pre-Trained Models ` * IoT libraries and code samples in the GitHUB repository: `Intel® IoT Developer Kit `__ - + @endsphinxdirective diff --git a/docs/install_guides/installing-openvino-from-archive-windows.md b/docs/install_guides/installing-openvino-from-archive-windows.md index db1df67ffa0973..535c280e61fad6 100644 --- a/docs/install_guides/installing-openvino-from-archive-windows.md +++ b/docs/install_guides/installing-openvino-from-archive-windows.md @@ -4,20 +4,36 @@ .. meta:: :description: Learn how to install OpenVINO™ Runtime on Windows operating - system, using an archive file, which is a recommended - installation method for C++ developers. + system, using an archive file. -With the OpenVINO™ 2023.0 release, you can download and use archive files to install OpenVINO Runtime. The archive files contain pre-built binaries and library files needed for OpenVINO Runtime, as well as code samples. - -Installing OpenVINO Runtime from archive files is recommended for C++ developers. If you are working with Python, the PyPI package has everything needed for Python development and deployment on CPU and GPUs. See the :doc:`Install OpenVINO from PyPI ` page for instructions on how to install OpenVINO Runtime for Python using PyPI. - .. note:: + + Note that the Archive distribution: + + * offers both C++ and Python APIs + * additionally includes code samples + * is dedicated to users of all major OSs: Windows, Linux, macOS + * may offer different hardware support under different operating systems + (see the drop-down below for more details) + + .. dropdown:: Inference Options + + =================== ===== ===== ===== ===== ======== ============= ======== ======== + Operating System CPU GPU GNA NPU AUTO Auto-batch HETERO MULTI + =================== ===== ===== ===== ===== ======== ============= ======== ======== + Debian9 armhf V n/a n/a n/a V V V n/a + Debian9 arm64 V n/a n/a n/a V V V n/a + CentOS7 x86_64 V V V n/a V V V V + Ubuntu18 x86_64 V V V n/a V V V V + Ubuntu20 x86_64 V V V V V V V V + Ubuntu22 x86_64 V V V V V V V V + RHEL8 x86_64 V V V n/a V V V V + Windows x86_64 V V V V V V V V + MacOS x86_64 V n/a n/a n/a V V V n/a + MacOS arm64 V n/a n/a n/a V V V n/a + =================== ===== ===== ===== ===== ======== ============= ======== ======== - Since the OpenVINO™ 2022.1 release, the following development tools: Model Optimizer, Post-Training Optimization Tool, Model Downloader and other Open Model Zoo tools, Accuracy Checker, and Annotation Converter can be installed via `pypi.org `__ only. - - -See the `Release Notes `__ for more information on updates in the latest release. System Requirements #################### @@ -26,28 +42,26 @@ System Requirements .. tab-item:: System Requirements :sync: system-requirements - + | Full requirement listing is available in: - | `System Requirements Page `_ + | `System Requirements Page `__ .. tab-item:: Processor Notes :sync: processor-notes - Processor graphics are not included in all processors. - See `Product Specifications`_ for information about your processor. - - .. _Product Specifications: https://ark.intel.com/ + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ .. tab-item:: Software :sync: software - * `Microsoft Visual Studio 2019 with MSBuild `_ or `Microsoft Visual Studio 2022 `_ - * `CMake 3.14 or higher, 64-bit `_ (optional, only required for building sample applications) - * `Python 3.7 - 3.11, 64-bit `_ + * `Microsoft Visual Studio 2019 with MSBuild `__ or `Microsoft Visual Studio 2022 `__ + * `CMake 3.14 or higher, 64-bit `__ (optional, only required for building sample applications) + * `Python 3.7 - 3.11, 64-bit `__ .. note:: - To install Microsoft Visual Studio 2019, follow the `Microsoft Visual Studio installation guide `_. You can choose to download the Community version. During installation in the **Workloads** tab, choose **Desktop development with C++**. + To install Microsoft Visual Studio 2019, follow the `Microsoft Visual Studio installation guide `__. You can choose to download the Community version. During installation in the **Workloads** tab, choose **Desktop development with C++**. .. note:: @@ -55,7 +69,7 @@ System Requirements .. important:: - When installing Python, make sure you click the option **Add Python 3.x to PATH** to `add Python `_ to your `PATH` environment variable. + When installing Python, make sure you click the option **Add Python 3.x to PATH** to `add Python `__ to your `PATH` environment variable. @@ -155,43 +169,11 @@ You must update several environment variables before you can compile and run Ope .. note:: - If you see an error indicating Python is not installed, Python may not be added to the PATH environment variable (as described `here `__). Check your system environment variables, and add Python if necessary. - - -The environment variables are set. Continue to the next section if you want to download any additional components. - -.. _model-optimizer-windows: - -Step 3 (Optional): Install Additional Components -++++++++++++++++++++++++++++++++++++++++++++++++ + If you see an error indicating Python is not installed, Python may not be added to the PATH environment variable + (as described `here `__). + Check your system environment variables, and add Python if necessary. -OpenVINO Development Tools is a set of utilities for working with OpenVINO and OpenVINO models. It provides tools like Model Optimizer, Benchmark Tool, Post-Training Optimization Tool, and Open Model Zoo Downloader. If you install OpenVINO Runtime using archive files, OpenVINO Development Tools must be installed separately. - -See the :doc:`Install OpenVINO Development Tools ` page for step-by-step installation instructions. - -OpenCV is necessary to run demos from Open Model Zoo (OMZ). Some OpenVINO samples can also extend their capabilities when compiled with OpenCV as a dependency. To install OpenCV for OpenVINO, see the `instructions on GitHub `__ . - -.. _optional-steps-windows: - -Step 4 (Optional): Configure Inference on non-CPU Devices -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -OpenVINO Runtime has a plugin architecture that enables you to run inference on multiple devices without rewriting your code. Supported devices include integrated GPUs, discrete GPUs and GNAs. See the instructions below to set up OpenVINO on these devices. - -.. tab-set:: - - .. tab-item:: GPU - :sync: gpu - - To enable the toolkit components to use processor graphics (GPU) on your system, follow the steps in :ref:`GPU Setup Guide `. - - .. tab-item:: GNA - :sync: gna - - To enable the toolkit components to use Intel® Gaussian & Neural Accelerator (GNA) on your system, follow the steps in :ref:`GNA Setup Guide `. - -.. _get-started-windows: What's Next? #################### diff --git a/docs/install_guides/installing-openvino-linux-header.md b/docs/install_guides/installing-openvino-linux-header.md index 333bf918c520a2..55660cdb8e7bef 100644 --- a/docs/install_guides/installing-openvino-linux-header.md +++ b/docs/install_guides/installing-openvino-linux-header.md @@ -17,6 +17,7 @@ Use APT Use YUM Use Conda Forge + Use VCPKG Use Homebrew Use Docker diff --git a/docs/install_guides/installing-openvino-macos-header.md b/docs/install_guides/installing-openvino-macos-header.md index 8a8f710e6a7591..89fb89719fc009 100644 --- a/docs/install_guides/installing-openvino-macos-header.md +++ b/docs/install_guides/installing-openvino-macos-header.md @@ -13,9 +13,10 @@ :hidden: From Archive + Using Homebrew From PyPI Using Conda Forge - Using Homebrew + Use VCPKG If you want to install OpenVINO™ Runtime on macOS, there are a few ways to accomplish this. We prepared following options for you: diff --git a/docs/install_guides/installing-openvino-overview.md b/docs/install_guides/installing-openvino-overview.md index 3bba094b70ea1c..2d97d6a410a09e 100644 --- a/docs/install_guides/installing-openvino-overview.md +++ b/docs/install_guides/installing-openvino-overview.md @@ -3,9 +3,8 @@ @sphinxdirective .. meta:: - :description: You can choose to install OpenVINO Runtime package - a core set - of libraries or OpenVINO Development Tools - a set of utilities - for working with OpenVINO. + :description: install OpenVINO Runtime package, using the distribution channel + of your choice. .. toctree:: @@ -14,8 +13,8 @@ OpenVINO Runtime on Linux OpenVINO Runtime on Windows - OpenVINO Runtime on macOS - OpenVINO Development Tools + OpenVINO Runtime on macOS + OpenVINO Development Tools Create a Yocto Image @@ -25,26 +24,42 @@ - -Different OpenVINO distributions may differ with regard to supported hardware or available APIs. -Read installation guides for particular distributions for more details. - -| **OpenVINO Runtime:** -| contains the core set of libraries for running inference on various processing units. It is recommended for users who already have an optimized model - and want to deploy it in an application using OpenVINO for inference on their devices. - -| **OpenVINO Development Tools:** -| includes the OpenVINO Runtime for Python, as well as a set of utilities for optimizing models and validating performance. - It is recommended for users who want to optimize and verify their models before applying them in their applications. - For Python developers it is ready out-of-the-box, while for C++ development you need to install OpenVINO Runtime libraries separately. -| See the :ref:`For C++ Developers ` section of the install guide for detailed instructions. -| Development Tools provides: - * Model conversion API - * Benchmark Tool - * Accuracy Checker and Annotation Converter - * Post-Training Optimization Tool - * Model Downloader and other Open Model Zoo tools - +.. warning:: + + The OpenVINO Development Tools package has been deprecated and removed from the default + installation options. For new projects, the OpenVINO runtime package now includes + all necessary components. + + The OpenVINO Development Tools is still available for older versions of OpenVINO, + as well as the current one, from the GitHub repository. + + +.. tip:: + + OpenVINO 2023.1, described here, is not a Long-Term-Support version! + All currently supported versions are: + + * 2023.1 (development) + * 2022.3 (LTS) + * 2021.4 (LTS) + + Moreover, different OpenVINO distributions may support slightly different sets of features. + Read installation guides for particular distributions for more details. + + .. dropdown:: Distribution Comparison for OpenVINO 2023.1 + + =============== ========== ====== ========= ======== ============ ========== + Device Archives PyPI APT/YUM Conda Homebrew VCPKG + =============== ========== ====== ========= ======== ============ ========== + CPU V V V V V V + GPU V V V V V V + GNA V V V V V V + NPU V V V V V V + Auto V V V V V V + Auto-Batch V V V V V V + Hetero V n/a n/a n/a n/a n/a + Multi V n/a n/a n/a n/a n/a + =============== ========== ====== ========= ======== ============ ========== | **Build OpenVINO from source** | OpenVINO Toolkit source files are available on GitHub as open source. If you want to build your own version of OpenVINO for your platform, @@ -52,6 +67,5 @@ Read installation guides for particular distributions for more details. - @endsphinxdirective diff --git a/docs/install_guides/installing-openvino-pip.md b/docs/install_guides/installing-openvino-pip.md index 00413eeae3d762..8f0c0c6844e0c8 100644 --- a/docs/install_guides/installing-openvino-pip.md +++ b/docs/install_guides/installing-openvino-pip.md @@ -7,27 +7,40 @@ macOS operating systems, using a PyPi package. -Using the PyPI repository, you can install either OpenVINO™ Runtime or OpenVINO Development Tools on Windows, Linux, and macOS systems. -This article focuses on OpenVINO™ Runtime. +.. note:: + + Note that the PyPi distribution: + + * offers the Python API only + * does not offer support for GNA and NPU inference + * is dedicated to users of all major OSs: Windows, Linux, macOS -.. note +.. tab-set:: + + .. tab-item:: System Requirements + :sync: system-requirements - If you install OpenVINO Development Tools, OpenVINO Runtime will also be installed as a dependency, so you don't need to install it separately. + | Full requirement listing is available in: + | `System Requirements Page `__ + | 'PyPi OpenVINO page `__ + + + .. tab-item:: Processor Notes + :sync: processor-notes + + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ Installing OpenVINO Runtime ########################### -For system requirements and troubleshooting, see https://pypi.org/project/openvino/ - Step 1. Set Up Python Virtual Environment +++++++++++++++++++++++++++++++++++++++++ Use a virtual environment to avoid dependency conflicts. - To create a virtual environment, use the following command: - .. tab-set:: .. tab-item:: Windows @@ -100,7 +113,15 @@ Run the command below: python -c "from openvino.runtime import Core; print(Core().available_devices)" -If installation was successful, you will see the list of available devices. Congratulations! You have finished installing OpenVINO Runtime. +If installation was successful, you will see the list of available devices. + + +Congratulations! You've just Installed OpenVINO! For some use cases you may still +need to install additional components. Check the +:doc:`list of additional configurations ` +to see if your case needs any of them. + + What's Next? @@ -122,10 +143,7 @@ Visit the :doc:`Tutorials ` page for more Jupyter Notebooks to get yo * `Basic image classification program with Hello Image Classification `__ * `Convert a PyTorch model and use it for image background removal `__ -Run OpenVINO on accelerated devices -+++++++++++++++++++++++++++++++++++ -OpenVINO Runtime has a plugin architecture that enables you to run inference on multiple devices without rewriting your code. Supported devices include integrated GPUs, discrete GPUs and GNAs. Visit the :doc:`Additional Configurations ` page for instructions on how to configure your hardware devices to work with OpenVINO. Additional Resources #################### diff --git a/docs/install_guides/installing-openvino-vcpkg.md b/docs/install_guides/installing-openvino-vcpkg.md new file mode 100644 index 00000000000000..c5bd022e02b0e9 --- /dev/null +++ b/docs/install_guides/installing-openvino-vcpkg.md @@ -0,0 +1,95 @@ +# Install OpenVINO™ Runtime via VCPKG {#openvino_docs_install_guides_installing_openvino_vcpkg} + +@sphinxdirective + +.. meta:: + :description: Learn how to install OpenVINO™ Runtime on Windows, Linux, and macOS + operating systems, using VCPKG. + +.. note:: + + Note that the VCPKG distribution: + + * offers C++ API only + * does not offer support for GNA and NPU inference + * is dedicated to users of all major OSs: Windows, Linux, macOS. + * may offer different hardware support under different operating systems. + +.. tab-set:: + + .. tab-item:: System Requirements + :sync: system-requirements + + | Full requirement listing is available in: + | `System Requirements Page `__ + + .. tab-item:: Processor Notes + :sync: processor-notes + + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ + + .. tab-item:: Software Requirements + :sync: software-requirements + + * `vcpkg `__ + + + +Installing OpenVINO Runtime +########################### + +1. Make sure that you have installed VCPKG on your system. If not, follow the + `VCPKG installation instructions `__. + + +2. Install OpenVINO using the following terminal command: + + .. code-block:: sh + + vcpkg install openvino + + VCPKG also enables you to install only selected components, by specifying them in the command. + See the list of `available features `__, for example: + + .. code-block:: sh + + vcpkg install openvino[cpu,ir] + +Note that the VCPKG installation means building all packages and dependencies from source, +which means the compiler stage will require additional time to complete the process. + + +Congratulations! You've just Installed OpenVINO! For some use cases you may still +need to install additional components. Check the +:doc:`list of additional configurations ` +to see if your case needs any of them. + + + + +Uninstalling OpenVINO +##################### + +To uninstall OpenVINO via VCPKG, use the following command: + +.. code-block:: sh + + vcpkg uninstall openvino + + +What's Next? +#################### + +Now that you've installed OpenVINO Runtime, you can try the following things: + +* Learn more about :doc:`OpenVINO Workflow `. +* To prepare your models for working with OpenVINO, see :doc:`Model Preparation `. +* See pre-trained deep learning models in our :doc:`Open Model Zoo `. +* Learn more about :doc:`Inference with OpenVINO Runtime `. +* See sample applications in :doc:`OpenVINO toolkit Samples Overview `. +* Check out the OpenVINO product home page: https://software.intel.com/en-us/openvino-toolkit. + + + +@endsphinxdirective diff --git a/docs/install_guides/installing-openvino-windows-header.md b/docs/install_guides/installing-openvino-windows-header.md index deedd11394d8a2..e2c9b5cf10b145 100644 --- a/docs/install_guides/installing-openvino-windows-header.md +++ b/docs/install_guides/installing-openvino-windows-header.md @@ -15,9 +15,11 @@ Use Archive Use PyPI Use Conda Forge + Use VCPKG Use Docker + If you want to install OpenVINO™ Runtime on Windows, you have the following options: * :doc:`Install OpenVINO Runtime from an Archive File ` diff --git a/docs/install_guides/installing-openvino-yocto.md b/docs/install_guides/installing-openvino-yocto.md index 4c304e69fc51ba..5410c724003501 100644 --- a/docs/install_guides/installing-openvino-yocto.md +++ b/docs/install_guides/installing-openvino-yocto.md @@ -8,9 +8,6 @@ This document provides instructions for creating a Yocto image with Intel® Distribution of OpenVINO™ toolkit. -System Requirements -################### - Follow the `Yocto Project official documentation `__ to set up and configure your host machine to be compatible with BitBake. Step 1: Set Up Environment diff --git a/docs/install_guides/installing-openvino-yum.md b/docs/install_guides/installing-openvino-yum.md index 6dfa0dad7318a4..1f756833c6e588 100644 --- a/docs/install_guides/installing-openvino-yum.md +++ b/docs/install_guides/installing-openvino-yum.md @@ -1,35 +1,19 @@ # Install OpenVINO™ Runtime on Linux From YUM Repository {#openvino_docs_install_guides_installing_openvino_yum} - - @sphinxdirective .. meta:: :description: Learn how to install OpenVINO™ Runtime on Linux operating - system, using the YUM repository, which is a recommended - installation method for C++ developers. - - -With the OpenVINO™ 2023.0 release, you can install OpenVINO Runtime on Linux using the YUM repository. -OpenVINO™ Development Tools can be installed via PyPI only. See -`Installing Additional Components <#step-3-optional-install-additional-components>`__ for more information. - -See the `Release Notes `__ -for more information on updates in the latest release. + system, using the YUM repository. -Installing OpenVINO Runtime from YUM is recommended for C++ developers. If you are working with Python, -the PyPI package has everything needed for Python development and deployment on CPU and GPUs. Visit the -:doc:`Install OpenVINO from PyPI ` -page for instructions on how to install OpenVINO Runtime for Python using PyPI. - -.. warning:: - - By downloading and using this container and the included software, you agree to the terms and conditions of the - `software license agreements `__. - - -Prerequisites -############# +.. note:: + + Note that the YUM distribution: + + * offers both C++ and Python APIs + * does not offer support for GNA and NPU inference + * additionally includes code samples + * is dedicated to Linux users. .. tab-set:: @@ -46,8 +30,8 @@ Prerequisites .. tab-item:: Processor Notes :sync: processor-notes - Processor graphics are not included in all processors. - See `Product Specifications `__ for information about your processor. + | To see if your processor includes the integrated graphics technology and supports iGPU inference, refer to: + | `Product Specifications `__ .. tab-item:: Software :sync: software @@ -146,27 +130,15 @@ Run the following command: yum list installed 'openvino*' -Step 3 (Optional): Install Additional Components -+++++++++++++++++++++++++++++++++++++++++++++++++ - -OpenVINO Development Tools is a set of utilities for working with OpenVINO and OpenVINO models. -It provides tools like Model Optimizer, Benchmark Tool, Post-Training Optimization Tool, and -Open Model Zoo Downloader. If you installed OpenVINO Runtime using YUM, OpenVINO Development -Tools must be installed separately. - -See **For C++ Developers** section on the :doc:`Install OpenVINO Development Tools ` page for instructions. - -Step 4 (Optional): Configure Inference on Non-CPU Devices -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Congratulations! You've just Installed OpenVINO! For some use cases you may still +need to install additional components. Check the +:doc:`list of additional configurations ` +to see if your case needs any of them. -To enable the toolkit components to use processor graphics (GPU) on your system, follow the steps in -:doc:`GPU Setup Guide `. - -Step 5: Build Samples -++++++++++++++++++++++ - -To build the C++ or C sample applications for Linux, run the ``build_samples.sh`` script: +With the YUM distribution, you can build OpenVINO sample files, as explained in the +:doc:`guide for OpenVINO sample applications `. +For C++ and C, just run the ``build_samples.sh`` script: .. tab-set:: @@ -185,8 +157,6 @@ To build the C++ or C sample applications for Linux, run the ``build_samples.sh` /usr/share/openvino/samples/c/build_samples.sh -For more information, refer to :doc:`Build the Sample Applications on Linux `. - Uninstalling OpenVINO Runtime ############################## @@ -245,8 +215,6 @@ You can also try the following things: * Take a glance at the OpenVINO product home page: https://software.intel.com/en-us/openvino-toolkit. - - @endsphinxdirective diff --git a/docs/install_guides/troubleshooting.md b/docs/install_guides/troubleshooting.md index 1343ea1b1ecc18..e1a6d03be41216 100644 --- a/docs/install_guides/troubleshooting.md +++ b/docs/install_guides/troubleshooting.md @@ -51,7 +51,7 @@ This guide provides general troubleshooting steps and solutions to possible issu If you met proxy issues during the installation with Docker, you need set up proxy settings for Docker. See the `Docker guide `__ for more details. - .. _yocto_install_issues: +.. _yocto_install_issues: .. dropdown:: Issues with Creating a Yocto Image for OpenVINO @@ -170,12 +170,5 @@ This guide provides general troubleshooting steps and solutions to possible issu For specific issues, see :ref:`Errors with Installing via PIP for Users in China ` and :ref:`proxy issues with installing OpenVINO on Linux from Docker `. -.. dropdown:: Check if required external dependencies are installed (for pre-2022.2 releases) - - For OpenVINO releases prior to 2022.2: - - - If you are using Ubuntu or RHEL 8 systems, and installed OpenVINO Runtime via the archive file, APT, or YUM repository, and then decided to :doc:`install OpenVINO Development Tools `, make sure that you **Install External Software Dependencies** first by following the steps in the corresponding installation pages. - - - For C++ developers with Windows systems, make sure that Microsoft Visual Studio 2019 with MSBuild and CMake 3.14 or higher (64-bit) are installed. While installing Microsoft Visual Studio 2019, make sure that you have selected **Desktop development with C++** in the **Workloads** tab. If not, launch the installer again to select that option. For more information on modifying the installation options for Microsoft Visual Studio, see its `official support page `__ . @endsphinxdirective \ No newline at end of file diff --git a/docs/notebooks-installation.md b/docs/notebooks-installation.md index 113b2f76eb4851..52fd608e8f1804 100644 --- a/docs/notebooks-installation.md +++ b/docs/notebooks-installation.md @@ -3,35 +3,25 @@ @sphinxdirective -.. _notebooks installation: - .. meta:: :description: An installation guide for Jupyter notebooks on which Python tutorials run. The tutorials serve as introduction to the OpenVINO™ toolkit. -The notebooks run almost anywhere, from browsers and desktops to even a cloud VM or a Docker container. -Follow the guide below in order to run and manage the notebooks on your machine. +The notebooks can be run in various environments. This guide will show you +how to run and manage them on your local system. --------------------- Contents: -- `Installation Guide <#-installation-guide>`__ -- `Run the Notebooks <#-run-the-notebooks>`__ -- `Manage the notebooks <#-manage-the-notebooks>`__ -- `Troubleshooting <#-troubleshooting>`__ -- `FAQ <#-faq>`__ - --------------------- - -.. raw:: html +- `Installation Guide <#installation-guide>`__ +- `Run the Notebooks <#run-the-notebooks>`__ +- `Manage the notebooks <#manage-the-notebooks>`__ +- `Troubleshooting <#troubleshooting>`__ - - -`Installation Guide`_ -===================== +Installation Guide +################## The table below lists the supported operating systems and Python versions. @@ -57,8 +47,8 @@ The table below lists the supported operating systems and Python versions. OpenVINO Notebooks also require Git. Follow the guide below for your operating system or environment. -`Installing prerequisites`_ ----------------------------- +Installing prerequisites ++++++++++++++++++++++++++++ .. tab-set:: @@ -258,8 +248,8 @@ operating system or environment. CMD /tmp/scripts/run -`Installing notebooks`_ ------------------------- +Installing notebooks +++++++++++++++++++++ .. tab-set:: @@ -469,8 +459,8 @@ operating system or environment. 4. **Start the browser** - Copy the URL printed in the terminal window and open in a browser. |br| - If it is a remote machine, replace 127.0.0.1 with the correct IP address. + | Copy the URL printed in the terminal window and open in a browser. + | If it is a remote machine, replace 127.0.0.1 with the correct IP address. |docker-terminal-1| @@ -483,18 +473,11 @@ operating system or environment. While running the container on Windows and macOS, only CPU devices can be used. To access the iGPU, install the notebooks locally, following the instructions above. --------------------- - -.. raw:: html - - - - -`Run the Notebooks`_ -==================== +Run the Notebooks +################# Launch a Single Notebook ------------------------------- +++++++++++++++++++++++++ If you want to launch only one notebook, such as the *Monodepth* notebook, run the command below. @@ -503,7 +486,7 @@ If you want to launch only one notebook, such as the *Monodepth* notebook, run t jupyter lab notebooks/201-vision-monodepth/201-vision-monodepth.ipynb Launch All Notebooks --------------------------- +++++++++++++++++++++ .. code:: bash @@ -514,23 +497,17 @@ In your browser, select a notebook from the file browser in Jupyter Lab, using t |launch-jupyter| --------------------- - -.. raw:: html - - - -`Manage the Notebooks`_ -======================== +Manage the Notebooks +#################### Shut Down Jupyter Kernel ---------------------------- +++++++++++++++++++++++++ To end your Jupyter session, press ``Ctrl-c``. This will prompt you to ``Shutdown this Jupyter server (y/[n])?`` enter ``y`` and hit ``Enter``. Deactivate Virtual Environment ------------------------------------- +++++++++++++++++++++++++++++++ First, make sure you use the terminal window where you activated ``openvino_env``. To deactivate your ``virtualenv``, simply run: @@ -541,7 +518,7 @@ First, make sure you use the terminal window where you activated ``openvino_env` This will deactivate your virtual environment. Reactivate Virtual Environment ------------------------------------- +++++++++++++++++++++++++++++++ To reactivate your environment, run: @@ -572,7 +549,7 @@ To reactivate your environment, run: Then type ``jupyter lab`` or ``jupyter notebook`` to launch the notebooks again. Delete Virtual Environment -------------------------------------- +++++++++++++++++++++++++++ This operation is optional. However, if you want to remove your virtual environment, simply delete the ``openvino_env`` directory: @@ -601,7 +578,7 @@ This operation is optional. However, if you want to remove your virtual environm Remove openvino_env Kernel from Jupyter -------------------------------------------- ++++++++++++++++++++++++++++++++++++++++ .. code:: bash @@ -611,65 +588,25 @@ Remove openvino_env Kernel from Jupyter If you run into issues, check the `Troubleshooting <#-troubleshooting>`__, and `FAQs <#-faq>`__ sections or start a GitHub `discussion `__. -------------------- - -.. raw:: html - - -`Troubleshooting`_ -==================== +Troubleshooting +############### -- To check some common installation problems, run - ``python check_install.py``. This script is located in the - openvino_notebooks directory. Run it after activating the - ``openvino_env`` virtual environment. -- If you get an ``ImportError``, doublecheck that you installed the - Jupyter kernel. If necessary, choose the ``openvino_env`` kernel from the - *Kernel->Change Kernel* menu) in Jupyter Lab or Jupyter Notebook -- If OpenVINO is installed globally, do not run installation commands - in a terminal where ``setupvars.bat`` or ``setupvars.sh`` are sourced. -- For Windows installation, it is recommended to use *Command Prompt - (cmd.exe)*, not *PowerShell*. +For solutions to common issues during installation, refer to the `Troubleshooting `__ and +`FAQ `__ sections in `openvino_notebooks `__ repository. -If the following tips do not solve your problem, feel free to open a `discussion -topic `__ +If the above tips do not solve your problem, feel free to open a +`discussion topic `__ or create an -`issue `__! on Github. - -.. raw:: html - - +`issue `__ on Github. -`FAQ`_ -======== - -- :doc:`Which devices does OpenVINO support? ` -- `What is the first CPU generation that OpenVINO supports? `__ -- `Are there any success stories about deploying real-world solutions with OpenVINO? `__ - --------------- - -`Additional Resources`_ -------------------------- +Additional Resources +#################### * `OpenVINO™ Notebooks - Github Repository `_ -* :doc:`Install OpenVINO™ Development Tools ` - - -.. |br| raw:: html -
.. |launch-jupyter| image:: https://user-images.githubusercontent.com/15709723/120527271-006fd200-c38f-11eb-9935-2d36d50bab9f.gif -.. |Apache License Version 2.0| image:: https://img.shields.io/badge/license-Apache_2.0-green.svg - :target: https://github.com/openvinotoolkit/openvino_notebooks/blob/main/LICENSE -.. |nbval| image:: https://github.com/openvinotoolkit/openvino_notebooks/actions/workflows/nbval.yml/badge.svg - :target: https://github.com/openvinotoolkit/openvino_notebooks/actions/workflows/nbval.yml?query=branch%3Amain -.. |nbval-docker| image:: https://github.com/openvinotoolkit/openvino_notebooks/actions/workflows/docker.yml/badge.svg - :target: https://github.com/openvinotoolkit/openvino_notebooks/actions/workflows/nbval.yml?query=branch%3Amain -.. |binder logo| image:: https://mybinder.org/badge_logo.svg - :alt: Binder button .. |ml-studio-1| image:: https://user-images.githubusercontent.com/15709723/117559437-17463180-b03a-11eb-9e8d-d4539d1502f2.png From bacb83f8a276c37105f5ca0c9adb3b8638a6f02f Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Wed, 6 Sep 2023 19:28:22 +0200 Subject: [PATCH 26/31] Support aten::tile op (#19645) --- src/frontends/pytorch/src/op_table.cpp | 1 + tests/layer_tests/pytorch_tests/test_tile.py | 33 ++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/layer_tests/pytorch_tests/test_tile.py diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp index 244b8fd804a1e1..67bee51301868e 100644 --- a/src/frontends/pytorch/src/op_table.cpp +++ b/src/frontends/pytorch/src/op_table.cpp @@ -435,6 +435,7 @@ const std::map get_supported_ops_ts() { {"aten::tanh", op::translate_1to1_match_1_inputs_with_fp32_type_alignment}, {"aten::tanh_", op::inplace_op>}, {"aten::tensor", op::translate_as_tensor}, + {"aten::tile", op::translate_1to1_match_2_inputs}, {"aten::to", op::translate_to}, {"aten::topk", op::translate_topk}, {"aten::transpose", op::quantizable_op}, diff --git a/tests/layer_tests/pytorch_tests/test_tile.py b/tests/layer_tests/pytorch_tests/test_tile.py new file mode 100644 index 00000000000000..d0223b95a7147c --- /dev/null +++ b/tests/layer_tests/pytorch_tests/test_tile.py @@ -0,0 +1,33 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from pytorch_layer_test_class import PytorchLayerTest + + +class TestTile(PytorchLayerTest): + def _prepare_input(self): + import numpy as np + return (np.random.randn(1, 3, 224, 224).astype(np.float32),) + + def create_model(self, dims): + import torch + + class aten_tile(torch.nn.Module): + def __init__(self, dims): + super(aten_tile, self).__init__() + self.dims = dims + + def forward(self, x): + return torch.tile(x, self.dims) + + ref_net = None + + return aten_tile(dims), ref_net, "aten::tile" + + @pytest.mark.nightly + @pytest.mark.precommit + @pytest.mark.parametrize("dims", [(2, 2), (1, 1), (1, 2, 3, 4)]) + def test_tile(self, dims, ie_device, precision, ir_version): + self._test(*self.create_model(dims), ie_device, precision, ir_version) From cb479f4a5d1a97d127727086917cc013e7840ce1 Mon Sep 17 00:00:00 2001 From: David Nam Date: Thu, 7 Sep 2023 03:43:51 +0900 Subject: [PATCH 27/31] [GPU] No need to add reorder after strided_slice (#19411) --- .../intel_gpu/src/graph/layout_optimizer.cpp | 6 +- .../tests/unit/passes/reorder_inputs_test.cpp | 64 +++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp index d8193844598052..d5b762b7d2160a 100644 --- a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp +++ b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp @@ -14,6 +14,7 @@ #include "arg_max_min_inst.h" #include "shape_of_inst.h" #include "condition_inst.h" +#include "strided_slice_inst.h" #include #include "gemm_inst.h" @@ -234,8 +235,9 @@ bool layout_optimizer::can_fuse_reorder(program_node& prev, program_node& next, } } - // Ref kernels are the main for depth_to_space and region_yolo. It can do anything. - if (next.is_type() || next.is_type()) + // Ref kernels are the main for depth_to_space and region_yolo and strided_slice. It can do anything. + if (next.is_type() || next.is_type() || + (next.is_type() && next.get_preferred_impl_type() != cldnn::impl_types::cpu)) return true; if (next.is_type()) diff --git a/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp b/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp index 62211a9fb6deaf..a6efbbc98a5de3 100644 --- a/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp @@ -15,6 +15,10 @@ #include "gather_inst.h" #include "border_inst.h" #include "reshape_inst.h" +#include "strided_slice_inst.h" +#include "batch_to_space_inst.h" +#include "permute_inst.h" +#include "concatenation_inst.h" #include "pass_manager.h" #include "to_string_utils.h" @@ -297,6 +301,66 @@ TEST(reorder_inputs, no_add_reorder_infront_of_reshape) { ASSERT_EQ(reshape_layout_out.get_partial_shape(), expected_out_shape); } +TEST(reorder_inputs, no_need_of_reorder_for_strided_slice) { + tests::random_generator rg(GET_SUITE_NAME); + auto& engine = get_test_engine(); + auto in_layout1 = layout{ ov::PartialShape{1080, 1920, 1, 2}, data_types::f32, format::bfyx }; + auto in_layout2 = layout{ ov::PartialShape{4, 540, 960, 1, 1}, data_types::f32, format::bfzyx }; + auto data_1 = engine.allocate_memory({ov::PartialShape{5}, data_types::i32, format::bfyx}); + auto data_2 = engine.allocate_memory({ov::PartialShape{5}, data_types::i32, format::bfyx}); + auto data_3 = engine.allocate_memory({ov::PartialShape{5}, data_types::i32, format::bfyx}); + + topology topology( + input_layout("input1", in_layout1), + input_layout("input2", in_layout2), + permute("permute1", input_info("input1"), {0, 1, 2, 3}), + batch_to_space("batch_to_space1", + input_info("input2"), + tensor{1, 1, 4, 1, 1}, + tensor{0, 0, 1, 0, 0}, + tensor{0, 0, 1, 0, 0}, + tensor{1, 1080, 1920, 1, 2}), + batch_to_space("batch_to_space2", + input_info("input2"), + tensor{1, 1, 4, 1, 1}, + tensor{0, 0, 1, 0, 0}, + tensor{0, 0, 1, 0, 0}, + tensor{1, 1080, 1920, 1, 2}), + data("data_1", data_1), + data("data_2", data_2), + data("data_3", data_3), + strided_slice("strided_slice1", + input_info("batch_to_space1"), + input_info("data_1"), + input_info("data_2"), + input_info("data_3"), + {}, {}, {}, {}, {}, {1080, 1920, 1, 2}), + strided_slice("strided_slice2", + input_info("batch_to_space2"), + input_info("data_1"), + input_info("data_2"), + input_info("data_3"), + {}, {}, {}, {}, {}, {1080, 1920, 1, 2}), + concatenation("concat", {input_info("permute1"), input_info("strided_slice1"), input_info("strided_slice2")}, 2), + permute("result", input_info("concat"), {3, 0, 1, 2}) + ); + + ExecutionConfig config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::optimize_data(true)); + + auto program = program::build_program(engine, topology, config, false, true); + layout_optimizer lo(true); + reorder_factory rf; + program_wrapper::apply_opt_pass(*program, lo, rf); + + ASSERT_NE(program, nullptr); + + auto& result = program->get_node("result"); + auto in_order = format::get_default_format(result.get_input_layout(0).get_rank()).order(); + auto out_shape = result.get_output_layout(0).get_shape(); + ASSERT_EQ(in_order.size(), out_shape.size()); +} + // TODO Not yet implemented //TEST(reorder_inputs, impl_forcing_conv_format_kernel) { // auto& engine = get_test_engine(); From 63a6d4c41edbd548d72a3a5c5fe7eb92f250157a Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Thu, 7 Sep 2023 00:51:31 +0400 Subject: [PATCH 28/31] [TF Hub][GA] Set correct scheduler and model scope for regular validation (#19658) * [TF Hub][GA] Set correct scheduler and model scope for regular validation Signed-off-by: Kazantsev, Roman * Remove empty line * Update .github/workflows/linux.yml Co-authored-by: Andrey Kashchikhin * Correct a path to output html report --------- Signed-off-by: Kazantsev, Roman Co-authored-by: Andrey Kashchikhin --- .github/workflows/linux.yml | 6 +++--- tests/model_hub_tests/tf_hub_tests/nightly_models | 2 +- tests/model_hub_tests/tf_hub_tests/nightly_models_tmp | 2 -- .../tf_hub_tests/test_tf_hub_convert_model.py | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 tests/model_hub_tests/tf_hub_tests/nightly_models_tmp diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 527ee86daebae0..0a5a5ecf539bc0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,8 +1,8 @@ name: Tests on Linux (Ubuntu 22.04, Python 3.11) on: schedule: - # - cron: '0 20/72 * * *' - - cron: '10 * * * *' + # at 00:00 on Wednesday and Saturday + - cron: '0 0 * * 3,6' workflow_dispatch: pull_request: paths-ignore: @@ -677,7 +677,7 @@ jobs: source ${{ env.INSTALL_DIR }}/setupvars.sh - python3 -m pytest ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/tf_hub_tests/ -m ${{ env.TYPE }} --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_hub_tf_fe.xml --html TEST-tf_hub_tf_fe.html --self-contained-html + python3 -m pytest ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/tf_hub_tests/ -m ${{ env.TYPE }} --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_hub_tf_fe.xml --html=${{ env.INSTALL_TEST_DIR }}/TEST-tf_hub_tf_fe.html --self-contained-html env: TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}} TEST_DEVICE: CPU diff --git a/tests/model_hub_tests/tf_hub_tests/nightly_models b/tests/model_hub_tests/tf_hub_tests/nightly_models index 074ee20fcc0a9c..344289abc5a5fe 100644 --- a/tests/model_hub_tests/tf_hub_tests/nightly_models +++ b/tests/model_hub_tests/tf_hub_tests/nightly_models @@ -686,4 +686,4 @@ imagenet/efficientnet_v2_imagenet21k_b2/classification,https://tfhub.dev/google/ vgg19-block2-conv2-unpooling-decoder,https://tfhub.dev/emilutz/vgg19-block2-conv2-unpooling-decoder/1?tf-hub-format=compressed faster_rcnn/resnet50_v1_1024x1024,https://tfhub.dev/tensorflow/faster_rcnn/resnet50_v1_1024x1024/1?tf-hub-format=compressed Wiki-words-500-with-normalization,https://tfhub.dev/google/Wiki-words-500-with-normalization/2?tf-hub-format=compressed -wiki40b-lm-zh-tw,https://tfhub.dev/google/wiki40b-lm-zh-tw/1?tf-hub-format=compressed +wiki40b-lm-zh-tw,https://tfhub.dev/google/wiki40b-lm-zh-tw/1?tf-hub-format=compressed \ No newline at end of file diff --git a/tests/model_hub_tests/tf_hub_tests/nightly_models_tmp b/tests/model_hub_tests/tf_hub_tests/nightly_models_tmp deleted file mode 100644 index 6233759b6afb30..00000000000000 --- a/tests/model_hub_tests/tf_hub_tests/nightly_models_tmp +++ /dev/null @@ -1,2 +0,0 @@ -vision/embedder/fungi_V2,https://tfhub.dev/svampeatlas/vision/embedder/fungi_V2/1?tf-hub-format=compressed -universal-sentence-encoder,https://tfhub.dev/google/universal-sentence-encoder/4?tf-hub-format=compressed \ No newline at end of file diff --git a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py index c5cb9fb3b2f3dd..2640e8214e9044 100644 --- a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py +++ b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py @@ -106,7 +106,7 @@ def test_convert_model_precommit(self, model_name, model_link, mark, reason, ie_ self.run(model_name, model_link, ie_device) @pytest.mark.parametrize("model_name,model_link,mark,reason", - get_models_list(os.path.join(os.path.dirname(__file__), "nightly_models_tmp"))) + get_models_list(os.path.join(os.path.dirname(__file__), "nightly_models"))) @pytest.mark.nightly def test_convert_model_all_models(self, model_name, model_link, mark, reason, ie_device): assert mark is None or mark == 'skip', "Incorrect test case: {}, {}".format(model_name, model_link) From 14e0b1fd2c66d9e7a5fd93e3836bde30beadf554 Mon Sep 17 00:00:00 2001 From: yanlan song Date: Thu, 7 Sep 2023 11:47:45 +0800 Subject: [PATCH 29/31] Do not clean batch setting if proxy plugin (#19508) * do not clean batch setting if proxy plugin Signed-off-by: fishbell * add tests Signed-off-by: fishbell --------- Signed-off-by: fishbell --- src/inference/src/dev/core_impl.cpp | 7 ++-- .../proxy/tests/batch_compliance_test.cpp | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/plugins/proxy/tests/batch_compliance_test.cpp diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp index c0a99d0fbb723d..462a0b9f7cc5ae 100644 --- a/src/inference/src/dev/core_impl.cpp +++ b/src/inference/src/dev/core_impl.cpp @@ -743,7 +743,7 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::shared_ptr< // if auto-batching is applicable, the below function will patch the device name and config accordingly: auto model = apply_auto_batching(model_, deviceName, config_with_batch); - auto parsed = parseDeviceNameIntoConfig(deviceName, config_with_batch); + auto parsed = parseDeviceNameIntoConfig(deviceName, config_with_batch, is_proxy_device(device_name)); auto plugin = get_plugin(parsed._deviceName); ov::SoPtr res; auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager; @@ -776,7 +776,7 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::shared_ptr< // if auto-batching is applicable, the below function will patch the device name and config accordingly: auto model = apply_auto_batching(model_, deviceName, config_with_batch); - auto parsed = parseDeviceNameIntoConfig(deviceName, config_with_batch); + auto parsed = parseDeviceNameIntoConfig(deviceName, config_with_batch, is_proxy_device(deviceName)); auto plugin = get_plugin(parsed._deviceName); ov::SoPtr res; auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager; @@ -1095,8 +1095,9 @@ std::shared_ptr ov::CoreImpl::apply_auto_batching(const std::sh const auto disabled = batch_mode->second.as() == CONFIG_VALUE(NO); // virtual plugins like AUTO/MULTI will need the config // e.g. to deduce the #requests correctly + // proxy plugin should also keep the config // otherwise, no need for this config key in the rest of loading - if (!is_virtual_device(deviceName)) + if (!is_virtual_device(deviceName) && !is_proxy_device(deviceName)) config.erase(batch_mode); if (disabled) return model; diff --git a/src/plugins/proxy/tests/batch_compliance_test.cpp b/src/plugins/proxy/tests/batch_compliance_test.cpp new file mode 100644 index 00000000000000..73cf894291f6cd --- /dev/null +++ b/src/plugins/proxy/tests/batch_compliance_test.cpp @@ -0,0 +1,34 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/proxy/properties.hpp" +#include "openvino/runtime/properties.hpp" +#include "proxy_tests.hpp" + +using namespace ov::proxy::tests; + +TEST_F(ProxyTests, can_parse_and_inherit_batch_property) { + register_plugin_support_reshape(core, "MOCK_DEVICE", {{ov::proxy::configuration::alias.name(), "ALIAS_MOCK"}}); + auto available_devices = core.get_available_devices(); + auto model = create_model_with_add(); + auto compiled_model_default = core.compile_model(model, "MOCK_DEVICE", ov::hint::performance_mode("THROUGHPUT")); +#ifdef ENABLE_AUTO_BATCH + EXPECT_NO_THROW(compiled_model_default.get_property(ov::auto_batch_timeout)); // batch enabled by default + EXPECT_EQ(compiled_model_default.get_property(ov::auto_batch_timeout), 1000); // default value +#endif + auto compiled_model_with_batch = core.compile_model(model, + "MOCK_DEVICE", + ov::hint::performance_mode("THROUGHPUT"), + ov::hint::allow_auto_batching(true), + ov::auto_batch_timeout(8)); +#ifdef ENABLE_AUTO_BATCH + EXPECT_NO_THROW(compiled_model_with_batch.get_property(ov::auto_batch_timeout)); + EXPECT_EQ(compiled_model_with_batch.get_property(ov::auto_batch_timeout), 8); +#endif + auto compiled_model_no_batch = core.compile_model(model, + "MOCK_DEVICE", + ov::hint::performance_mode("THROUGHPUT"), + ov::hint::allow_auto_batching(false)); + EXPECT_ANY_THROW(compiled_model_no_batch.get_property(ov::auto_batch_timeout)); +} \ No newline at end of file From 252afa3b6cd1a4b93c53c5a13709921970425c6d Mon Sep 17 00:00:00 2001 From: River Li Date: Thu, 7 Sep 2023 13:09:16 +0800 Subject: [PATCH 30/31] [CPU] Fix incorrect output for float to bf16 in avx2 isa (#19358) --- .../src/emitters/x64/jit_bf16_emitters.hpp | 1 + .../intel_cpu/tests/unit/jit_kernel_test.cpp | 35 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_bf16_emitters.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_bf16_emitters.hpp index 88a8d0772e2772..1a1e4c1d05548f 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_bf16_emitters.hpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_bf16_emitters.hpp @@ -75,6 +75,7 @@ class jit_uni_vcvtneps2bf16 : public jit_emitter { h->uni_vpackusdw(aux, aux, aux); if (host_isa_ == dnnl::impl::cpu::x64::cpu_isa_t::avx2) { + h->vpermq(Ymm(aux.getIdx()), Ymm(aux.getIdx()), 0xD8); //11 01 10 00 h->vextracti128(out, Ymm(aux.getIdx()), 0); } else { h->uni_vmovups(out, aux); diff --git a/src/plugins/intel_cpu/tests/unit/jit_kernel_test.cpp b/src/plugins/intel_cpu/tests/unit/jit_kernel_test.cpp index 53576c629bcfe4..a851e0b4c5948a 100644 --- a/src/plugins/intel_cpu/tests/unit/jit_kernel_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/jit_kernel_test.cpp @@ -272,20 +272,19 @@ struct jit_variable_load_store_test_kernel { size_t size; }; - template + template void test() { kernel_impl kernel; kernel.init(); - - const size_t size = 3; + ASSERT_GE(N, M); std::array src {}; std::array result {}; - Params args = { src.data(), result.data(), size }; + Params args = { src.data(), result.data(), M }; src.fill(static_cast(42)); - for (size_t i = 0; i < size; ++i) { + for (size_t i = 0; i < M; ++i) { src[i] = static_cast(i); } @@ -293,7 +292,7 @@ struct jit_variable_load_store_test_kernel { std::array expected_result {}; - for (size_t i = 0; i < size; ++i) { + for (size_t i = 0; i < M; ++i) { expected_result[i] = static_cast(i); } @@ -325,52 +324,52 @@ TEST(JitKernel, variable_load_and_store) { { jit_variable_load_store_test_kernel kernel; if (mayiuse(cpu_isa_t::avx512_core)) { - kernel.test<16, false>(); + kernel.test<16, 11, false>(); } if (mayiuse(cpu_isa_t::avx2)) { - kernel.test<8, false>(); + kernel.test<8, 5, false>(); } if (mayiuse(cpu_isa_t::sse41)) { - kernel.test<4, false>(); + kernel.test<4, 3, false>(); } } { jit_variable_load_store_test_kernel kernel; if (mayiuse(cpu_isa_t::avx512_core)) { - kernel.test<16, false>(); + kernel.test<16, 11, false>(); } if (mayiuse(cpu_isa_t::avx2)) { - kernel.test<8, false>(); + kernel.test<8, 5, false>(); } if (mayiuse(cpu_isa_t::sse41)) { - kernel.test<4, false>(); + kernel.test<4, 3, false>(); } } { jit_variable_load_store_test_kernel kernel; if (mayiuse(cpu_isa_t::avx512_core)) { - kernel.test<16, true>(); + kernel.test<16, 11, true>(); } if (mayiuse(cpu_isa_t::avx2)) { - kernel.test<8, true>(); + kernel.test<8, 5, true>(); } if (mayiuse(cpu_isa_t::sse41)) { - kernel.test<4, true>(); + kernel.test<4, 3, true>(); } } { jit_variable_load_store_test_kernel kernel; if (mayiuse(cpu_isa_t::avx512_core)) { - kernel.test<16, true>(); + kernel.test<16, 11, true>(); } if (mayiuse(cpu_isa_t::avx2)) { - kernel.test<8, true>(); + kernel.test<8, 5, true>(); } if (mayiuse(cpu_isa_t::sse41)) { - kernel.test<4, true>(); + kernel.test<4, 3, true>(); } } } From 4124851d2b429c3b169d4205fc93eab0acaaa997 Mon Sep 17 00:00:00 2001 From: Taylor Yeonbok Lee Date: Wed, 6 Sep 2023 22:35:00 -0700 Subject: [PATCH 31/31] Revert "[GPU] Fixed reordered memory cache not to contain original weight memory (#19465)" (#19659) This reverts commit e8f1df495c32f093a9cb41fc004e628599bf49ec. --- .../intel_gpu/src/graph/include/convolution_inst.h | 9 +-------- .../intel_gpu/src/graph/include/deconvolution_inst.h | 9 +-------- .../intel_gpu/src/graph/include/fully_connected_inst.h | 10 +--------- src/plugins/intel_gpu/src/graph/primitive_inst.cpp | 4 +++- 4 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/include/convolution_inst.h b/src/plugins/intel_gpu/src/graph/include/convolution_inst.h index c0e6ce9fd520c7..7033df0905ac4c 100644 --- a/src/plugins/intel_gpu/src/graph/include/convolution_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/convolution_inst.h @@ -149,14 +149,7 @@ class typed_primitive_inst : public typed_primitive_inst_baseweights_layout; - auto weights_idx = node->get_deform_conv_dep_offset() + 1; - if (weights_layout.compatible(get_node().get_input_layout(weights_idx))) { - weights_mem = dep_memory_ptr(weights_idx); - } else { - weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout); - } + auto weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout); OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache"); return weights_mem; } else { // all weights are in one buffer diff --git a/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.h b/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.h index 87bdf00e686984..195c00d22c3b67 100644 --- a/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.h @@ -81,14 +81,7 @@ class typed_primitive_inst : public typed_primitive_inst_baseweights_layout; - size_t weights_idx = 1; - if (weights_layout.compatible(get_node().get_input_layout(weights_idx))) { - weights_mem = dep_memory_ptr(weights_idx); - } else { - weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout); - } + auto weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout); OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache"); return weights_mem; } else { diff --git a/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.h b/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.h index 8258367b7f9bf5..f350cd8ef15b4b 100644 --- a/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.h @@ -54,15 +54,7 @@ class typed_primitive_inst : public typed_primitive_inst_baseweights_layout; - size_t weights_idx = 1; - if (weights_layout.compatible(get_node().get_input_layout(weights_idx))) { - weights_mem = dep_memory_ptr(weights_idx); - } else { - weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout); - } - + auto weights_mem = _reordered_weights_cache.get(*_impl_params->weights_layout); OPENVINO_ASSERT(weights_mem != nullptr, "[GPU] Can't find proper weights memory buffer in cache"); return weights_mem; } else { diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp index 2a2283ce2c41ad..271bf2d338903b 100644 --- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp +++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp @@ -1137,6 +1137,7 @@ event::ptr primitive_inst::update_weights() { if (!reorder_kernel_params) { // If kernel doesn't says that it doesn't require weights reorder, but weights were reordered previously, then // incorrect memory buffer may be assigned, so reset cached weights for such case + _reordered_weights_cache.add(original_layout, original_weights_memory); _impl_params->weights_layout = optional_layout(original_layout); } else { auto expected_layout = reorder_kernel_params->get_output_layout(); @@ -1152,6 +1153,7 @@ event::ptr primitive_inst::update_weights() { GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true); GPU_DEBUG_TRACE_DETAIL << id() << ": reinterpret original weights memory from " << original_layout.to_short_string() << " to " << expected_layout.to_short_string() << std::endl; + _reordered_weights_cache.add(expected_layout, engine.reinterpret_buffer(*original_weights_memory, expected_layout)); return nullptr; } else { GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(false); @@ -1184,7 +1186,7 @@ event::ptr primitive_inst::update_weights() { memory::ptr weights_memory = nullptr; if (_reordered_weights_cache.is_full()) { weights_memory = _reordered_weights_cache.get_lru_element().second; - can_reuse = weights_memory->size() <= expected_layout.bytes_count(); + can_reuse = weights_memory->size() <= expected_layout.bytes_count() && (weights_memory->buffer_ptr() != original_weights_memory->buffer_ptr()); } if (can_reuse) {