elu.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/node.hpp"
8 #include "ngraph/op/op.hpp"
9 
10 namespace ngraph
11 {
12  namespace op
13  {
14  namespace v0
15  {
16  /// \brief Exponential Linear Unit
17  /// x < 0 => f(x) = alpha * (exp(x) - 1.)
18  /// x >= 0 => f(x) = x
19  ///
20  class NGRAPH_API Elu : public ngraph::op::Op
21  {
22  public:
23  static constexpr NodeTypeInfo type_info{"Elu", 0};
24  const NodeTypeInfo& get_type_info() const override { return type_info; }
25  Elu() = default;
26  /// \brief Constructs an Elu operation.
27  ///
28  /// \param data Input tensor
29  /// \param alpha Multiplier for negative values
30  Elu(const Output<Node>& data, const double alpha);
31 
32  bool visit_attributes(AttributeVisitor& visitor) override;
33  void validate_and_infer_types() override;
34 
35  virtual std::shared_ptr<Node>
36  clone_with_new_inputs(const OutputVector& new_args) const override;
37 
38  double get_alpha() const { return m_alpha; }
39 
40  private:
41  double m_alpha;
42  };
43  } // namespace v0
44  using v0::Elu;
45  } // namespace op
46 } // 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
Root of all actual ops.
Definition: op.hpp:17
Exponential Linear Unit x < 0 => f(x) = alpha * (exp(x) - 1.) x >= 0 => f(x) = x.
Definition: elu.hpp:21
Elu(const Output< Node > &data, const double alpha)
Constructs an Elu operation.
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
const NodeTypeInfo & get_type_info() const override
Definition: elu.hpp:24
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27