From 27c03b35be697aef1a15638adfdf2e830f693fd7 Mon Sep 17 00:00:00 2001 From: Maksim Doronin Date: Tue, 15 Sep 2020 12:42:16 +0300 Subject: [PATCH] [IE][VPU]: Some KW fixes (#2142) * Some KW fixes * Fix printTo in vpu ngraph transformations --- .../vpu/ngraph/transformations/dynamic_to_static_shape.hpp | 2 -- inference-engine/src/vpu/common/include/vpu/ngraph/utilities.hpp | 6 ++++++ .../src/vpu/common/include/vpu/utils/simple_math.hpp | 2 +- .../src/ngraph/transformations/dynamic_to_static_shape.cpp | 9 +++------ .../dynamic_to_static_shape_binary_elementwise.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_broadcast.cpp | 3 ++- .../ngraph/transformations/dynamic_to_static_shape_concat.cpp | 9 +++++---- .../ngraph/transformations/dynamic_to_static_shape_gather.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_matmul.cpp | 1 + .../dynamic_to_static_shape_non_max_suppression.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_nonzero.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_reduce.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_reshape.cpp | 8 ++++++-- .../ngraph/transformations/dynamic_to_static_shape_roialign.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_squeeze.cpp | 6 +++++- .../transformations/dynamic_to_static_shape_strided_slice.cpp | 1 + .../src/ngraph/transformations/dynamic_to_static_shape_topk.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_transpose.cpp | 8 ++++++-- .../dynamic_to_static_shape_unary_elementwise.cpp | 1 + .../ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp | 6 +++++- .../transformations/dynamic_to_static_shape_variadic_split.cpp | 1 + inference-engine/src/vpu/common/src/ngraph/utilities.cpp | 8 ++++++++ .../src/vpu/graph_transformer/src/frontend/custom_layer.cpp | 2 ++ inference-engine/src/vpu/graph_transformer/src/stages/custom.cpp | 5 +++-- 24 files changed, 63 insertions(+), 22 deletions(-) diff --git a/inference-engine/src/vpu/common/include/vpu/ngraph/transformations/dynamic_to_static_shape.hpp b/inference-engine/src/vpu/common/include/vpu/ngraph/transformations/dynamic_to_static_shape.hpp index 01abaad..8101b84 100644 --- a/inference-engine/src/vpu/common/include/vpu/ngraph/transformations/dynamic_to_static_shape.hpp +++ b/inference-engine/src/vpu/common/include/vpu/ngraph/transformations/dynamic_to_static_shape.hpp @@ -24,6 +24,4 @@ private: Transformations transformations; }; -void printTo(std::ostream& stream, const ngraph::NodeTypeInfo& object); - } // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/ngraph/utilities.hpp b/inference-engine/src/vpu/common/include/vpu/ngraph/utilities.hpp index ffd6e80..520cb76 100644 --- a/inference-engine/src/vpu/common/include/vpu/ngraph/utilities.hpp +++ b/inference-engine/src/vpu/common/include/vpu/ngraph/utilities.hpp @@ -7,3 +7,9 @@ #include "ngraph/node.hpp" std::vector evaluateTargetShape(const ngraph::Output& value); + +namespace vpu { + +void printTo(std::ostream& stream, const ngraph::NodeTypeInfo& object); + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/utils/simple_math.hpp b/inference-engine/src/vpu/common/include/vpu/utils/simple_math.hpp index aafe688..bd49139 100644 --- a/inference-engine/src/vpu/common/include/vpu/utils/simple_math.hpp +++ b/inference-engine/src/vpu/common/include/vpu/utils/simple_math.hpp @@ -26,7 +26,7 @@ namespace vpu { template Optional parseNumber(const std::string& s) { - T value; + T value{}; if ((std::istringstream(s) >> value >> std::ws).eof()) { return {value}; } diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape.cpp index 8358a7c..a2a3c1a 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape.cpp @@ -21,6 +21,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_unsqueeze.hpp" #include "vpu/ngraph/transformations/dynamic_to_static_shape_variadic_split.hpp" +#include "vpu/ngraph/utilities.hpp" #include "vpu/utils/error.hpp" #include "ngraph/opsets/opset3.hpp" @@ -28,10 +29,6 @@ namespace vpu { -void printTo(std::ostream& stream, const ngraph::NodeTypeInfo& object) { - stream << object.name << " ver. " << object.version; -} - namespace { using namespace ngraph; @@ -41,7 +38,7 @@ bool isDynamic(const Node& node) { return std::any_of(outputs.cbegin(), outputs.cend(), [](const Output& output) { VPU_THROW_UNLESS(output.get_partial_shape().rank() != ngraph::Rank::dynamic(), "DynamicToStaticShape transformation: got dynamic rank for {} with type {} while only static is supported", - output.get_node_shared_ptr()->get_friendly_name(), output.get_node_shared_ptr()->get_type_name()); + output.get_node_shared_ptr()->get_friendly_name(), output.get_node_shared_ptr()->get_type_info()); return output.get_partial_shape().is_dynamic(); }); @@ -51,7 +48,7 @@ bool validateStaticShapes(const ngraph::Function& function) { for (const auto& node : function.get_ordered_ops()) { VPU_THROW_UNLESS(!isDynamic(*node), "DynamicToStaticShape transformation: after all the transformations there is still dynamism in the network." - " First met node with dynamic output: {} (type: {})", node->get_friendly_name(), node->get_type_name()); + " First met node with dynamic output: {} (type: {})", node->get_friendly_name(), node->get_type_info()); } return true; } diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp index 0f1ffe0..396c933 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_binary_elementwise.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp index 08fc027..cd1a100 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp @@ -6,6 +6,7 @@ #include "vpu/ngraph/operations/static_shape_broadcast.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include "vpu/utils/error.hpp" #include "ngraph/graph_util.hpp" @@ -20,7 +21,7 @@ void dynamicToStaticShapeBroadcast(std::shared_ptr target) { VPU_THROW_UNLESS(broadcast, "dynamicToStaticShapeBroadcast transformation is not applicable for {}, " "it should be {} instead", - target, ngraph::opset3::Broadcast::type_info.name); + target, ngraph::opset3::Broadcast::type_info); std::shared_ptr staticShapeBroadcast; if (broadcast->get_broadcast_spec() == ngraph::op::BroadcastType::EXPLICIT) { diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_concat.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_concat.cpp index 7f75857..4417970 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_concat.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_concat.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_concat.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" @@ -33,7 +34,7 @@ void dynamicToStaticShapeConcat(std::shared_ptr target) { VPU_THROW_UNLESS(!dsrInputs.empty(), "DynamicToStaticShape transformation for {} of type {} expects at least " "one {} as input, actual types: {}", target->get_friendly_name(), - target->get_type_info().name, ngraph::vpu::op::DynamicShapeResolver::type_info.name, + target->get_type_info(), ngraph::vpu::op::DynamicShapeResolver::type_info, std::accumulate(inputs.begin(), inputs.end(), std::string(), []( const std::string& typesStr, const ngraph::Output& input) { return typesStr + input.get_node_shared_ptr()->get_type_info().name + ", "; @@ -55,8 +56,8 @@ void dynamicToStaticShapeConcat(std::shared_ptr target) { VPU_THROW_UNLESS(dsrShapeInputValue.get_element_type() == shapeDataType, "DynamicToStaticShape transformation for {} of type {} expects input " "shape with {} type from {} argument of type {}, provided {}", - target->get_friendly_name(), target->get_type_info().name, - shapeDataType, dsrNode->get_friendly_name(), dsrNode->get_type_info().name, + target->get_friendly_name(), target->get_type_info(), + shapeDataType, dsrNode->get_friendly_name(), dsrNode->get_type_info(), dsrShapeInputValue.get_element_type()); return dsrShapeInputValue; }; @@ -85,7 +86,7 @@ void dynamicToStaticShapeConcat(std::shared_ptr target) { VPU_THROW_UNLESS(staticInputPartialShape.is_static(), "DynamicToStaticShape transformation for {} of type {} expects static " "shape on inputs without DSR", target->get_friendly_name(), - target->get_type_info().name); + target->get_type_info()); accumulatedStaticShapeValue[axis] += staticInputPartialShape[axis].get_length(); } return accumulatedStaticShapeValue; diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_gather.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_gather.cpp index 012e221..0103294 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_gather.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_gather.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_gather.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_matmul.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_matmul.cpp index a202592..5b2621c 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_matmul.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_matmul.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_matmul.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp index 4ed18ef..a1285ef 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_non_max_suppression.cpp @@ -6,6 +6,7 @@ #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" #include "vpu/ngraph/operations/dynamic_non_max_suppression.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp index 5bcac1f..2cb3449 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_nonzero.cpp @@ -6,6 +6,7 @@ #include "vpu/ngraph/operations/static_shape_nonzero.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include "vpu/utils/error.hpp" #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reduce.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reduce.cpp index f36f9fa..ff0e8c6 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reduce.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reduce.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_reduce.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reshape.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reshape.cpp index 5c0fe8a..98c2bc0 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reshape.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_reshape.cpp @@ -6,6 +6,7 @@ #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" #include "vpu/ngraph/operations/out_shape_of_reshape.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" @@ -17,15 +18,18 @@ namespace vpu { void dynamicToStaticShapeReshape(std::shared_ptr target) { + const auto reshape = ngraph::as_type_ptr(target); + VPU_THROW_UNLESS(reshape, "dynamicToStaticShapeReshape transformation is not applicable for {}, it should be {} instead", + target, ngraph::opset3::Reshape::type_info); + const auto dsr = target->input_value(0).get_node_shared_ptr(); VPU_THROW_UNLESS(ngraph::as_type_ptr(dsr), "DynamicToStaticShape transformation for {} of type {} expects {} as input with index {}", target->get_friendly_name(), target->get_type_info(), ngraph::vpu::op::DynamicShapeResolver::type_info, 0); - const auto reshape = std::dynamic_pointer_cast(target); const auto outShapeDescriptor = reshape->input_value(1).get_node_shared_ptr(); - const auto replacement = ngraph::as_type_ptr(outShapeDescriptor) + const auto replacement = ngraph::is_type(outShapeDescriptor) ? reshape->clone_with_new_inputs(reshape->input_values()) : std::make_shared(reshape); diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_roialign.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_roialign.cpp index a591c2a..9a140b4 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_roialign.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_roialign.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_roialign.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp index 46f60cc..85562fc 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_squeeze.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_squeeze.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" @@ -18,6 +19,10 @@ namespace vpu { void dynamicToStaticShapeSqueeze(std::shared_ptr target) { + const auto squeeze = ngraph::as_type_ptr(target); + VPU_THROW_UNLESS(squeeze, "dynamicToStaticShapeSqueeze transformation is not applicable for {}, it should be {} instead", + target, ngraph::opset3::Squeeze::type_info); + const auto dsr = target->input_value(0).get_node_shared_ptr(); VPU_THROW_UNLESS(std::dynamic_pointer_cast(dsr), "DynamicToStaticShape transformation for {} of type {} expects {} as input with index {}", @@ -27,7 +32,6 @@ void dynamicToStaticShapeSqueeze(std::shared_ptr target) { VPU_THROW_UNLESS(axes, "DynamicToStaticShape transformation for {} of type {} expects {} as input with index {}", target->get_friendly_name(), target->get_type_info(), ngraph::op::Constant::type_info, 1); - const auto squeeze = std::dynamic_pointer_cast(target); const auto copied = squeeze->clone_with_new_inputs(target->input_values()); const auto shape = dsr->input(1).get_source_output(); diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_strided_slice.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_strided_slice.cpp index 2149986..dacf2dd 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_strided_slice.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_strided_slice.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_strided_slice.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_topk.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_topk.cpp index 93e37dc..b97edb1 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_topk.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_topk.cpp @@ -6,6 +6,7 @@ #include "vpu/ngraph/operations/static_shape_topk.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_transpose.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_transpose.cpp index f1b9266..22a433b 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_transpose.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_transpose.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_transpose.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" @@ -15,6 +16,10 @@ namespace vpu { void dynamicToStaticShapeTranspose(std::shared_ptr target) { + const auto transpose = ngraph::as_type_ptr(target); + VPU_THROW_UNLESS(transpose, "dynamicToStaticShapeTranspose transformation is not applicable for {}, it should be {} instead", + target, ngraph::opset3::Transpose::type_info); + const auto dsr = target->input_value(0).get_node_shared_ptr(); VPU_THROW_UNLESS(ngraph::as_type_ptr(dsr), "DynamicToStaticShape transformation for {} of type {} expects {} as input with index {}", @@ -22,10 +27,9 @@ void dynamicToStaticShapeTranspose(std::shared_ptr target) { const auto transposition = target->input_value(1).get_node_shared_ptr(); VPU_THROW_UNLESS(ngraph::as_type_ptr(transposition), - "DynamicToStaticShape transformation for {] of type {} expects {} as input with index {}", + "DynamicToStaticShape transformation for {} of type {} expects {} as input with index {}", target->get_friendly_name(), target->get_type_info(), ngraph::opset3::Constant::type_info, 1); - const auto transpose = std::dynamic_pointer_cast(target); const auto copied = transpose->clone_with_new_inputs(target->input_values()); const auto shape = dsr->input(1).get_source_output(); diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp index 6d51589..5d92259 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_unary_elementwise.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp index 81c053b..244f883 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_unsqueeze.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_unsqueeze.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" @@ -19,6 +20,10 @@ namespace vpu { void dynamicToStaticShapeUnsqueeze(std::shared_ptr target) { + const auto unsqueeze = ngraph::as_type_ptr(target); + VPU_THROW_UNLESS(unsqueeze, "dynamicToStaticShapeUnsqueeze transformation is not applicable for {}, it should be {} instead", + target, ngraph::opset3::Unsqueeze::type_info); + const auto dsr = target->input_value(0).get_node_shared_ptr(); VPU_THROW_UNLESS(std::dynamic_pointer_cast(dsr), "DynamicToStaticShape transformation for {} of type {} expects {} as input with index {}", @@ -28,7 +33,6 @@ void dynamicToStaticShapeUnsqueeze(std::shared_ptr target) { VPU_THROW_UNLESS(axes, "DynamicToStaticShape transformation for {} of type {} expects {} as input with index {}", target->get_friendly_name(), target->get_type_info(), ngraph::op::Constant::type_info, 1); - const auto unsqueeze = std::dynamic_pointer_cast(target); const auto copied = unsqueeze->clone_with_new_inputs(target->input_values()); const auto shape = dsr->input(1).get_source_output(); diff --git a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp index c0e4553..5535b3c 100644 --- a/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/transformations/dynamic_to_static_shape_variadic_split.cpp @@ -5,6 +5,7 @@ #include "vpu/ngraph/transformations/dynamic_to_static_shape_variadic_split.hpp" #include "vpu/ngraph/operations/dynamic_shape_resolver.hpp" +#include "vpu/ngraph/utilities.hpp" #include #include "ngraph/graph_util.hpp" diff --git a/inference-engine/src/vpu/common/src/ngraph/utilities.cpp b/inference-engine/src/vpu/common/src/ngraph/utilities.cpp index d0a84b9..3e3de8f 100644 --- a/inference-engine/src/vpu/common/src/ngraph/utilities.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/utilities.cpp @@ -60,3 +60,11 @@ std::vector evaluateTargetShape(const ngraph::Output const auto shapeConstNode = std::make_shared(shapeTensor); return {shapeConstNode->cast_vector()}; } + +namespace vpu { + +void printTo(std::ostream& stream, const ngraph::NodeTypeInfo& object) { + stream << object.name << " ver. " << object.version; +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/custom_layer.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/custom_layer.cpp index 4a9a209..a20ffbb 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/custom_layer.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/custom_layer.cpp @@ -184,6 +184,8 @@ CustomLayer::CustomLayer(std::string configDir, const pugi::xml_node& customLaye stageOrder.emplace(stageNum, CustomKernel{kernel, _configDir}); } + VPU_THROW_UNLESS(!stageOrder.empty(), + "Error while binding %s custom layer: No kernels are found.", _layerName); VPU_THROW_UNLESS(stageOrder.begin()->first == 0, "Error while binding %s custom layer: Stage 0 is not found.", _layerName); VPU_THROW_UNLESS(stageOrder.rbegin()->first == stageOrder.size() - 1, diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/custom.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/custom.cpp index bc4e346..ef8f59c 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/custom.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/custom.cpp @@ -135,11 +135,12 @@ private: case CustomParamType::InputBuffer: case CustomParamType::OutputBuffer: case CustomParamType::Data: { - VPU_THROW_UNLESS(ports.find(kp) != ports.end(), + const auto& kpIt = ports.find(kp); + VPU_THROW_UNLESS(kpIt != ports.end(), "XML specification for %s layer has no definition for '%s' parameter. Layer name: %s", origLayer()->type, kp, origLayer()->name); - int id = ports.find(kp)->second; + int id = kpIt->second; serializer.append(static_cast(0)); serializer.append(static_cast(id)); break; -- 2.7.4