hswish.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 #include "ngraph/op/util/unary_elementwise_arithmetic.hpp"
10 
11 namespace ngraph
12 {
13  namespace op
14  {
15  namespace v4
16  {
17  /// \brief A HSwish Activation Function
18  /// f(x) = x * min(max(x + 3, 0), 6) / 6 or
19  /// f(x) = x * min(ReLU(x + 3), 6) / 6
20  ///
22  {
23  public:
24  NGRAPH_RTTI_DECLARATION;
25  HSwish() = default;
26 
27  /// \brief Constructs a HSwish (hard version of Swish) operation.
28  ///
29  /// \param data Input tensor
30  HSwish(const Output<Node>& arg);
31 
32  bool visit_attributes(AttributeVisitor& visitor) override;
33 
34  virtual std::shared_ptr<Node>
35  clone_with_new_inputs(const OutputVector& new_args) const override;
36  bool evaluate(const HostTensorVector& outputs,
37  const HostTensorVector& inputs) const override;
38  bool has_evaluate() const override;
39  };
40  } // namespace v4
41  } // namespace op
42 } // 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
Abstract base class for elementwise unary arithmetic operations, i.e., operations where the same scal...
Definition: unary_elementwise_arithmetic.hpp:37
A HSwish Activation Function f(x) = x * min(max(x + 3, 0), 6) / 6 or f(x) = x * min(ReLU(x + 3),...
Definition: hswish.hpp:22
HSwish(const Output< Node > &arg)
Constructs a HSwish (hard version of Swish) operation.
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
bool has_evaluate() const override
Allows to get information about availability of evaluate method for the current operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16