space_to_batch.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/node.hpp"
20 #include "ngraph/op/util/fused_op.hpp"
21 
22 namespace ngraph
23 {
24  namespace op
25  {
26  namespace v1
27  {
28  /// \brief SpaceToBatch permutes data tensor blocks of spatial data into batch
29  /// dimension.
30  ///
31  /// \note Values from spatial blocks dimensions are moved in the batch dimension.
32  ///
33  /// Output node produces a tensor with shape: tensor with shape
34  /// `[batch * block_shape[0] * block_shape[1] * ... * block_shape[N - 1],
35  /// (pads_begin[1] + D_1 + pads_end[1]) / block_shape[1],
36  /// (pads_begin[2] + D_2 + pads_end[2]) / block_shape[2], ...,
37  /// (pads_begin[N - 1] + D_{N - 1} + pads_end[N - 1]) / block_shape[N - 1]`
38  /// of the same type as `data` input.
39  class NGRAPH_API SpaceToBatch : public Op
40  {
41  public:
42  static constexpr NodeTypeInfo type_info{"SpaceToBatch", 1};
43  const NodeTypeInfo& get_type_info() const override { return type_info; }
44  SpaceToBatch() = default;
45 
46  /// \brief Constructs a SpaceToBatch operation.
47  ///
48  /// \param data Node producing the data tensor
49  /// \param block_shape The sizes of the block of values to be moved
50  /// \param pads_begin Specifies the padding for the beginning along each axis of
51  /// `data` input
52  /// \param pads_end Specifies the padding for the ending along each axis of `data`
53  /// input.
54  SpaceToBatch(const Output<Node>& data,
55  const Output<Node>& block_shape,
56  const Output<ngraph::Node>& pads_begin,
57  const Output<ngraph::Node>& pads_end);
58 
59  void validate_and_infer_types() override;
60  std::shared_ptr<Node>
61  clone_with_new_inputs(const OutputVector& new_args) const override;
62  bool visit_attributes(AttributeVisitor& visitor) override;
63  };
64  }
65  using v1::SpaceToBatch;
66  }
67 }
ngraph::op::v1::SpaceToBatch::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::v1::SpaceToBatch::SpaceToBatch
SpaceToBatch(const Output< Node > &data, const Output< Node > &block_shape, const Output< ngraph::Node > &pads_begin, const Output< ngraph::Node > &pads_end)
Constructs a SpaceToBatch operation.
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v1::SpaceToBatch
SpaceToBatch permutes data tensor blocks of spatial data into batch dimension.
Definition: space_to_batch.hpp:40
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v1::SpaceToBatch::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: space_to_batch.hpp:43
ngraph::op::Op
Root of all actual ops.
Definition: op.hpp:29