deformable_convolution.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/coordinate_diff.hpp"
20 #include "ngraph/op/op.hpp"
21 #include "ngraph/op/util/attr_types.hpp"
22 
23 namespace ngraph
24 {
25  namespace op
26  {
27  namespace v1
28  {
29  /// \brief DeformableConvolution operation.
30  class NGRAPH_API DeformableConvolution : public Op
31  {
32  public:
33  static constexpr NodeTypeInfo type_info{"DeformableConvolution", 1};
34  const NodeTypeInfo& get_type_info() const override { return type_info; }
35  /// \brief Constructs a conversion operation.
36  DeformableConvolution() = default;
37  /// \brief Constructs a conversion operation.
38  ///
39  /// \param arg Node that produces the input tensor.
40  /// \param deformable_values Node producing the deformable values tensor.
41  /// \param filters Node producing the filters(kernels) tensor wit OIZYX
42  /// layout.
43  /// \param strides Convolution strides.
44  /// \param pads_begin Amount of padding to be added to the beginning along
45  /// each axis. For example in case of a 2D input the value
46  /// of (1, 2) means that 1 element will be added to the
47  /// top and 2 elements to the left.
48  /// \param pads_end Amount of padding to be added to the end along each
49  /// axis.
50  /// \param dilations The distance in width and height between the weights
51  /// in the filters tensor.
52  /// \param auto_pad Specifies how the automatic calculation of padding
53  /// should be done.
54  /// \param group The number of groups which both output and input
55  /// should be split into.
56  /// \param deformable_group The number of groups which deformable values and
57  /// output should be split into along the channel axis.
58  DeformableConvolution(const Output<Node>& arg,
59  const Output<Node>& deformable_values,
60  const Output<Node>& filters,
61  const Strides& strides,
62  const CoordinateDiff& pads_begin,
63  const CoordinateDiff& pads_end,
64  const Strides& dilations,
65  const PadType& auto_pad = PadType::EXPLICIT,
66  const int64_t group = 1,
67  const int64_t deformable_group = 1);
68  bool visit_attributes(AttributeVisitor& visitor) override;
69 
70  void validate_and_infer_types() override;
71 
72  const Strides& get_strides() const { return m_strides; }
73  void set_strides(const Strides& strides) { m_strides = strides; }
74  const Strides& get_dilations() const { return m_dilations; }
75  void set_dilations(const Strides& dilations) { m_dilations = dilations; }
76  const CoordinateDiff& get_pads_begin() const { return m_pads_begin; }
77  void set_pads_begin(const CoordinateDiff& pads_begin) { m_pads_begin = pads_begin; }
78  const CoordinateDiff& get_pads_end() const { return m_pads_end; }
79  void set_pads_end(const CoordinateDiff& pads_end) { m_pads_end = pads_end; }
80  const PadType& get_auto_pad() const { return m_auto_pad; }
81  void set_auto_pad(const PadType& auto_pad) { m_auto_pad = auto_pad; }
82  int64_t get_group() const { return m_group; }
83  void set_group(const int64_t group) { m_group = group; }
84  int64_t get_deformable_group() const { return m_deformable_group; }
85  void set_deformable_group(const int64_t deformable_group)
86  {
87  m_deformable_group = deformable_group;
88  }
89  virtual std::shared_ptr<Node>
90  clone_with_new_inputs(const OutputVector& new_args) const override;
91 
92  protected:
93  Strides m_strides;
94  Strides m_dilations;
95  CoordinateDiff m_pads_begin;
96  CoordinateDiff m_pads_end;
97  PadType m_auto_pad;
98  int64_t m_group;
99  int64_t m_deformable_group;
100  };
101  }
102  }
103 }
ngraph::op::v1::DeformableConvolution::DeformableConvolution
DeformableConvolution()=default
Constructs a conversion operation.
ngraph::op::PadType
PadType
Padding Type used for Convolution and Pooling
Definition: attr_types.hpp:71
ngraph::op::v1::DeformableConvolution::DeformableConvolution
DeformableConvolution(const Output< Node > &arg, const Output< Node > &deformable_values, const Output< Node > &filters, const Strides &strides, const CoordinateDiff &pads_begin, const CoordinateDiff &pads_end, const Strides &dilations, const PadType &auto_pad=PadType::EXPLICIT, const int64_t group=1, const int64_t deformable_group=1)
Constructs a conversion operation.
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v1::DeformableConvolution
DeformableConvolution operation.
Definition: deformable_convolution.hpp:31
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v1::DeformableConvolution::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: deformable_convolution.hpp:34
ngraph::op::v1::DeformableConvolution::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::op::Op
Root of all actual ops.
Definition: op.hpp:29