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