Migrate shape infers to new IStaticShapeInfer API (#18579)

* Add static shape adapter
- Adapters holds CPU dimension which can be reference to it or vector
- Add ov::optional for holding optional result from shape inference
- Add new `infer` function in `IStaticShapeInfer`

* Temporary support of StaticShape

* Minor corrections in ShapeInferenceTA

* Migrate shape_infer to new interface version

* Replace StaticShape by adapter implementation

* Replace IShapeInferCommon by IStaticShapeInfer

* Correct code formatting

* Fix build issues

* NodeValidationFailure::create for StaticShapeRef
This commit is contained in:
Pawel Raasz authored and GitHub committed 2023-07-24 15:59:18 +02:00
1 parent ec8fe6353a
commit 5eab1be682
209 files changed
+2014 -2968

No files matched your search

@@ -79,7 +79,7 @@ std::vector<layout> arg_max_min_inst::calc_output_layouts(arg_max_min_node const
op.set_mode(desc->mode);
op.set_sort_type(desc->sort);
std::vector<ShapeType> output_shapes = { ShapeType{}, ShapeType{} };
std::vector<ShapeType> output_shapes = {ShapeType{}, ShapeType{}};
std::vector<ShapeType> input_shapes = {
input_layout.get<ShapeType>(),
ShapeType{}
@@ -92,14 +92,14 @@ std::vector<layout> arg_max_min_inst::calc_output_layouts(arg_max_min_node const
auto top_k_tensor = std::make_shared<ngraph::runtime::HostTensor>(ov::element::u32, ov::Shape{1}, static_cast<void*>(&topk));
const_data = { {1, top_k_tensor} };
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
} else if (constant_mem.count(1)) {
std::map<size_t, ngraph::HostTensorPtr> const_data;
auto target_shape_mem = constant_mem.at(1);
cldnn::mem_lock<uint8_t, mem_lock_type::read> target_shape_lock(target_shape_mem, impl_param.get_stream());
const_data.emplace(1, make_host_tensor(target_shape_mem->get_layout(), target_shape_lock.data()));
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
} else {
output_shapes[0] = output_shapes[1] = ShapeType::dynamic(input_layout.get<ShapeType>().size());
}
+6 -5
View File
@@ -57,7 +57,7 @@ std::vector<layout> border_inst::calc_output_layouts(border_node const& /*node*/
ShapeType pads_begin_shape = is_begin_mem ? pads_begin_layout.get<ShapeType>() : ov::Shape{ desc->pads_begin.size() };
ShapeType pads_end_shape = is_end_mem ? pads_end_layout.get<ShapeType>() : ov::Shape{ desc->pads_end.size() };
std::vector<ShapeType> output_shapes = {ShapeType{}};
std::vector<ShapeType> output_shapes;
std::vector<ShapeType> input_shapes = {
input0_layout.get<ShapeType>(),
pads_begin_shape,
@@ -66,6 +66,7 @@ std::vector<layout> border_inst::calc_output_layouts(border_node const& /*node*/
auto& memory_deps = impl_param.memory_deps;
std::map<size_t, ngraph::HostTensorPtr> const_data;
auto ta = ov::make_tensor_accessor(const_data);
if ((is_begin_mem && memory_deps.count(1)) && (is_end_mem && memory_deps.count(2))) {
auto pads_begin_mem = memory_deps.at(1);
@@ -76,7 +77,7 @@ std::vector<layout> border_inst::calc_output_layouts(border_node const& /*node*/
cldnn::mem_lock<uint8_t, mem_lock_type::read> pads_end_lock(pads_end_mem, impl_param.get_stream());
const_data.emplace(2, make_host_tensor(pads_end_mem->get_layout(), pads_end_lock.data()));
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::shape_infer(&op, input_shapes, ta);
} else if ((is_begin_mem || is_end_mem) && memory_deps.count(1)) {
if (is_begin_mem) {
auto pads_begin_mem = memory_deps.at(1);
@@ -87,7 +88,7 @@ std::vector<layout> border_inst::calc_output_layouts(border_node const& /*node*/
auto pads_end_tensor = make_host_tensor({pads_end_shape, data_types::i64, format::bfyx}, static_cast<void*>(pads_end_data.data()));
const_data.emplace(2, pads_end_tensor);
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::shape_infer(&op, input_shapes, ta);
} else {
auto pads_begin_data = desc->pads_begin;
auto pads_begin_tensor = make_host_tensor({pads_begin_shape, data_types::i64, format::bfyx}, static_cast<void*>(pads_begin_data.data()));
@@ -97,7 +98,7 @@ std::vector<layout> border_inst::calc_output_layouts(border_node const& /*node*/
cldnn::mem_lock<uint8_t, mem_lock_type::read> pads_end_lock(pads_end_mem, impl_param.get_stream());
const_data.emplace(2, make_host_tensor(pads_end_mem->get_layout(), pads_end_lock.data()));
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::shape_infer(&op, input_shapes, ta);
}
} else {
std::ptrdiff_t val = desc->pad_value;
@@ -116,7 +117,7 @@ std::vector<layout> border_inst::calc_output_layouts(border_node const& /*node*/
auto pads_end_tensor = make_host_tensor({pads_end_shape, data_types::i64, format::bfyx}, static_cast<void*>(pads_end_data.data()));
const_data.emplace(2, pads_end_tensor);
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::shape_infer(&op, input_shapes, ta);
}
format output_format = format::adjust_to_rank(input0_layout.format, output_shapes[0].size());
@@ -75,13 +75,13 @@ std::vector<layout> broadcast_inst::calc_output_layouts(broadcast_node const& /*
auto target_shape_mem = constant_mem.at(1);
cldnn::mem_lock<uint8_t, mem_lock_type::read> target_shape_lock(target_shape_mem, impl_param.get_stream());
const_data.emplace(1, make_host_tensor(target_shape_mem->get_layout(), target_shape_lock.data()));
ov::op::v3::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::v3::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
} else if (impl_param.input_layouts.size() == 1) {
// predefined pattern shape
auto target_shape_tensor = make_host_tensor({pattern_shape, data_types::i64, format::bfyx},
static_cast<void*>(target_shape.data()));
const_data.emplace(1, target_shape_tensor);
ov::op::v3::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::v3::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
} else if (impl_param.input_layouts.size() >= 2) {
auto input1 = impl_param.get_input_layout(1);
auto output_rank = input1.get<ShapeType>().size();
@@ -62,14 +62,14 @@ std::vector<layout> concatenation_inst::calc_output_layouts(const concatenation_
auto axis_index = desc->axis;
std::vector<ShapeType> input_shapes;
std::vector<ShapeType> output_shapes = {ShapeType{}};
for (size_t i = 0; i < desc->input.size(); ++i) {
auto input_shape = impl_param.get_input_layout(i).get<ShapeType>();
input_shapes.push_back(input_shape);
}
ov::op::v0::Concat op;
op.set_concatenation_axis(axis_index);
ov::op::v0::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
return { layout {output_shapes[0], output_dt, output_format} };
}
+2 -2
View File
@@ -69,7 +69,7 @@ std::vector<layout> crop_inst::calc_output_layouts(const crop_node& /*node*/, co
const_data.emplace(2, make_host_tensor(split_length_mem->get_layout(), split_length_mem_lock.data()));
ov::op::v1::VariadicSplit op;
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
} else if (desc->op_mode == cldnn::crop_ngraph_op_mode::split) {
std::map<size_t, ngraph::HostTensorPtr> const_data;
@@ -80,7 +80,7 @@ std::vector<layout> crop_inst::calc_output_layouts(const crop_node& /*node*/, co
ov::op::v1::Split op;
op.set_num_splits(desc->num_splits);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
} else if (desc->op_mode == cldnn::crop_ngraph_op_mode::none) {
// Legacy usage
if (in_layout.is_dynamic()) {
@@ -187,13 +187,11 @@ std::vector<layout> deconvolution_inst::calc_output_layouts(deconvolution_node c
auto mem = memory_deps.at(2);
auto dims = read_vector<int64_t>(mem, impl_param.get_stream());
auto dims_shape = ov::Shape{dims.size()};
auto const_data =
std::unordered_map<size_t, ov::Tensor>{{2, ov::Tensor(ov::element::i64, dims_shape, dims.data())}};
input_shapes.push_back(dims_shape);
output_shapes = ov::op::v1::shape_infer(
&op,
input_shapes,
pads_begin,
pads_end,
{{2, std::make_shared<ov::HostTensor>(ov::element::i64, dims_shape, dims.data())}});
output_shapes =
ov::op::v1::shape_infer(&op, input_shapes, pads_begin, pads_end, ov::make_tensor_accessor(const_data));
} else {
output_shapes = ov::op::v1::shape_infer(&op, input_shapes, pads_begin, pads_end);
}
@@ -213,13 +211,12 @@ std::vector<layout> deconvolution_inst::calc_output_layouts(deconvolution_node c
auto mem = memory_deps.at(2);
auto dims = read_vector<int64_t>(mem, impl_param.get_stream());
auto dims_shape = ov::Shape{dims.size()};
auto const_data =
std::unordered_map<size_t, ov::Tensor>{{2, ov::Tensor(ov::element::i64, dims_shape, dims.data())}};
input_shapes.push_back(dims_shape);
output_shapes = ov::op::v1::shape_infer(
&op,
input_shapes,
pads_begin,
pads_end,
{{2, std::make_shared<ov::HostTensor>(ov::element::i64, dims_shape, dims.data())}});
output_shapes =
ov::op::v1::shape_infer(&op, input_shapes, pads_begin, pads_end, ov::make_tensor_accessor(const_data));
} else {
output_shapes = ov::op::v1::shape_infer(&op, input_shapes, pads_begin, pads_end);
}
@@ -58,11 +58,10 @@ std::vector<layout> depth_to_space_inst::calc_output_layouts(depth_to_space_node
ov::op::v0::DepthToSpace op;
op.set_block_size(desc->block_size);
std::vector<ShapeType> output_shapes = { ShapeType() };
std::vector<ShapeType> input_shapes = {
input_layout.get<ShapeType>()
};
ov::op::v0::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
return { layout{output_shapes[0], output_type, output_format} };
}
@@ -87,7 +87,7 @@ std::vector<layout> detection_output_inst::calc_output_layouts(detection_output_
attrs.normalized = desc->prior_is_normalized;
op.set_attrs(attrs);
ov::op::v8::shape_infer(&op, input_shapes, output_shapes);
output_shapes = ov::op::v8::shape_infer(&op, input_shapes);
} else {
ov::op::v0::DetectionOutput op;
ov::op::v0::DetectionOutput::Attributes attrs;
@@ -99,7 +99,7 @@ std::vector<layout> detection_output_inst::calc_output_layouts(detection_output_
attrs.normalized = desc->prior_is_normalized;
op.set_attrs(attrs);
ov::op::v0::shape_infer(&op, input_shapes, output_shapes);
output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
}
return { layout{output_shapes[0], output_type, output_format} };
+2 -2
View File
@@ -9,8 +9,8 @@
#include <vector>
#include <algorithm>
#include "eltwise_shape_inference.hpp"
#include "openvino/op/add.hpp"
#include "utils.hpp"
namespace cldnn {
GPU_DEFINE_PRIMITIVE_TYPE_ID(eltwise)
@@ -128,7 +128,7 @@ std::vector<layout> eltwise_inst::calc_output_layouts(eltwise_node const& /*node
for (size_t i = 0; i < desc->input_size(); i++) {
input_shapes.push_back(impl_param.get_input_layout(i).get<ShapeType>());
}
eltwise_shape_infer(&op, input_shapes, output_shapes);
output_shapes = ov::op::eltwise_shape_infer(&op, input_shapes);
if (input_layout.format == format::b_fs_zyx_fsv16) // use optimized 5D
out_format = format::b_fs_zyx_fsv16;
@@ -149,13 +149,12 @@ std::vector<layout> fully_connected_inst::calc_output_layouts(fully_connected_no
ov::op::v0::MatMul op;
op.set_transpose_b(true);
std::vector<ShapeType> output_shapes = {ShapeType()};
std::vector<ShapeType> input_shapes = {
input_layout.get<ShapeType>(),
weights_layout.get<ShapeType>()
};
ov::op::v0::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
bool is_static = input_layout.is_static() && weights_layout.is_static();
bool allow_new_shape_infer = impl_param.get_program().get_config().get_property(ov::intel_gpu::allow_new_shape_infer);
+1 -1
View File
@@ -90,7 +90,7 @@ std::vector<layout> gather_inst::calc_output_layouts(gather_node const& /*node*/
auto axis_tensor = std::make_shared<ngraph::runtime::HostTensor>(ov::element::i64, ov::Shape{1}, static_cast<void*>(&axis));
std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>> const_data = {{2, axis_tensor}};
ov::op::util::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
format output_format = format::adjust_to_rank(input0_layout.format, output_shapes[0].size());
@@ -42,12 +42,11 @@ std::vector<layout> gather_elements_inst::calc_output_layouts(gather_elements_no
ov::op::v6::GatherElements op;
op.set_axis(desc->axis);
std::vector<ShapeType> output_shapes = {ShapeType()};
std::vector<ShapeType> input_shapes = {
impl_param.get_input_layout(0).get<ShapeType>(),
impl_param.get_input_layout(1).get<ShapeType>()
};
ov::op::v6::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v6::shape_infer(&op, input_shapes);
format output_format = format::adjust_to_rank(input_layout.format, output_shapes[0].size());
@@ -84,7 +84,7 @@ std::vector<layout> gather_nd_inst::calc_output_layouts(gather_nd_node const& /*
output_type = impl_param.get_fused_output_layout().data_type;
}
std::vector<ShapeType> output_shapes = {ShapeType()};
std::vector<ShapeType> output_shapes;
std::vector<ShapeType> input_shapes = {
input_layout.get<ShapeType>(),
indices_layout.get<ShapeType>()
@@ -93,11 +93,11 @@ std::vector<layout> gather_nd_inst::calc_output_layouts(gather_nd_node const& /*
if (desc->batch_merged_output) {
ov::op::v5::GatherND op;
op.set_batch_dims(desc->batch_dims);
ov::op::v5::shape_infer(&op, input_shapes, output_shapes);
output_shapes = ov::op::v5::shape_infer(&op, input_shapes);
} else {
ov::op::v8::GatherND op;
op.set_batch_dims(desc->batch_dims);
ov::op::v8::shape_infer(&op, input_shapes, output_shapes);
output_shapes = ov::op::v8::shape_infer(&op, input_shapes);
}
OPENVINO_ASSERT(!output_shapes[0].rank().is_dynamic(),
@@ -33,14 +33,13 @@ std::vector<layout> gather_tree_inst::calc_output_layouts(gather_tree_node const
ov::op::v1::GatherTree op;
std::vector<ShapeType> output_shapes = {ShapeType()};
std::vector<ShapeType> input_shapes = {
impl_param.get_input_layout(0).get<ShapeType>(),
impl_param.get_input_layout(1).get<ShapeType>(),
impl_param.get_input_layout(2).get<ShapeType>(),
impl_param.get_input_layout(3).get<ShapeType>(),
};
ov::op::v1::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v1::shape_infer(&op, input_shapes);
format output_format = format::adjust_to_rank(input0_layout.format, output_shapes[0].size());
+1 -2
View File
@@ -101,13 +101,12 @@ std::vector<layout> gemm_inst::calc_output_layouts(gemm_node const& /*node*/, co
op.set_transpose_a(prim->transpose_input0);
op.set_transpose_b(prim->transpose_input1);
std::vector<ShapeType> output_shapes = {ShapeType()};
std::vector<ShapeType> input_shapes = {
input0_layout.get<ShapeType>(),
input1_layout.get<ShapeType>()
};
ov::op::v0::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
return { layout{output_shapes[0], output_type, input0_layout.format, prim->output_paddings[0]} };
}
@@ -53,7 +53,7 @@ std::vector<layout> non_max_suppression_inst::calc_output_layouts(non_max_suppre
// Output tensor has the following shape: [min(num_boxes, max_output_boxes_per_class) * num_batches * num_classes, 3]
// The first dimension is an upper bound for the number of possible selected boxes
bool static_output = boxes[1].is_static() && scores[0].is_static() && scores[1].is_static();
ov::op::v9::shape_infer(&op, input_shapes, output_shapes, static_output, const_data);
ov::op::v9::shape_infer(&op, input_shapes, output_shapes, static_output, ov::make_tensor_accessor(const_data));
} else {
output_shapes[0] = output_shapes[1] = ShapeType{ov::Dimension::dynamic(), 3};
output_shapes[2] = ShapeType{1};
+2 -2
View File
@@ -58,7 +58,6 @@ std::vector<layout> one_hot_inst::calc_output_layouts(const one_hot_node& /*node
op.set_axis(desc->one_hot_axis);
} catch (...) {}
std::vector<ShapeType> output_shapes = { ShapeType{} };
std::vector<ShapeType> input_shapes = {
input_layout.get_partial_shape(),
ShapeType{},
@@ -72,7 +71,8 @@ std::vector<layout> one_hot_inst::calc_output_layouts(const one_hot_node& /*node
std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>> const_data = {
{1, depth_tensor}
};
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
std::vector<ShapeType> output_shapes =
ov::op::v1::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
return {{output_shapes[0], dt, format::get_default_format(output_shapes[0].size())}};
}
@@ -508,19 +508,20 @@ std::vector<layout> prior_box_inst::calc_output_layouts(prior_box_node const& /*
}
}
const auto tensor_accessor = ov::make_tensor_accessor(const_data);
if (primitive->is_clustered()) {
ov::op::v0::PriorBoxClustered op;
op.set_attrs(primitive->get_attrs_clustered());
output_shapes = ov::op::v0::shape_infer(&op, input_shapes, const_data);
output_shapes = ov::op::v0::shape_infer(&op, input_shapes, tensor_accessor);
} else {
if (primitive->is_v8_support()) {
ov::op::v8::PriorBox op;
op.set_attrs(primitive->get_attrs_v8());
output_shapes = ov::op::v8::shape_infer(&op, input_shapes, const_data);
output_shapes = ov::op::v8::shape_infer(&op, input_shapes, tensor_accessor);
} else {
ov::op::v0::PriorBox op;
op.set_attrs(primitive->get_attrs_v0());
output_shapes = ov::op::v0::shape_infer(&op, input_shapes, const_data);
output_shapes = ov::op::v0::shape_infer(&op, input_shapes, tensor_accessor);
}
}
const auto output_type = primitive->output_data_types[0].value_or(data_types::f32);
+1 -1
View File
@@ -50,7 +50,7 @@ std::vector<layout> range_inst::calc_output_layouts(range_node const& /*node*/,
cldnn::mem_lock<uint8_t, mem_lock_type::read> step_mem_lock(step_mem, impl_param.get_stream());
const_data.emplace(2, make_host_tensor(step_mem->get_layout(), step_mem_lock.data()));
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
}
return {layout({output_shapes[0], output_data_type, impl_param.get_output_layout().format})};
+10 -9
View File
@@ -109,6 +109,7 @@ std::vector<layout> reduce_inst::calc_output_layouts(reduce_node const& /*node*/
auto axes = desc->axes;
auto axes_tensor = std::make_shared<ngraph::runtime::HostTensor>(ov::element::i64, ov::Shape{axes.size()}, axes.data());
std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>> const_data = {{1, axes_tensor}};
auto ta = ov::make_tensor_accessor(const_data);
// shape infer by mode
auto mode = desc->mode;
@@ -118,63 +119,63 @@ std::vector<layout> reduce_inst::calc_output_layouts(reduce_node const& /*node*/
{
ov::op::v1::ReduceMax op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::min:
{
ov::op::v1::ReduceMin op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::mean:
{
ov::op::v1::ReduceMean op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::prod:
{
ov::op::v1::ReduceProd op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::sum:
{
ov::op::v1::ReduceSum op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::logical_and:
{
ov::op::v1::ReduceLogicalAnd op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::logical_or:
{
ov::op::v1::ReduceLogicalOr op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::l1:
{
ov::op::v4::ReduceL1 op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::l2:
{
ov::op::v4::ReduceL2 op;
op.set_keep_dims(keep_dims);
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reduce_mode::sum_square:
@@ -52,11 +52,10 @@ std::vector<layout> region_yolo_inst::calc_output_layouts(region_yolo_node const
op.set_axis(desc->axis);
op.set_end_axis(desc->end_axis);
std::vector<ShapeType> output_shapes = { ShapeType() };
std::vector<ShapeType> input_shapes = {
input_layout.get<ShapeType>()
};
ov::op::v0::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
return { layout{output_shapes[0], output_type, output_format} };
}
+4 -3
View File
@@ -86,6 +86,7 @@ std::vector<layout> reshape_inst::calc_output_layouts(reshape_node const& /*node
};
std::map<size_t, ngraph::HostTensorPtr> const_data;
const auto ta = ov::make_tensor_accessor(const_data);
auto run_shape_infer = [&](reshape::reshape_mode mode) {
switch (mode) {
@@ -93,19 +94,19 @@ std::vector<layout> reshape_inst::calc_output_layouts(reshape_node const& /*node
ov::op::v1::Reshape op;
op.set_special_zero(prim->special_zero);
op.set_friendly_name(prim->id.c_str());
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reshape::reshape_mode::squeeze: {
ov::op::v0::Squeeze op;
op.set_friendly_name(prim->id.c_str());
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
case reshape::reshape_mode::unsqueeze: {
ov::op::v0::Unsqueeze op;
op.set_friendly_name(prim->id.c_str());
shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = shape_infer(&op, input_shapes, ta);
break;
}
default:
@@ -40,12 +40,10 @@ std::vector<layout> roi_align_inst::calc_output_layouts(roi_align_node const& no
input2_layout.get<ShapeType>() // batch indices shape
};
std::vector<ShapeType> output_shapes = {ShapeType()};
ov::op::v3::ROIAlign op;
op.set_pooled_h(primitive->pooled_h);
op.set_pooled_w(primitive->pooled_w);
shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = shape_infer(&op, input_shapes);
return { layout{output_shapes[0], input0_layout.data_type, input0_layout.format} };
}
@@ -40,12 +40,11 @@ std::vector<layout> roi_pooling_inst::calc_output_layouts(roi_pooling_node const
op.set_spatial_scale(desc->spatial_scale);
ShapeType rois_shape = impl_param.get_input_layout(1).get<ShapeType>();
std::vector<ShapeType> output_shapes = { ShapeType() };
std::vector<ShapeType> input_shapes = {
data_shape,
rois_shape
};
ov::op::v0::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
return { layout{output_shapes[0], output_type, output_format} };
}
@@ -39,10 +39,8 @@ std::vector<layout> scatter_nd_update_inst::calc_output_layouts(scatter_nd_updat
input2_layout.get<ShapeType>(), // updates_shape,
};
std::vector<ShapeType> output_shapes = {ShapeType()};
ov::op::v3::ScatterNDUpdate op;
shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = shape_infer(&op, input_shapes);
return { layout{output_shapes[0], input0_layout.data_type, input0_layout.format} };
}
+1 -2
View File
@@ -43,14 +43,13 @@ std::vector<layout> select_inst::calc_output_layouts(const select_node& /*node*/
ov::op::v1::Select op;
op.set_auto_broadcast(desc->broadcast_spec);
std::vector<ShapeType> output_shapes = { ShapeType{} };
std::vector<ShapeType> input_shapes = {
input0_layout.get<ShapeType>(),
input1_layout.get<ShapeType>(),
input2_layout.get<ShapeType>()
};
ov::op::v1::shape_infer(&op, input_shapes, output_shapes);
std::vector<ShapeType> output_shapes = ov::op::v1::shape_infer(&op, input_shapes);
return {{output_shapes[0], dt, format::get_default_format(output_shapes[0].size())}};
}
@@ -53,7 +53,7 @@ std::vector<layout> strided_slice_inst::calc_output_layouts(strided_slice_node c
ShapeType end_shape = end_data.empty() ? impl_param.get_input_layout(2).get<ShapeType>() : ov::Shape{ end_data.size() };
ShapeType strides_shape = strides_data.empty() ? impl_param.get_input_layout(3).get<ShapeType>() : ov::Shape{ strides_data.size() };
std::vector<ShapeType> output_shapes = {ShapeType{}};
std::vector<ShapeType> output_shapes;
std::vector<ShapeType> input_shapes = {
input0_shape,
begin_shape,
@@ -68,6 +68,7 @@ std::vector<layout> strided_slice_inst::calc_output_layouts(strided_slice_node c
op.set_ellipsis_mask_mask(desc->ellipsis_mask);
std::map<size_t, ngraph::HostTensorPtr> const_data;
const auto ta = ov::make_tensor_accessor(const_data);
if (!begin_data.empty() && !end_data.empty() && !strides_data.empty()) {
auto begin_tensor = make_host_tensor({ begin_shape, data_types::i64, format::bfyx }, static_cast<void*>(begin_data.data()));
auto end_tensor = make_host_tensor({ end_shape, data_types::i64, format::bfyx }, static_cast<void*>(end_data.data()));
@@ -77,7 +78,7 @@ std::vector<layout> strided_slice_inst::calc_output_layouts(strided_slice_node c
const_data.emplace(2, end_tensor);
const_data.emplace(3, strides_tensor);
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::v1::shape_infer(&op, input_shapes, ta);
} else {
auto begin_mem = constant_mem.at(1);
auto end_mem = constant_mem.at(2);
@@ -95,7 +96,7 @@ std::vector<layout> strided_slice_inst::calc_output_layouts(strided_slice_node c
const_data.emplace(2, end_tensor);
const_data.emplace(3, strides_tensor);
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
output_shapes = ov::op::v1::shape_infer(&op, input_shapes, ta);
}
auto output_format = format::get_default_format(output_shapes[0].size());