Compute Library
 21.02
EltwiseLayerNode Class Referencefinal

Eltwise Layer node. More...

#include <EltwiseLayerNode.h>

Collaboration diagram for EltwiseLayerNode:
[legend]

Public Member Functions

 EltwiseLayerNode (const descriptors::EltwiseLayerDescriptor &descriptor)
 Constructor. More...
 
EltwiseOperation eltwise_operation () const
 Eltwise operation accessor. More...
 
ConvertPolicy convert_policy () const
 Convert policy accessor. More...
 
RoundingPolicy rounding_policy () const
 Rounding policy accessor. More...
 
ActivationLayerInfo fused_activation () const
 Returns fused activation. More...
 
QuantizationInfo output_quant_info () const
 Returns output quantization info. More...
 
void set_fused_activation (ActivationLayerInfo fused_activation)
 Sets fused activation. 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::EltwiseLayer
 

Detailed Description

Eltwise Layer node.

Definition at line 34 of file EltwiseLayerNode.h.

Constructor & Destructor Documentation

◆ EltwiseLayerNode()

Constructor.

Parameters
[in]descriptorContaining information for the node described in descriptors::EltwiseLayerDescriptor

Definition at line 34 of file EltwiseLayerNode.cpp.

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

35  : descriptor(descriptor)
36 {
37  _input_edges.resize(2, EmptyEdgeID);
38  _outputs.resize(1, NullTensorID);
39 }
constexpr EdgeID EmptyEdgeID
Definition: Types.h:75
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:71

Member Function Documentation

◆ accept()

void accept ( INodeVisitor v)
overridevirtual

Accepts a node visitor.

Parameters
[in]vVisitor to accept

Implements INode.

Definition at line 113 of file EltwiseLayerNode.cpp.

References INodeVisitor::visit().

114 {
115  v.visit(*this);
116 }

◆ 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 83 of file EltwiseLayerNode.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_MSG, ARM_COMPUTE_UNUSED, TensorShape::broadcast_shape(), Tensor::desc(), QuantizationInfo::empty(), INode::input(), EltwiseLayerDescriptor::out_quant_info, arm_compute::test::validation::output_info, TensorDescriptor::shape, and TensorShape::total_size().

Referenced by EltwiseLayerNode::forward_descriptors().

84 {
85  ARM_COMPUTE_UNUSED(idx);
86 
87  const Tensor *src1 = input(0);
88  ARM_COMPUTE_ERROR_ON(src1 == nullptr);
89 
90  const Tensor *src2 = input(1);
91  ARM_COMPUTE_ERROR_ON(src2 == nullptr);
92 
93  auto output_info = src1->desc();
94 
95  TensorShape out_shape = TensorShape::broadcast_shape(src1->desc().shape, src2->desc().shape);
96  ARM_COMPUTE_ERROR_ON_MSG(out_shape.total_size() == 0, "Inputs are not broadcast compatible");
97 
98  output_info.set_shape(out_shape);
99 
100  if(!descriptor.out_quant_info.empty())
101  {
102  output_info.set_quantization_info(descriptor.out_quant_info);
103  }
104 
105  return output_info;
106 }
static TensorShape broadcast_shape(const Shapes &... shapes)
If shapes are broadcast compatible, return the broadcasted shape.
Definition: TensorShape.h:211
#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
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
bool empty() const
Indicates whether this QuantizationInfo has valid settings or not.
QuantizationInfo out_quant_info
Output quantization information.
Tensor * input(size_t idx) const
Returns the tensor of a given input of the node.
Definition: INode.cpp:150

◆ convert_policy()

ConvertPolicy convert_policy ( ) const

Convert policy accessor.

Returns
Convert policy that is used in the node

Definition at line 46 of file EltwiseLayerNode.cpp.

References EltwiseLayerDescriptor::c_policy.

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

47 {
48  return descriptor.c_policy;
49 }

◆ eltwise_operation()

EltwiseOperation eltwise_operation ( ) const

Eltwise operation accessor.

Returns
Eltwise operation that is to be performed by the node

Definition at line 41 of file EltwiseLayerNode.cpp.

References EltwiseLayerDescriptor::op.

Referenced by arm_compute::graph::backends::detail::validate_eltwise_Layer(), and DotGraphVisitor::visit().

42 {
43  return descriptor.op;
44 }
EltwiseOperation op
Element-wise operation to perform.

◆ 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 71 of file EltwiseLayerNode.cpp.

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

72 {
73  if((input_id(0) != NullTensorID) && (input_id(1) != NullTensorID) && (output_id(0) != NullTensorID))
74  {
75  Tensor *dst = output(0);
76  ARM_COMPUTE_ERROR_ON(dst == nullptr);
77  dst->desc() = configure_output(0);
78  return true;
79  }
80  return false;
81 }
#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
Tensor * output(size_t idx) const
Returns the tensor of a given output of the node.
Definition: INode.cpp:158
TensorID input_id(size_t idx) const
Returns the tensor ID of a given input of the node.
Definition: INode.cpp:137
TensorID output_id(size_t idx) const
Returns the tensor ID of a given output of the node.
Definition: INode.cpp:144
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:71
TensorDescriptor configure_output(size_t idx) const override
Calculates output configuration.

◆ fused_activation()

ActivationLayerInfo fused_activation ( ) const

Returns fused activation.

Returns
Fused activation

Definition at line 56 of file EltwiseLayerNode.cpp.

References EltwiseLayerDescriptor::fused_activation.

Referenced by EltwiseLayerNode::set_fused_activation(), and arm_compute::graph::backends::detail::validate_eltwise_Layer().

57 {
58  return descriptor.fused_activation;
59 }
ActivationLayerInfo fused_activation
Fused activation info.

◆ output_quant_info()

QuantizationInfo output_quant_info ( ) const

Returns output quantization info.

Returns
Output quantization info

Definition at line 61 of file EltwiseLayerNode.cpp.

References EltwiseLayerDescriptor::out_quant_info.

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

62 {
63  return descriptor.out_quant_info;
64 }
QuantizationInfo out_quant_info
Output quantization information.

◆ rounding_policy()

RoundingPolicy rounding_policy ( ) const

Rounding policy accessor.

Returns
Convert policy that is used in the node

Definition at line 51 of file EltwiseLayerNode.cpp.

References EltwiseLayerDescriptor::r_policy.

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

52 {
53  return descriptor.r_policy;
54 }

◆ set_fused_activation()

void set_fused_activation ( ActivationLayerInfo  fused_activation)

Sets fused activation.

Parameters
[in]fused_activationFused activation to set

Definition at line 66 of file EltwiseLayerNode.cpp.

References EltwiseLayerNode::fused_activation(), and EltwiseLayerDescriptor::fused_activation.

67 {
69 }
ActivationLayerInfo fused_activation() const
Returns fused activation.
ActivationLayerInfo fused_activation
Fused activation info.

◆ type()

NodeType type ( ) const
overridevirtual

Returns node's type.

Returns
Node's type

Implements INode.

Definition at line 108 of file EltwiseLayerNode.cpp.

References arm_compute::graph::EltwiseLayer.

Field Documentation

◆ node_type

constexpr NodeType node_type = NodeType::EltwiseLayer
static

Definition at line 84 of file EltwiseLayerNode.h.


The documentation for this class was generated from the following files: