[IE][VPU][GT]: Introduce Split by dynamic dimension check (#2802)

* [IE][VPU][GT]: Introduce Split by dynamic dimension check

At the moment, myriad plugin does not support split operation
by dynamic axis. To be sure there is no issue with optimized-out
split operation which should have been replaced with copy
stage - assertion before DTS transformation is introduced.

Check should be performed before loop with DTS transformations
because it requires dynamic context (dynamic dimension should be
visible as dynamic), otherwise dynamic dimension would be
replaced with upper-bound estimation and check will always pass.

Signed-off-by: Gladilov, Gleb <gleb.gladilov@intel.com>

* [IE][nGraph]: Fixes normalize_axis symbol exporting

Signed-off-by: Gladilov, Gleb <gleb.gladilov@intel.com>
This commit is contained in:
Gladilov, Gleb 2020-10-30 09:12:11 +03:00 committed by GitHub
parent b25d4ab065
commit 8ee263e7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "vpu/utils/error.hpp"
#include "ngraph/opsets/opset3.hpp"
#include <ngraph/validation_util.hpp>
#include "ngraph/opsets/opset5.hpp"
namespace vpu {
@ -68,6 +69,23 @@ bool propagateUpperBoundFromExistingDSR(std::shared_ptr<ngraph::Function>& funct
return function_changed;
}
void validateDynamicFunction(const ngraph::Function& function) {
for (auto const& split : function.get_ordered_ops()) {
if (split->get_type_info() != ngraph::opset5::Split::type_info) {
continue;
}
VPU_THROW_UNLESS(split->get_input_size() >= 2, "There is Split operation \"{}\" without specified axis", split->get_friendly_name());
const auto& axis = ngraph::as_type_ptr<ngraph::opset5::Constant>(split->input_value(1).get_node_shared_ptr());
VPU_THROW_UNLESS(axis != nullptr, "There is Split operation \"{}\" with dynamic axis \"{}\", but only constant axis is supported",
split->get_friendly_name(), split->input_value(1).get_node_shared_ptr()->get_friendly_name());
const auto axisValue = ngraph::normalize_axis(split.get(), axis->cast_vector<std::int64_t>().front(), split->get_input_partial_shape(0).rank());
VPU_THROW_UNLESS(split->get_input_partial_shape(0)[axisValue].is_static(),
"There is Split operation \"{}\" by dynamic dimension, but only split by static dimension is supported: shape = \"{}\", axis = \"{}\"",
split->get_friendly_name(), split->get_input_partial_shape(0), axisValue);
}
}
const Transformations& getDefaultTransformations() {
static const Transformations transformations = {
{ngraph::opset3::Add::type_info, dynamicToStaticShapeBinaryEltwise},
@ -141,6 +159,9 @@ bool DynamicToStaticShape::run_on_function(std::shared_ptr<ngraph::Function> fun
// Basically this is possible in test cases, when the function is initially configured with DSR as inputs.
function_changed |= propagateUpperBoundFromExistingDSR(function);
// Operation-specific testing that needs to be performed in dynamic context before DSRs are introduced
validateDynamicFunction(*function);
for (const auto& operation : function->get_ordered_ops()) {
if (!isDynamic(*operation)) {
continue;

View File

@ -144,6 +144,7 @@ namespace ngraph
/// \return Checking if axis is in range [-tensor_rank, tensor_rank-1], otherwise
/// returns error. If negative axis, it counts from the last to the first axis,
/// by adding tensor_rank to axis.
NGRAPH_API
int64_t normalize_axis(const Node* node, std::int64_t axis, const Rank& tensor_rank);
/// \brief Handle out of range axes in vector.