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