arithmetic_reduction.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 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/op/op.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  namespace util
26  {
27  /// \brief Abstract base class for arithmetic reduction operations, i.e., operations
28  /// where chosen axes of the input tensors are eliminated (reduced out) by
29  /// repeated application of a particular binary arithmetic operation.
30  class NGRAPH_API ArithmeticReduction : public Op
31  {
32  protected:
33  /// \brief Constructs an arithmetic reduction operation.
35 
36  /// \brief Constructs an arithmetic reduction operation.
37  ///
38  /// \param arg Output that produces the first input tensor.
39  /// \param reduction_axes The axis positions (0-based) to be eliminated.
40  ArithmeticReduction(const Output<Node>& arg, const AxisSet& reduction_axes);
41  /// \brief Constructs an arithmetic reduction operation.
42  ///
43  /// \param arg Output that produces the first input tensor.
44  /// \param reduction_axes The axis positions (0-based) to be eliminated.
45  ArithmeticReduction(const Output<Node>& arg, const Output<Node>& reduction_axes);
46 
47  public:
48  void validate_and_infer_types() override;
49 
50  /// \return true if reduction axes are constant else false.
52 
53  /// \return The axis positions (0-based) to be eliminated through reduction.
54  /// \throws CheckFailure if the reduction axes are not constant. (Use
55  /// reduction_axes_constant to check.)
56  const AxisSet get_reduction_axes() const;
57 
58  /// \brief Change the reduction axes
59  void set_reduction_axes(const AxisSet& reduction_axes);
60  };
61  }
62  }
63 }
A set of axes.
Definition: axis_set.hpp:31
A handle for one of a node's outputs.
Definition: node_output.hpp:42
Root of all actual ops.
Definition: op.hpp:29
Abstract base class for arithmetic reduction operations, i.e., operations where chosen axes of the in...
Definition: arithmetic_reduction.hpp:31
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
void set_reduction_axes(const AxisSet &reduction_axes)
Change the reduction axes.
const AxisSet get_reduction_axes() const
ArithmeticReduction()
Constructs an arithmetic reduction operation.
ArithmeticReduction(const Output< Node > &arg, const Output< Node > &reduction_axes)
Constructs an arithmetic reduction operation.
ArithmeticReduction(const Output< Node > &arg, const AxisSet &reduction_axes)
Constructs an arithmetic reduction operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28