Skip to content

Commit

Permalink
const type variables modification
Browse files Browse the repository at this point in the history
  • Loading branch information
liubo-intel committed Oct 4, 2021
1 parent 7afd870 commit 1baa835
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions ngraph/frontend/paddlepaddle/src/op/prior_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ std::shared_ptr<StridedSlice> make_slice(const std::shared_ptr<ngraph::Node>& no
NamedOutputs prior_box(const NodeContext& node) {
auto input = node.get_ng_input("Input");
auto Image = node.get_ng_input("Image");
auto input_shape = std::make_shared<ShapeOf>(input);
auto Image_shape = std::make_shared<ShapeOf>(Image);
auto output_shape_slice = detail::make_slice(input_shape, 2, 4);
auto image_shape_slice = detail::make_slice(Image_shape, 2, 4);
const auto input_shape = std::make_shared<ShapeOf>(input);
const auto Image_shape = std::make_shared<ShapeOf>(Image);
const auto output_shape_slice = detail::make_slice(input_shape, 2, 4);
const auto image_shape_slice = detail::make_slice(Image_shape, 2, 4);

ngraph::op::PriorBoxAttrs attrs;
attrs.min_size = node.get_attribute<std::vector<float>>("min_sizes", {});
Expand All @@ -46,57 +46,57 @@ NamedOutputs prior_box(const NodeContext& node) {

bool min_max_aspect_ratios_order = node.get_attribute<bool>("min_max_aspect_ratios_order", false);

auto ov_prior_box_node = std::make_shared<PriorBox>(output_shape_slice, image_shape_slice, attrs);
const auto ov_prior_box_node = std::make_shared<PriorBox>(output_shape_slice, image_shape_slice, attrs);

auto split_axis_node = Constant::create(i64, ngraph::Shape{}, {0});
auto node_prior_box_split = std::make_shared<Split>(ov_prior_box_node, split_axis_node, 2);
const auto split_axis_node = Constant::create(i64, ngraph::Shape{}, {0});
const auto node_prior_box_split = std::make_shared<Split>(ov_prior_box_node, split_axis_node, 2);

auto node_boxes_origin = node_prior_box_split->output(0);
auto node_variances_origin = node_prior_box_split->output(1);
const auto node_boxes_origin = node_prior_box_split->output(0);
const auto node_variances_origin = node_prior_box_split->output(1);

const auto out_shape =
std::make_shared<Concat>(NodeVector{output_shape_slice, Constant::create<int64_t>(i64, {2}, {-1, 4})}, 0);

auto node_boxes_reshape = std::make_shared<Reshape>(node_boxes_origin, out_shape, true);
auto node_variances_reshape = std::make_shared<Reshape>(node_variances_origin, out_shape, true);
const auto node_variances_reshape = std::make_shared<Reshape>(node_variances_origin, out_shape, true);

int64_t total_aspect_ratios = ngraph::op::PriorBox::normalized_aspect_ratio(attrs.aspect_ratio, attrs.flip).size();
if ((total_aspect_ratios > 1) && !attrs.min_size.empty() && !attrs.max_size.empty() &&
!min_max_aspect_ratios_order) {
std::vector<int64_t> mask{1, 1, 1, 0, 1};
int64_t min_size_len = static_cast<int64_t>(attrs.min_size.size());

auto out_shape_div_numpri = std::make_shared<Concat>(
const auto out_shape_div_numpri = std::make_shared<Concat>(
NodeVector{output_shape_slice, Constant::create<int64_t>(i64, {3}, {min_size_len, -1, 4})},
0);
auto node_boxes_div_numpri = std::make_shared<Reshape>(node_boxes_reshape, out_shape_div_numpri, true);
const auto node_boxes_div_numpri = std::make_shared<Reshape>(node_boxes_reshape, out_shape_div_numpri, true);

auto slice_begin_min = Constant::create(i64, Shape{5}, std::vector<int64_t>{0, 0, 0, 0, 0});
auto slice_end_min = std::make_shared<Concat>(
const auto slice_begin_min = Constant::create(i64, Shape{5}, std::vector<int64_t>{0, 0, 0, 0, 0});
const auto slice_end_min = std::make_shared<Concat>(
NodeVector{output_shape_slice, Constant::create<int64_t>(i64, {3}, {min_size_len, 1, 4})},
0);
auto slice_min_node =
const auto slice_min_node =
std::make_shared<StridedSlice>(node_boxes_div_numpri, slice_begin_min, slice_end_min, mask, mask);

auto slice_begin_max = Constant::create(i64, Shape{5}, std::vector<int64_t>{0, 0, 0, 1, 0});
auto slice_end_max = std::make_shared<Concat>(
const auto slice_begin_max = Constant::create(i64, Shape{5}, std::vector<int64_t>{0, 0, 0, 1, 0});
const auto slice_end_max = std::make_shared<Concat>(
NodeVector{output_shape_slice, Constant::create<int64_t>(i64, {3}, {min_size_len, 2, 4})},
0);
auto slice_max_node =
const auto slice_max_node =
std::make_shared<StridedSlice>(node_boxes_div_numpri, slice_begin_max, slice_end_max, mask, mask);

auto slice_begin_aspect_ratios = Constant::create(i64, Shape{5}, std::vector<int64_t>{0, 0, 0, 2, 0});
auto slice_end_aspect_ratios = std::make_shared<Concat>(
const auto slice_begin_aspect_ratios = Constant::create(i64, Shape{5}, std::vector<int64_t>{0, 0, 0, 2, 0});
const auto slice_end_aspect_ratios = std::make_shared<Concat>(
NodeVector{output_shape_slice,
Constant::create<int64_t>(i64, {3}, {min_size_len, 2 + (total_aspect_ratios - 1), 4})},
0);
auto slice_aspect_ratios_node = std::make_shared<StridedSlice>(node_boxes_div_numpri,
slice_begin_aspect_ratios,
slice_end_aspect_ratios,
mask,
mask);
const auto slice_aspect_ratios_node = std::make_shared<StridedSlice>(node_boxes_div_numpri,
slice_begin_aspect_ratios,
slice_end_aspect_ratios,
mask,
mask);

auto node_boxes_div_numpri_reorder =
const auto node_boxes_div_numpri_reorder =
std::make_shared<Concat>(NodeVector{slice_min_node, slice_aspect_ratios_node, slice_max_node}, 3);
node_boxes_reshape = std::make_shared<Reshape>(node_boxes_div_numpri_reorder, out_shape, true);
}
Expand Down

0 comments on commit 1baa835

Please sign in to comment.