logical_reduction.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/op/op.hpp"
8 
9 namespace ngraph
10 {
11  namespace op
12  {
13  namespace util
14  {
15  /// \brief Abstract base class for logical reduction operations, i.e., operations where
16  /// chosen axes of the input tensors are eliminated (reduced out) by repeated
17  /// application of a particular binary logical operation.
18  class NGRAPH_API LogicalReduction : public Op
19  {
20  protected:
21  /// \brief Constructs a logical reduction operation.
23  /// \brief Constructs a logical reduction operation.
24  ///
25  /// \param arg Output that produces the first input tensor.
26  /// \param reduction_axes The axis positions (0-based) to be eliminated.
27  LogicalReduction(const Output<Node>& arg, const AxisSet& reduction_axes);
28  /// \brief Constructs a 'dynamic' logical reduction operation.
29  ///
30  /// \param arg Node that produces the first input tensor.
31  /// \param reduction_axes The axis positions (0-based) to be eliminated.
32  LogicalReduction(const Output<Node>& arg, const Output<Node>& reduction_axes);
33 
34  public:
35  NGRAPH_RTTI_DECLARATION;
36  void validate_and_infer_types() override;
37 
38  /// \return true if reduction axes are constant else false.
40 
41  /// \return The axis positions (0-based) to be eliminated through reduction.
42  /// \throws CheckFailure if the reduction axes are not constant. (Use
43  /// reduction_axes_constant to check.)
44  const AxisSet get_reduction_axes() const;
45  void set_reduction_axes(const AxisSet& reduction_axes);
46  };
47  } // namespace util
48  } // namespace op
49 } // namespace ngraph
A set of axes.
Definition: axis_set.hpp:19
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Root of all actual ops.
Definition: op.hpp:17
Abstract base class for logical reduction operations, i.e., operations where chosen axes of the input...
Definition: logical_reduction.hpp:19
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
const AxisSet get_reduction_axes() const
LogicalReduction(const Output< Node > &arg, const Output< Node > &reduction_axes)
Constructs a 'dynamic' logical reduction operation.
LogicalReduction()
Constructs a logical reduction operation.
LogicalReduction(const Output< Node > &arg, const AxisSet &reduction_axes)
Constructs a logical reduction operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16