batch_to_space.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/node.hpp"
8 #include "ngraph/op/util/fused_op.hpp"
9 
10 namespace ngraph
11 {
12  namespace op
13  {
14  namespace v1
15  {
16  /// \brief BatchToSpace permutes data from the batch dimension of the data tensor into
17  /// spatial dimensions.
18  ///
19  /// \note Values from the batch dimension are moved in spatial blocks dimensions.
20  ///
21  /// Output node produces a tensor with shape:
22  /// `[batch / (block_shape[0] * block_shape[1] * ... * block_shape[N - 1]),
23  /// D_1 * block_shape[1] - crops_begin[1] - crops_end[1],
24  /// D_2 * block_shape[2] - crops_begin[2] - crops_end[2], ...,
25  /// D_{N - 1} * block_shape[N - 1] - crops_begin[N - 1] - crops_end[N - 1]`
26  /// of the same type as `data` input.
27  class NGRAPH_API BatchToSpace : public Op
28  {
29  public:
30  static constexpr NodeTypeInfo type_info{"BatchToSpace", 1};
31  const NodeTypeInfo& get_type_info() const override { return type_info; }
32  BatchToSpace() = default;
33  /// \brief Constructs a BatchToSpace operation.
34  ///
35  /// \param data Node producing the data tensor
36  /// \param block_shape The sizes of the block of values to be moved
37  /// \param crops_begin Specifies the amount to crop from the beginning along each
38  /// axis of `data` input
39  /// \param crops_end Specifies the amount to crop from the ending along each axis of
40  /// `data` input.
42  const Output<Node>& block_shape,
43  const Output<Node>& crops_begin,
44  const Output<Node>& crops_end);
45  bool evaluate(const HostTensorVector& outputs,
46  const HostTensorVector& inputs) const override;
47  bool has_evaluate() const override;
48 
49  void validate_and_infer_types() override;
50  std::shared_ptr<Node>
51  clone_with_new_inputs(const OutputVector& new_args) const override;
52  bool visit_attributes(AttributeVisitor& visitor) override;
53  };
54  } // namespace v1
55  } // namespace op
56 } // 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
BatchToSpace permutes data from the batch dimension of the data tensor into spatial dimensions.
Definition: batch_to_space.hpp:28
const NodeTypeInfo & get_type_info() const override
Definition: batch_to_space.hpp:31
BatchToSpace(const Output< Node > &data, const Output< Node > &block_shape, const Output< Node > &crops_begin, const Output< Node > &crops_end)
Constructs a BatchToSpace operation.
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
bool has_evaluate() const override
Allows to get information about availability of evaluate method for the current operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27