Compute Library
 23.11
SoftmaxLayerNode Class Referencefinal

Softmax Layer node. More...

#include <SoftmaxLayerNode.h>

Collaboration diagram for SoftmaxLayerNode:
[legend]

Public Member Functions

 SoftmaxLayerNode (float beta=1.f)
 Constructor. More...
 
float beta () const
 Beta parameter accessor. More...
 
NodeType type () const override
 Returns node's type. More...
 
bool forward_descriptors () override
 Forwards descriptor information to outputs if possible. More...
 
TensorDescriptor configure_output (size_t idx) const override
 Calculates output configuration. More...
 
void accept (INodeVisitor &v) override
 Accepts a node visitor. More...
 
- Public Member Functions inherited from INode
 INode ()
 Constructor. More...
 
virtual ~INode ()=default
 Destructor. More...
 
 INode (const INode &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INodeoperator= (const INode &)=delete
 Prevent instances of this class from being copy assigned (As this class contains pointers) More...
 
 INode (INode &&)=default
 Allow instances of this class to be moved. More...
 
INodeoperator= (INode &&)=default
 Allow instances of this class to be move assigned. More...
 
virtual Status validate () const
 Validate node. More...
 
std::string name () const
 Returns node's name. More...
 
NodeID id () const
 Returns node's ID. More...
 
const Graphgraph () const
 Returns node's Graph. More...
 
Graphgraph ()
 Returns node's Graph. More...
 
void set_graph (Graph *g)
 Sets the graph that this node is registered to. More...
 
void set_id (NodeID id)
 Sets the node id. More...
 
void set_common_node_parameters (NodeParams common_params)
 Sets common node parameters. More...
 
void set_requested_target (Target target)
 Sets target preference. More...
 
void set_assigned_target (Target target)
 Sets the final execution target. More...
 
void set_output_tensor (TensorID tid, size_t idx)
 Sets the output tensor of at a given index. More...
 
const std::vector< TensorID > & inputs () const
 Returns inputs of the node. More...
 
const std::vector< TensorID > & outputs () const
 Returns outputs of the node. More...
 
const std::vector< EdgeID > & input_edges () const
 Returns input edge set. More...
 
const std::set< EdgeID > & output_edges () const
 Returns output edge set. More...
 
TensorID input_id (size_t idx) const
 Returns the tensor ID of a given input of the node. More...
 
TensorID output_id (size_t idx) const
 Returns the tensor ID of a given output of the node. More...
 
Tensorinput (size_t idx) const
 Returns the tensor of a given input of the node. More...
 
Tensoroutput (size_t idx) const
 Returns the tensor of a given output of the node. More...
 
EdgeID input_edge_id (size_t idx) const
 Returns the edge ID of a given input of the node. More...
 
Edgeinput_edge (size_t idx) const
 Returns the edge of a given input of the node. More...
 
size_t num_inputs () const
 Returns number of inputs of the node. More...
 
size_t num_outputs () const
 Returns number of outputs of the node. More...
 
NodeParams common_node_params () const
 Returns common node parameters. More...
 
Target requested_target () const
 Returns requested target for this node. More...
 
Target assigned_target () const
 Returns assigned target for this node. More...
 

Static Public Attributes

static constexpr NodeType node_type = NodeType::SoftmaxLayer
 

Detailed Description

Softmax Layer node.

Definition at line 34 of file SoftmaxLayerNode.h.

Constructor & Destructor Documentation

◆ SoftmaxLayerNode()

SoftmaxLayerNode ( float  beta = 1.f)

Constructor.

Parameters
[in]beta(Optional) Beta parameter. Defaults to 1

Definition at line 34 of file SoftmaxLayerNode.cpp.

34  : _beta(beta)
35 {
36  _input_edges.resize(1, EmptyEdgeID);
37  _outputs.resize(1, NullTensorID);
38 }

References arm_compute::graph::EmptyEdgeID, and arm_compute::graph::NullTensorID.

Member Function Documentation

◆ accept()

void accept ( INodeVisitor v)
overridevirtual

Accepts a node visitor.

Parameters
[in]vVisitor to accept

Implements INode.

Definition at line 76 of file SoftmaxLayerNode.cpp.

77 {
78  v.visit(*this);
79 }

References INodeVisitor::visit().

◆ beta()

float beta ( ) const

Beta parameter accessor.

Returns
Beta parameter

Definition at line 40 of file SoftmaxLayerNode.cpp.

41 {
42  return _beta;
43 }

Referenced by arm_compute::graph::backends::detail::create_softmax_layer().

◆ configure_output()

TensorDescriptor configure_output ( size_t  idx) const
overridevirtual

Calculates output configuration.

Parameters
[in]idxOutput index to configure
Returns
Output descriptor configuration

Implements INode.

Definition at line 57 of file SoftmaxLayerNode.cpp.

58 {
59  ARM_COMPUTE_UNUSED(idx);
60  ARM_COMPUTE_ERROR_ON(idx >= _outputs.size());
61 
62  const Tensor *src = input(0);
63  ARM_COMPUTE_ERROR_ON(src == nullptr);
64 
65  TensorDescriptor out_desc = src->desc();
66  out_desc.quant_info = get_softmax_output_quantization_info(out_desc.data_type, false);
67 
68  return out_desc;
69 }

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, TensorDescriptor::data_type, arm_compute::get_softmax_output_quantization_info(), INode::input(), TensorDescriptor::quant_info, and arm_compute::test::validation::src.

Referenced by SoftmaxLayerNode::forward_descriptors().

◆ forward_descriptors()

bool forward_descriptors ( )
overridevirtual

Forwards descriptor information to outputs if possible.

Returns
True if descriptor information could be forwarded otherwise false

Implements INode.

Definition at line 45 of file SoftmaxLayerNode.cpp.

46 {
47  if ((input_id(0) != NullTensorID) && (output_id(0) != NullTensorID))
48  {
49  Tensor *dst = output(0);
50  ARM_COMPUTE_ERROR_ON(dst == nullptr);
51  dst->desc() = configure_output(0);
52  return true;
53  }
54  return false;
55 }

References ARM_COMPUTE_ERROR_ON, SoftmaxLayerNode::configure_output(), arm_compute::test::validation::dst, INode::input_id(), arm_compute::graph::NullTensorID, INode::output(), and INode::output_id().

◆ type()

NodeType type ( ) const
overridevirtual

Returns node's type.

Returns
Node's type

Implements INode.

Definition at line 71 of file SoftmaxLayerNode.cpp.

72 {
74 }

References arm_compute::graph::SoftmaxLayer.

Referenced by arm_compute::graph::backends::detail::create_softmax_layer().

Field Documentation

◆ node_type

constexpr NodeType node_type = NodeType::SoftmaxLayer
staticconstexpr

Definition at line 55 of file SoftmaxLayerNode.h.


The documentation for this class was generated from the following files:
arm_compute::graph::EmptyEdgeID
constexpr EdgeID EmptyEdgeID
Definition: Types.h:81
arm_compute::test::validation::src
SimpleTensor< float > src
Definition: DFT.cpp:155
arm_compute::graph::INode::input_id
TensorID input_id(size_t idx) const
Returns the tensor ID of a given input of the node.
Definition: INode.cpp:137
arm_compute::test::validation::dst
auto dst
Definition: DFT.cpp:170
arm_compute::graph::INode::output
Tensor * output(size_t idx) const
Returns the tensor of a given output of the node.
Definition: INode.cpp:158
ARM_COMPUTE_ERROR_ON
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
arm_compute::get_softmax_output_quantization_info
QuantizationInfo get_softmax_output_quantization_info(DataType input_type, bool is_log)
Returns output quantization information for softmax layer.
Definition: Utils.cpp:421
arm_compute::detail::ObjectType::Tensor
@ Tensor
arm_compute::graph::NodeType::SoftmaxLayer
@ SoftmaxLayer
ARM_COMPUTE_UNUSED
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:151
arm_compute::graph::SoftmaxLayerNode::beta
float beta() const
Beta parameter accessor.
Definition: SoftmaxLayerNode.cpp:40
arm_compute::graph::SoftmaxLayerNode::configure_output
TensorDescriptor configure_output(size_t idx) const override
Calculates output configuration.
Definition: SoftmaxLayerNode.cpp:57
arm_compute::graph::INode::input
Tensor * input(size_t idx) const
Returns the tensor of a given input of the node.
Definition: INode.cpp:150
arm_compute::graph::INode::output_id
TensorID output_id(size_t idx) const
Returns the tensor ID of a given output of the node.
Definition: INode.cpp:144
arm_compute::graph::NullTensorID
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:77