arithmetic_reductions_keep_dims.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 #include "ngraph/op/util/arithmetic_reduction.hpp"
9 
10 namespace ngraph
11 {
12  namespace op
13  {
14  namespace util
15  {
17  {
18  protected:
19  ArithmeticReductionKeepDims() = default;
20 
21  /// \param arg The tensor to be summed.
22  /// \param reduction_axes The axis positions (0-based) to be eliminated.
23  /// \param keep_dims If set to 1 it holds axes that are used for reduction.
25  const Output<Node>& reduction_axes,
26  bool keep_dims = false);
27 
28  bool visit_attributes(AttributeVisitor& visitor) override;
29 
30  public:
31  NGRAPH_RTTI_DECLARATION;
32  void validate_and_infer_types() override;
33 
34  /// \return If set to 1 it holds axes that are used for reduction.
35  /// For each such axis, output dimension is equal to 1.
36  bool get_keep_dims() const { return m_keep_dims; }
37  void set_keep_dims(bool keep_dims) { m_keep_dims = keep_dims; }
38 
39  private:
40  bool m_keep_dims = false;
41  };
42  } // namespace util
43  } // namespace op
44 } // 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
Definition: arithmetic_reductions_keep_dims.hpp:17
bool get_keep_dims() const
Definition: arithmetic_reductions_keep_dims.hpp:36
ArithmeticReductionKeepDims(const Output< Node > &arg, const Output< Node > &reduction_axes, bool keep_dims=false)
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
Abstract base class for arithmetic reduction operations, i.e., operations where chosen axes of the in...
Definition: arithmetic_reduction.hpp:19
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16