softmax.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 v1
14  {
15  class NGRAPH_API Softmax : public Op
16  {
17  public:
18  static constexpr NodeTypeInfo type_info{"Softmax", 1};
19  const NodeTypeInfo& get_type_info() const override { return type_info; }
20  Softmax()
21  : m_axis(0)
22  {
23  }
24  /// \brief Constructs a softmax operation.
25  ///
26  /// \param arg Node that produces the first input tensor.<br>
27  /// `[d0, ...]`
28  /// \param axis The axis position (0-based) on which to calculate the softmax.
29  ///
30  /// Output `[d0, ...]`
31  ///
32  Softmax(const Output<Node>& arg, const size_t axis = 1);
33 
34  bool visit_attributes(AttributeVisitor& visitor) override;
35  void validate_and_infer_types() override;
36 
37  size_t get_version() const override { return 1; }
38  virtual std::shared_ptr<Node>
39  clone_with_new_inputs(const OutputVector& new_args) const override;
40 
41  size_t get_axis() const { return m_axis; }
42  void set_axis(const size_t axis) { m_axis = axis; }
43  bool evaluate(const HostTensorVector& outputs,
44  const HostTensorVector& inputs) const override;
45  bool has_evaluate() const override;
46 
47  private:
48  size_t m_axis;
49  };
50  } // namespace v1
51  } // namespace op
52 } // 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
Definition: softmax.hpp:16
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
Softmax(const Output< Node > &arg, const size_t axis=1)
Constructs a softmax operation.
const NodeTypeInfo & get_type_info() const override
Definition: softmax.hpp:19
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
size_t get_version() const override
Definition: softmax.hpp:37
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
Definition: type.hpp:27