ArmNN
 24.08
ShapesAreBroadcastCompatible Struct Reference

#include <LayerSupportRules.hpp>

Inheritance diagram for ShapesAreBroadcastCompatible:
[legend]
Collaboration diagram for ShapesAreBroadcastCompatible:
[legend]

Public Member Functions

unsigned int CalcInputSize (const TensorShape &in, const TensorShape &out, unsigned int idx)
 
 ShapesAreBroadcastCompatible (const TensorInfo &in0, const TensorInfo &in1, const TensorInfo &out)
 
- Public Member Functions inherited from Rule
bool operator() () const
 

Additional Inherited Members

- Public Attributes inherited from Rule
bool m_Res = true
 

Detailed Description

Definition at line 153 of file LayerSupportRules.hpp.

Constructor & Destructor Documentation

◆ ShapesAreBroadcastCompatible()

ShapesAreBroadcastCompatible ( const TensorInfo in0,
const TensorInfo in1,
const TensorInfo out 
)
inline

Definition at line 162 of file LayerSupportRules.hpp.

163  {
164  const TensorShape& shape0 = in0.GetShape();
165  const TensorShape& shape1 = in1.GetShape();
166  const TensorShape& outShape = out.GetShape();
167 
168  for (unsigned int i=0; i < outShape.GetNumDimensions() && m_Res; i++)
169  {
170  unsigned int sizeOut = outShape[i];
171  unsigned int sizeIn0 = CalcInputSize(shape0, outShape, i);
172  unsigned int sizeIn1 = CalcInputSize(shape1, outShape, i);
173 
174  m_Res &= ((sizeIn0 == sizeOut) || (sizeIn0 == 1)) &&
175  ((sizeIn1 == sizeOut) || (sizeIn1 == 1));
176  }
177  }

References ShapesAreBroadcastCompatible::CalcInputSize(), TensorShape::GetNumDimensions(), TensorInfo::GetShape(), and Rule::m_Res.

Member Function Documentation

◆ CalcInputSize()

unsigned int CalcInputSize ( const TensorShape in,
const TensorShape out,
unsigned int  idx 
)
inline

Definition at line 155 of file LayerSupportRules.hpp.

156  {
157  unsigned int offset = out.GetNumDimensions() - in.GetNumDimensions();
158  unsigned int sizeIn = (idx < offset) ? 1 : in[idx-offset];
159  return sizeIn;
160  }

References TensorShape::GetNumDimensions().

Referenced by ShapesAreBroadcastCompatible::ShapesAreBroadcastCompatible().


The documentation for this struct was generated from the following file:
armnn::Rule::m_Res
bool m_Res
Definition: LayerSupportRules.hpp:54
armnn::ShapesAreBroadcastCompatible::CalcInputSize
unsigned int CalcInputSize(const TensorShape &in, const TensorShape &out, unsigned int idx)
Definition: LayerSupportRules.hpp:155