prior_box_clustered.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/op/op.hpp"
8 
9 namespace ngraph
10 {
11  namespace op
12  {
13  struct NGRAPH_API PriorBoxClusteredAttrs
14  {
15  // widths Desired widths of prior boxes
16  // heights Desired heights of prior boxes
17  // clip Clip output to [0,1]
18  // step_widths Distance between prior box centers
19  // step_heights Distance between prior box centers
20  // offset Box offset relative to top center of image
21  // variances Values to adjust prior boxes with
22  std::vector<float> widths;
23  std::vector<float> heights;
24  bool clip = true;
25  float step_widths = 0.0f;
26  float step_heights = 0.0f;
27  float offset = 0.0f;
28  std::vector<float> variances;
29  };
30 
31  namespace v0
32  {
33  /// \brief Layer which generates prior boxes of specified sizes
34  /// normalized to input image size
35  class NGRAPH_API PriorBoxClustered : public Op
36  {
37  public:
38  static constexpr NodeTypeInfo type_info{"PriorBoxClustered", 0};
39  const NodeTypeInfo& get_type_info() const override { return type_info; }
40  PriorBoxClustered() = default;
41  /// \brief Constructs a PriorBoxClustered operation
42  ///
43  /// \param layer_shape Shape of layer for which prior boxes are computed
44  /// \param image_shape Shape of image to which prior boxes are scaled
45  /// \param attrs PriorBoxClustered attributes
46  PriorBoxClustered(const Output<Node>& layer_shape,
47  const Output<Node>& image_shape,
48  const PriorBoxClusteredAttrs& attrs);
49 
50  void validate_and_infer_types() override;
51  virtual std::shared_ptr<Node>
52  clone_with_new_inputs(const OutputVector& new_args) const override;
53  const PriorBoxClusteredAttrs& get_attrs() const { return m_attrs; }
54  virtual bool visit_attributes(AttributeVisitor& visitor) override;
55  bool evaluate(const HostTensorVector& outputs,
56  const HostTensorVector& inputs) const override;
57  bool has_evaluate() const override;
58 
59  private:
60  PriorBoxClusteredAttrs m_attrs;
61  };
62  } // namespace v0
64  } // namespace op
65 } // namespace ngraph
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:59
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Root of all actual ops.
Definition: op.hpp:17
Layer which generates prior boxes of specified sizes normalized to input image size.
Definition: prior_box_clustered.hpp:36
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:39
bool has_evaluate() const override
Allows to get information about availability of evaluate method for the current operation.
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:16
Definition: type.hpp:27
Definition: prior_box_clustered.hpp:14