Deprecate nGraph v0 ops and builders (#1856)
[platform/upstream/dldt.git] / ngraph / core / include / ngraph / op / sum.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/axis_set.hpp"
20 #include "ngraph/op/op.hpp"
21 #include "ngraph/op/util/arithmetic_reduction.hpp"
22
23 namespace ngraph
24 {
25     namespace op
26     {
27         namespace v0
28         {
29             // clang-format off
30             /// \brief Tensor sum operation.
31             ///
32             /// Element-wise sums the input tensor, eliminating the specified reduction axes.
33             /// For example:
34             ///
35             /// \f[
36             ///     \mathit{sum}\left(\{0\},
37             ///         \left[ \begin{array}{ccc}
38             ///                1 & 2 \\ 3 & 4 \\ 5 & 6 \end{array} \right]\right) =
39             ///     \left[ (1 + 3 + 5), (2 + 4 + 6) \right] =
40             ///     \left[ 9, 12 \right]~~~\text{(dimension 0 (rows) is eliminated)}
41             /// \f]
42             ///
43             /// \f[
44             ///     \mathit{sum}\left(\{1\},
45             ///         \left[ \begin{array}{ccc}
46             ///                1 & 2 \\ 3 & 4 \\ 5 & 6 \end{array} \right]\right) =
47             ///     \left[ (1 + 2), (3 + 4), (5 + 6) \right] =
48             ///     \left[ 3, 7, 11 \right]~~~\text{(dimension 1 (columns) is eliminated)}
49             /// \f]
50             ///
51             /// \f[
52             ///     \mathit{sum}\left(\{0,1\},
53             ///         \left[ \begin{array}{ccc}
54             ///                1 & 2 \\ 3 & 4 \\ 5 & 6 \end{array} \right]\right) =
55             ///      (1 + 2) + (3 + 4) + (5 + 6) =
56             ///      21~~~\text{(both dimensions (rows and columns) are eliminated)}
57             /// \f]
58             ///
59             /// ## Parameters
60             ///
61             /// |                      | Description                              |
62             /// | -------------------- | ---------------------------------------- |
63             /// | `reduction_axes`     | The axes to eliminate through summation. |
64             ///
65             /// ## Inputs
66             ///
67             /// |       | Type                              | Description                                            |
68             /// | ----- | --------------------------------- | ------------------------------------------------------ |
69             /// | `arg` | \f$N[d_1,\dots,d_n]~(n \geq 0)\f$ | An input tensor of any shape and numeric element type. |
70             ///
71             /// ## Output
72             ///
73             /// | Type                                      | Description                                                                                                      |
74             /// | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
75             /// | \f$N[\textit{delete}(A,d_1,\dots,d_n)]\f$ | The tensor \f$T\f$, where \f$T\f$ is the input tensor with the `reduction_axes` \f$A\f$ eliminated by summation. |
76             // clang-format off
77             class NGRAPH_DEPRECATED("This operation is deprecated and will be removed soon. "
78                                     "Use v1::ReduceSum instead of it.") NGRAPH_API Sum : public util::ArithmeticReduction
79             {
80                 NGRAPH_SUPPRESS_DEPRECATED_START
81             public:
82                 static constexpr NodeTypeInfo type_info{ "Sum", 0 };
83                 const NodeTypeInfo& get_type_info() const override { return type_info; }
84                 /// \brief Constructs a summation operation.
85                 Sum() = default;
86                 /// \brief Constructs a summation operation.
87                 ///
88                 /// \param arg The tensor to be summed.
89                 /// \param reduction_axes The axis positions (0-based) to be eliminated.
90                 Sum(const Output<Node>& arg, const AxisSet& reduction_axes);
91                 /// \brief Constructs a summation operation.
92                 ///
93                 /// \param arg The tensor to be summed.
94                 /// \param reduction_axes The axis positions (0-based) to be eliminated.
95                 Sum(const Output<Node>& arg, const Output<Node>& reduction_axes);
96
97                 virtual std::shared_ptr<Node>
98                     clone_with_new_inputs(const OutputVector& new_args) const override;
99
100                 /// \return The default value for Sum.
101                 virtual std::shared_ptr<Node> get_default_value() const override;
102
103                 bool evaluate(const HostTensorVector& outputs,
104                               const HostTensorVector& inputs) const override;
105                 NGRAPH_SUPPRESS_DEPRECATED_END
106             };
107         }
108         // default opset version
109         NGRAPH_SUPPRESS_DEPRECATED_START
110         using v0::Sum;
111         NGRAPH_SUPPRESS_DEPRECATED_END
112     }
113 }