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