ArmNN
 23.11
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 154 of file LayerSupportRules.hpp.

Constructor & Destructor Documentation

◆ ShapesAreBroadcastCompatible()

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

Definition at line 163 of file LayerSupportRules.hpp.

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

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 156 of file LayerSupportRules.hpp.

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

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:55
armnn::ShapesAreBroadcastCompatible::CalcInputSize
unsigned int CalcInputSize(const TensorShape &in, const TensorShape &out, unsigned int idx)
Definition: LayerSupportRules.hpp:156