region_yolo.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  namespace v0
14  {
15  class NGRAPH_API RegionYolo : public Op
16  {
17  public:
18  static constexpr NodeTypeInfo type_info{"RegionYolo", 0};
19  const NodeTypeInfo& get_type_info() const override { return type_info; }
20  RegionYolo() = default;
21  ///
22  /// \brief Constructs a RegionYolo operation
23  ///
24  /// \param[in] input Input
25  /// \param[in] coords Number of coordinates for each region
26  /// \param[in] classes Number of classes for each region
27  /// \param[in] regions Number of regions
28  /// \param[in] do_softmax Compute softmax
29  /// \param[in] mask Mask
30  /// \param[in] axis Axis to begin softmax on
31  /// \param[in] end_axis Axis to end softmax on
32  /// \param[in] anchors A flattened list of pairs `[width, height]` that
33  /// describes
34  /// prior box sizes.
35  ///
36  RegionYolo(const Output<Node>& input,
37  const size_t coords,
38  const size_t classes,
39  const size_t regions,
40  const bool do_softmax,
41  const std::vector<int64_t>& mask,
42  const int axis,
43  const int end_axis,
44  const std::vector<float>& anchors = std::vector<float>{});
45 
46  bool visit_attributes(AttributeVisitor& visitor) override;
47  void validate_and_infer_types() override;
48 
49  virtual std::shared_ptr<Node>
50  clone_with_new_inputs(const OutputVector& new_args) const override;
51 
52  size_t get_num_coords() const { return m_num_coords; }
53  size_t get_num_classes() const { return m_num_classes; }
54  size_t get_num_regions() const { return m_num_regions; }
55  bool get_do_softmax() const { return m_do_softmax; }
56  const std::vector<int64_t>& get_mask() const { return m_mask; }
57  const std::vector<float>& get_anchors() const { return m_anchors; }
58  int get_axis() const { return m_axis; }
59  int get_end_axis() const { return m_end_axis; }
60 
61  private:
62  size_t m_num_coords;
63  size_t m_num_classes;
64  size_t m_num_regions;
65  bool m_do_softmax;
66  std::vector<int64_t> m_mask;
67  std::vector<float> m_anchors{};
68  int m_axis;
69  int m_end_axis;
70  };
71  } // namespace v0
72  using v0::RegionYolo;
73  } // namespace op
74 } // 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
Definition: region_yolo.hpp:16
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
const NodeTypeInfo & get_type_info() const override
Definition: region_yolo.hpp:19
RegionYolo(const Output< Node > &input, const size_t coords, const size_t classes, const size_t regions, const bool do_softmax, const std::vector< int64_t > &mask, const int axis, const int end_axis, const std::vector< float > &anchors=std::vector< float >{})
Constructs a RegionYolo operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27