space_to_batch.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 SpaceToBatch permutes data tensor blocks of spatial data into batch
17  /// dimension.
18  ///
19  /// \note Values from spatial blocks dimensions are moved in the batch dimension.
20  ///
21  /// Output node produces a tensor with shape: tensor with shape
22  /// `[batch * block_shape[0] * block_shape[1] * ... * block_shape[N - 1],
23  /// (pads_begin[1] + D_1 + pads_end[1]) / block_shape[1],
24  /// (pads_begin[2] + D_2 + pads_end[2]) / block_shape[2], ...,
25  /// (pads_begin[N - 1] + D_{N - 1} + pads_end[N - 1]) / block_shape[N - 1]`
26  /// of the same type as `data` input.
27  class NGRAPH_API SpaceToBatch : public Op
28  {
29  public:
30  static constexpr NodeTypeInfo type_info{"SpaceToBatch", 1};
31  const NodeTypeInfo& get_type_info() const override { return type_info; }
32  SpaceToBatch() = default;
33 
34  /// \brief Constructs a SpaceToBatch operation.
35  ///
36  /// \param data Node producing the data tensor
37  /// \param block_shape The sizes of the block of values to be moved
38  /// \param pads_begin Specifies the padding for the beginning along each axis of
39  /// `data` input
40  /// \param pads_end Specifies the padding for the ending along each axis of `data`
41  /// input.
43  const Output<Node>& block_shape,
44  const Output<ngraph::Node>& pads_begin,
45  const Output<ngraph::Node>& pads_end);
46 
47  void validate_and_infer_types() override;
48  std::shared_ptr<Node>
49  clone_with_new_inputs(const OutputVector& new_args) const override;
50  bool visit_attributes(AttributeVisitor& visitor) override;
51 
52  bool evaluate(const HostTensorVector& outputs,
53  const HostTensorVector& inputs) const override;
54  bool has_evaluate() const override;
55 
56  private:
57  bool evaluate_space_to_batch(const HostTensorVector& outputs,
58  const HostTensorVector& inputs) const;
59  };
60  } // namespace v1
61  using v1::SpaceToBatch;
62  } // namespace op
63 } // 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
SpaceToBatch permutes data tensor blocks of spatial data into batch dimension.
Definition: space_to_batch.hpp:28
bool has_evaluate() const override
Allows to get information about availability of evaluate method for the current operation.
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
const NodeTypeInfo & get_type_info() const override
Definition: space_to_batch.hpp:31
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.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27