[IE VPU] Set name for output DSR in DTS (#1011)
* [IE VPU] Set name for outDSR in DTS transformations * [IE VPU] Enable NonZero_Transpose tests * [IE VPU] Set name for outDSR in Reduce DTS * [IE VPU] Use move semantic in DTS
This commit is contained in:
parent
fce9d9def0
commit
3790b35060
@ -44,7 +44,10 @@ void dynamicToStaticShapeBinaryEltwise(std::shared_ptr<ngraph::Node> eltwise) {
|
||||
}
|
||||
|
||||
const auto shape = std::make_shared<ngraph::opset3::Maximum>(lhsInput, rhsInput);
|
||||
ngraph::replace_node(std::move(eltwise), std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, shape));
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, shape);
|
||||
outDSR->set_friendly_name(eltwise->get_friendly_name());
|
||||
ngraph::replace_node(std::move(eltwise), std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -107,11 +107,10 @@ void dynamicToStaticShapeConcat(std::shared_ptr<ngraph::Node> target) {
|
||||
}
|
||||
|
||||
const auto copied = target->clone_with_new_inputs(target->input_values());
|
||||
auto outDsr = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(
|
||||
copied, accumulatedShape);
|
||||
outDsr->set_friendly_name(target->get_friendly_name());
|
||||
|
||||
ngraph::replace_node(std::move(target), outDsr);
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, accumulatedShape);
|
||||
outDSR->set_friendly_name(target->get_friendly_name());
|
||||
ngraph::replace_node(std::move(target), std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -71,9 +71,10 @@ void dynamicToStaticShapeGather(std::shared_ptr<ngraph::Node> target) {
|
||||
output_dims.push_back(second_data_shape_part);
|
||||
}
|
||||
const auto output_shape = std::make_shared<ngraph::opset3::Concat>(output_dims, 0);
|
||||
auto outDsr = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape);
|
||||
outDsr->set_friendly_name(target->get_friendly_name());
|
||||
ngraph::replace_node(target, outDsr);
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape);
|
||||
outDSR->set_friendly_name(target->get_friendly_name());
|
||||
ngraph::replace_node(target, std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -66,6 +66,9 @@ void dynamicToStaticShapeReduce(std::shared_ptr<ngraph::Node> target) {
|
||||
ngraph::opset3::Constant::create(ngraph::element::i64, {1}, {0}));
|
||||
}
|
||||
const auto copied = target->clone_with_new_inputs(target->input_values());
|
||||
ngraph::replace_node(target, std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape));
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape);
|
||||
outDSR->set_friendly_name(target->get_friendly_name());
|
||||
ngraph::replace_node(target, std::move(outDSR));
|
||||
}
|
||||
} // namespace vpu
|
||||
|
@ -33,8 +33,9 @@ void dynamicToStaticShapeReshape(std::shared_ptr<ngraph::Node> target) {
|
||||
const auto outShapeOfReshape = std::make_shared<ngraph::vpu::op::OutShapeOfReshape>(
|
||||
inDataShape, outShapeDescriptor, reshape->get_special_zero());
|
||||
|
||||
ngraph::replace_node(std::move(target), std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(
|
||||
copied, outShapeOfReshape));
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, outShapeOfReshape);
|
||||
outDSR->set_friendly_name(reshape->get_friendly_name());
|
||||
ngraph::replace_node(std::move(target), std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -49,7 +49,10 @@ void dynamicToStaticShapeROIAlign(std::shared_ptr<ngraph::Node> target) {
|
||||
ngraph::OutputVector{num_rois, c, pooled_h, pooled_w}, 0);
|
||||
|
||||
const auto copied = target->clone_with_new_inputs(target->input_values());
|
||||
ngraph::replace_node(target, std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape));
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape);
|
||||
outDSR->set_friendly_name(roi_align->get_friendly_name());
|
||||
ngraph::replace_node(target, std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -53,7 +53,10 @@ void dynamicToStaticShapeSqueeze(std::shared_ptr<ngraph::Node> target) {
|
||||
const auto axis = std::make_shared<ngraph::opset3::Constant>(
|
||||
ngraph::element::i64, ngraph::Shape{1}, std::vector<int64_t>{0});
|
||||
const auto squeeze_output_shape = std::make_shared<ngraph::opset3::Gather>(shape, index, axis);
|
||||
ngraph::replace_node(std::move(target), std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, squeeze_output_shape));
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, squeeze_output_shape);
|
||||
outDSR->set_friendly_name(squeeze->get_friendly_name());
|
||||
ngraph::replace_node(std::move(target), std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -109,35 +109,39 @@ void dynamicToStaticShapeStridedSlice(std::shared_ptr<ngraph::Node> target) {
|
||||
"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 ss = ngraph::as_type_ptr<ngraph::opset3::StridedSlice>(target);
|
||||
VPU_THROW_UNLESS(ss, "dynamicToStaticShapeStridedSlice transformation is not applicable for {}", target);
|
||||
const auto stridedSlice = ngraph::as_type_ptr<ngraph::opset3::StridedSlice>(target);
|
||||
VPU_THROW_UNLESS(stridedSlice, "dynamicToStaticShapeStridedSlice transformation is not applicable for {}", target);
|
||||
|
||||
const auto all_zero = [](const std::vector<int64_t> & v) {return std::all_of(v.cbegin(), v.cend(), [](const int64_t & i){return i == 0;});};
|
||||
VPU_THROW_UNLESS(all_zero(ss->get_new_axis_mask()),
|
||||
VPU_THROW_UNLESS(all_zero(stridedSlice->get_new_axis_mask()),
|
||||
"dynamicToStaticShapeStridedSlice transformation is not applicable for {}, new_axis_mask expected to be zeros", target);
|
||||
VPU_THROW_UNLESS(all_zero(ss->get_shrink_axis_mask()),
|
||||
VPU_THROW_UNLESS(all_zero(stridedSlice->get_shrink_axis_mask()),
|
||||
"dynamicToStaticShapeStridedSlice transformation is not applicable for {}, shrink_axis_mask expected to be zeros", target);
|
||||
VPU_THROW_UNLESS(all_zero(ss->get_ellipsis_mask()),
|
||||
VPU_THROW_UNLESS(all_zero(stridedSlice->get_ellipsis_mask()),
|
||||
"dynamicToStaticShapeStridedSlice transformation is not applicable for {}, ellipsis_mask expected to be zeros", target);
|
||||
|
||||
const auto get_i64_vector_from_const = [&ss](std::shared_ptr<ngraph::Node> node_ptr) {
|
||||
const auto get_i64_vector_from_const = [&stridedSlice](std::shared_ptr<ngraph::Node> node_ptr) {
|
||||
const auto constant = ngraph::as_type_ptr<ngraph::opset3::Constant>(node_ptr);
|
||||
VPU_THROW_UNLESS(constant,
|
||||
"dynamicToStaticShapeStridedSlice transformation is not applicable for {}, begin, end and stride inputs are expected to be constants", ss);
|
||||
"dynamicToStaticShapeStridedSlice transformation is not applicable for {}, begin, end and stride inputs are expected to be constants",
|
||||
stridedSlice);
|
||||
return constant->cast_vector<int64_t>();
|
||||
};
|
||||
|
||||
const auto input_shape = dsr->input_value(1);
|
||||
const auto output_shape = calculate_output_shape(
|
||||
get_i64_vector_from_const(ss->input_value(1).get_node_shared_ptr()),
|
||||
get_i64_vector_from_const(ss->input_value(2).get_node_shared_ptr()),
|
||||
get_i64_vector_from_const(ss->input_value(3).get_node_shared_ptr()),
|
||||
convert_mask_to_axis_set(ss->get_begin_mask()),
|
||||
convert_mask_to_axis_set(ss->get_end_mask()),
|
||||
get_i64_vector_from_const(stridedSlice->input_value(1).get_node_shared_ptr()),
|
||||
get_i64_vector_from_const(stridedSlice->input_value(2).get_node_shared_ptr()),
|
||||
get_i64_vector_from_const(stridedSlice->input_value(3).get_node_shared_ptr()),
|
||||
convert_mask_to_axis_set(stridedSlice->get_begin_mask()),
|
||||
convert_mask_to_axis_set(stridedSlice->get_end_mask()),
|
||||
input_shape);
|
||||
|
||||
const auto copied = ss->clone_with_new_inputs(target->input_values());
|
||||
ngraph::replace_node(std::move(target), std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape));
|
||||
const auto copied = stridedSlice->clone_with_new_inputs(target->input_values());
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, output_shape);
|
||||
outDSR->set_friendly_name(stridedSlice->get_friendly_name());
|
||||
ngraph::replace_node(std::move(target), std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -77,7 +77,10 @@ void dynamicToStaticShapeTopK(std::shared_ptr<ngraph::Node> target) {
|
||||
topk->get_sort_type(),
|
||||
topk->get_index_element_type());
|
||||
|
||||
for (auto &output : target->outputs())
|
||||
output.replace(std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(new_topk->output(output.get_index()), output_shape));
|
||||
for (auto &output : target->outputs()) {
|
||||
const auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(new_topk->output(output.get_index()), output_shape);
|
||||
outDSR->set_friendly_name(topk->get_friendly_name() + "." + std::to_string(output.get_index()));
|
||||
output.replace(outDSR);
|
||||
}
|
||||
}
|
||||
} // namespace vpu
|
||||
|
@ -34,7 +34,10 @@ void dynamicToStaticShapeTranspose(std::shared_ptr<ngraph::Node> target) {
|
||||
ngraph::Shape{std::initializer_list<std::size_t>{1}},
|
||||
std::vector<std::int64_t>{0});
|
||||
const auto scatterElementsUpdate = std::make_shared<ngraph::opset3::ScatterElementsUpdate>(shape, transposition, shape, axis);
|
||||
ngraph::replace_node(std::move(target), std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, scatterElementsUpdate));
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, scatterElementsUpdate);
|
||||
outDSR->set_friendly_name(transpose->get_friendly_name());
|
||||
ngraph::replace_node(std::move(target), std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -22,7 +22,10 @@ void dynamicToStaticUnaryElementwise(std::shared_ptr<ngraph::Node> target) {
|
||||
|
||||
const auto shape = dsr->input(1).get_source_output();
|
||||
const auto copied = target->clone_with_new_inputs(target->input_values());
|
||||
ngraph::replace_node(target, std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, shape));
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, shape);
|
||||
outDSR->set_friendly_name(target->get_friendly_name());
|
||||
ngraph::replace_node(target, std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -58,7 +58,10 @@ void dynamicToStaticShapeUnsqueeze(std::shared_ptr<ngraph::Node> target) {
|
||||
new_shape_dims.insert(new_shape_dims.begin() + i, new_dim);
|
||||
}
|
||||
const auto unsqueeze_output_shape = std::make_shared<ngraph::opset3::Concat>(new_shape_dims, 0);
|
||||
ngraph::replace_node(std::move(target), std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, unsqueeze_output_shape));
|
||||
|
||||
auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied, unsqueeze_output_shape);
|
||||
outDSR->set_friendly_name(unsqueeze->get_friendly_name());
|
||||
ngraph::replace_node(std::move(target), std::move(outDSR));
|
||||
}
|
||||
|
||||
} // namespace vpu
|
||||
|
@ -62,15 +62,18 @@ void dynamicToStaticShapeVariadicSplit(std::shared_ptr<ngraph::Node> target) {
|
||||
}
|
||||
for (auto i = 0; i < split_lengths.size(); ++i) {
|
||||
const auto dim = ngraph::opset3::Constant::create(data_shape->get_element_type(), {1}, {split_lengths[i]});
|
||||
auto dsrShapeInput = dim->shared_from_this();
|
||||
|
||||
if (!first_shape_part.empty() || !second_shape_part.empty()) {
|
||||
ngraph::OutputVector output_dims{dim};
|
||||
output_dims.insert(output_dims.begin(), first_shape_part.begin(), first_shape_part.end());
|
||||
output_dims.insert(output_dims.end(), second_shape_part.begin(), second_shape_part.end());
|
||||
const auto output_shape = std::make_shared<ngraph::opset3::Concat>(output_dims, 0);
|
||||
target->output(i).replace(std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied->output(i), output_shape));
|
||||
} else {
|
||||
target->output(i).replace(std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied->output(i), dim));
|
||||
dsrShapeInput = std::make_shared<ngraph::opset3::Concat>(output_dims, 0);
|
||||
}
|
||||
|
||||
const auto outDSR = std::make_shared<ngraph::vpu::op::DynamicShapeResolver>(copied->output(i), dsrShapeInput);
|
||||
outDSR->set_friendly_name(target->get_friendly_name() + "." + std::to_string(target->output(0).get_index()));
|
||||
target->output(i).replace(outDSR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,5 @@ std::vector<std::string> disabledTestPatterns() {
|
||||
".*Behavior.*ExecGraphTests.*",
|
||||
// TODO: Issue: 26268
|
||||
".*ConcatLayerTest.*axis=0.*",
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
//TODO: Issue: 33722
|
||||
".*DynamicTranspose.*NonZero_Transpose.*",
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user