prior_box_clustered.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //*****************************************************************************
16 
17 #pragma once
18 
19 #include "ngraph/op/op.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  struct NGRAPH_API PriorBoxClusteredAttrs
26  {
27  // widths Desired widths of prior boxes
28  // heights Desired heights of prior boxes
29  // clip Clip output to [0,1]
30  // step_widths Distance between prior box centers
31  // step_heights Distance between prior box centers
32  // offset Box offset relative to top center of image
33  // variances Values to adjust prior boxes with
34  std::vector<float> widths;
35  std::vector<float> heights;
36  bool clip = true;
37  float step_widths = 0.0f;
38  float step_heights = 0.0f;
39  float offset = 0.0f;
40  std::vector<float> variances;
41  };
42 
43  namespace v0
44  {
45  /// \brief Layer which generates prior boxes of specified sizes
46  /// normalized to input image size
47  class NGRAPH_API PriorBoxClustered : public Op
48  {
49  public:
50  static constexpr NodeTypeInfo type_info{"PriorBoxClustered", 0};
51  const NodeTypeInfo& get_type_info() const override { return type_info; }
52  PriorBoxClustered() = default;
53  /// \brief Constructs a PriorBoxClustered operation
54  ///
55  /// \param layer_shape Shape of layer for which prior boxes are computed
56  /// \param image_shape Shape of image to which prior boxes are scaled
57  /// \param attrs PriorBoxClustered attributes
58  PriorBoxClustered(const Output<Node>& layer_shape,
59  const Output<Node>& image_shape,
60  const PriorBoxClusteredAttrs& attrs);
61 
62  void validate_and_infer_types() override;
63  virtual std::shared_ptr<Node>
64  clone_with_new_inputs(const OutputVector& new_args) const override;
65  const PriorBoxClusteredAttrs& get_attrs() const { return m_attrs; }
66  virtual bool visit_attributes(AttributeVisitor& visitor) override;
67  bool evaluate(const HostTensorVector& outputs,
68  const HostTensorVector& inputs) const override;
69 
70  private:
71  PriorBoxClusteredAttrs m_attrs;
72  };
73  }
75  }
76 }
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:71
A handle for one of a node's outputs.
Definition: node_output.hpp:42
Root of all actual ops.
Definition: op.hpp:29
Layer which generates prior boxes of specified sizes normalized to input image size.
Definition: prior_box_clustered.hpp:48
PriorBoxClustered(const Output< Node > &layer_shape, const Output< Node > &image_shape, const PriorBoxClusteredAttrs &attrs)
Constructs a PriorBoxClustered operation.
const NodeTypeInfo & get_type_info() const override
Definition: prior_box_clustered.hpp:51
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: type.hpp:39
Definition: prior_box_clustered.hpp:26