ArmNN
 23.05
armnnUtils Namespace Reference

Namespaces

 Filesystem
 

Classes

class  DataLayoutIndexed
 Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout. More...
 
class  FloatingPointConverter
 
struct  IsFloatingPointIterator
 
class  ModelAccuracyChecker
 
struct  ParserPrototxtFixture
 
struct  SelectiveQuantizer
 
struct  SelectiveQuantizer< armnn::BFloat16, false >
 
struct  SelectiveQuantizer< armnn::Half, false >
 
struct  SelectiveQuantizer< T, false >
 

Typedefs

using TContainer = mapbox::util::variant< std::vector< float >, std::vector< int >, std::vector< unsigned char >, std::vector< int8_t > >
 
using LabelCategoryNames = std::vector< std::string >
 

Functions

template<typename T >
bool CompatibleTypes (armnn::DataType)
 
bool operator== (const armnn::DataLayout &dataLayout, const DataLayoutIndexed &indexed)
 Equality methods. More...
 
bool operator== (const DataLayoutIndexed &indexed, const armnn::DataLayout &dataLayout)
 
bool within_percentage_tolerance (float a, float b, float tolerancePercent=1.0f)
 Compare two floats and return true if their values are within a specified tolerance of each other. More...
 
armnn::TensorShape Permuted (const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
 
armnn::TensorInfo Permuted (const armnn::TensorInfo &info, const armnn::PermutationVector &mappings)
 
void Permute (const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
 
template<typename T >
SelectiveQuantize (float value, float scale, int32_t offset)
 
template<typename T >
float SelectiveDequantize (T value, float scale, int32_t offset)
 
template<typename T , typename FloatIt , typename std::enable_if< IsFloatingPointIterator< FloatIt >::value, int >::type = 0>
std::vector< T > QuantizedVector (FloatIt first, FloatIt last, float qScale, int32_t qOffset)
 
template<typename T >
std::vector< T > QuantizedVector (const std::vector< float > &array, float qScale=1.f, int32_t qOffset=0)
 
template<typename T >
std::vector< T > QuantizedVector (std::initializer_list< float > array, float qScale=1.f, int32_t qOffset=0)
 
armnn::TensorShape GetTensorShape (unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout)
 
armnn::TensorInfo GetTensorInfo (unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
 
armnn::TensorInfo GetTensorInfo (unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int depth, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
 
std::pair< float, float > FindMinMax (armnn::ITensorHandle *tensorHandle)
 
armnn::TensorShape ReduceDims (const armnn::TensorShape &tensorInfo, unsigned int dimensions)
 
armnn::TensorInfo ReduceDims (const armnn::TensorInfo &tensorInfo, unsigned int dimensions)
 
armnn::TensorShape ExpandDims (const armnn::TensorShape &tensorShape, int axis)
 
armnn::TensorShape ExpandDimsToRank (const armnn::TensorShape &tensorShape, unsigned int rank)
 
std::vector< unsigned int > SqueezeDims (const armnn::TensorShape &tensorShape)
 
unsigned int GetNumElementsBetween (const armnn::TensorShape &shape, unsigned int firstAxisInclusive, unsigned int lastAxisExclusive)
 
unsigned int GetUnsignedAxis (const unsigned int inputDimension, const int axis)
 
unsigned int GetNumElementsAfter (const armnn::TensorShape &shape, unsigned int axis)
 
std::pair< unsigned int, std::vector< float > > GetPerAxisParams (const armnn::TensorInfo &info)
 
template<typename PrimitiveType >
std::unique_ptr< float[]> ToFloatArray (const std::vector< PrimitiveType > &data, const armnn::TensorInfo &tensorInfo)
 
std::unique_ptr< float[]> ToFloatArray (const std::vector< uint8_t > &data, const armnn::TensorInfo &tensorInfo)
 
armnn::TensorShape TransposeTensorShape (const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
 
armnn::TensorInfo TransposeTensorShape (const armnn::TensorInfo &info, const armnn::PermutationVector &mappings)
 
void Transpose (const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
 
template<>
bool CompatibleTypes< float > (DataType dataType)
 
template<>
bool CompatibleTypes< Half > (DataType dataType)
 
template<>
bool CompatibleTypes< BFloat16 > (DataType dataType)
 
template<>
bool CompatibleTypes< uint8_t > (DataType dataType)
 
template<>
bool CompatibleTypes< int8_t > (DataType dataType)
 
template<>
bool CompatibleTypes< int16_t > (DataType dataType)
 
template<>
bool CompatibleTypes< int32_t > (DataType dataType)
 
template<typename TNodeId , typename TTargetNodes >
bool GraphTopologicalSort (const TTargetNodes &targetNodes, std::function< std::vector< TNodeId >(TNodeId)> getIncomingEdges, std::vector< TNodeId > &outSorted)
 
std::vector< std::string > SplitBy (const std::string &originalString, const std::string &delimiter=" ", bool includeEmptyToken=false)
 Split a string into tokens by a delimiter. More...
 
std::string Strip (const std::string &originalString, const std::string &characterSet=" ")
 Remove any preceding and trailing character specified in the characterSet. More...
 
void ProcessConcatInputTensorInfo (armnn::TensorInfo &inputTensorInfo, armnn::OriginsDescriptor &concatDescriptor, const unsigned int &concatAxis, unsigned int inputIndex, unsigned int &mergeDimOrigin)
 
void CalculateReducedOutputTensoInfo (const armnn::TensorInfo &inputTensorInfo, const std::set< unsigned int > &axisSet, bool keepDims, armnn::TensorInfo &outputTensorInfo)
 Creates a tensor info after reducing the dimensions mentioned in axisData. More...
 
void CalculateStridedSliceOutputTensorInfo (const armnn::TensorInfo &inputTensorInfo, const armnn::StridedSliceDescriptor &desc, armnn::TensorInfo &outputTensorInfo)
 Create output tensor info for a StridedSlice operator. More...
 
std::string ConvertInt32ToOctalString (int value)
 Converts an int value into the Prototxt octal representation. More...
 
std::string ConvertTensorShapeToString (const armnn::TensorShape &shape)
 Converts an TensorShape into Prototxt representation. More...
 
template<typename TContainer >
armnn::InputTensors MakeInputTensors (const std::vector< armnn::BindingPointInfo > &inputBindings, const std::vector< TContainer > &inputDataContainers)
 
template<typename TContainer >
armnn::OutputTensors MakeOutputTensors (const std::vector< armnn::BindingPointInfo > &outputBindings, std::vector< TContainer > &outputDataContainers)
 
template<typename PrimitiveType >
void CheckSizes (const std::vector< PrimitiveType > &data, const armnn::TensorInfo &tensorInfo, unsigned int size=1)
 
void CheckValidSize (std::initializer_list< size_t > validInputCounts, size_t actualValue, const char *validExpr, const char *actualExpr, const CheckLocation &location)
 
uint32_t NonNegative (const char *expr, int32_t value, const CheckLocation &location)
 
int32_t VerifyInt32 (const char *expr, int64_t value, const armnn::CheckLocation &location)
 

Variables

const armnn::PermutationVector NHWCToArmNN = { 0, 2, 3, 1 }
 
const armnn::PermutationVector ArmNNToNHWC = { 0, 3, 1, 2 }
 

Typedef Documentation

◆ LabelCategoryNames

using LabelCategoryNames = std::vector<std::string>

Definition at line 25 of file ModelAccuracyChecker.hpp.

◆ TContainer

using TContainer = mapbox::util::variant<std::vector<float>, std::vector<int>, std::vector<unsigned char>, std::vector<int8_t> >

Definition at line 18 of file TContainer.hpp.

Function Documentation

◆ CalculateReducedOutputTensoInfo()

void CalculateReducedOutputTensoInfo ( const armnn::TensorInfo inputTensorInfo,
const std::set< unsigned int > &  axisSet,
bool  keepDims,
armnn::TensorInfo outputTensorInfo 
)

Creates a tensor info after reducing the dimensions mentioned in axisData.

Definition at line 52 of file ParserHelper.cpp.

56 {
57  std::vector<unsigned int> outputShapeVector;
58  bool dimensionFound = false;
59  unsigned int size = 1;
60 
61  for (unsigned int i = 0; i < inputTensorInfo.GetNumDimensions(); ++i)
62  {
63  dimensionFound = false;
64  for (unsigned int axis: axisSet)
65  {
66  if (axis == i)
67  {
68  dimensionFound = true;
69  break;
70  }
71  }
72 
73  if (!dimensionFound)
74  {
75  size *= inputTensorInfo.GetShape()[i];
76 
77  if (keepDims)
78  {
79  outputShapeVector.push_back(inputTensorInfo.GetShape()[i]);
80  }
81  }
82  else
83  {
84  if (keepDims)
85  {
86  outputShapeVector.push_back(1);
87  }
88  }
89  }
90 
91  if (keepDims)
92  {
93  armnn::TensorShape outputTensorShape(inputTensorInfo.GetNumDimensions(), &outputShapeVector[0]);
94  outputTensorInfo = armnn::TensorInfo(outputTensorShape, inputTensorInfo.GetDataType());
95  }
96  else
97  {
98  outputTensorInfo = armnn::TensorInfo({size}, inputTensorInfo.GetDataType());
99  }
100 }

References TensorInfo::GetDataType(), TensorInfo::GetNumDimensions(), and TensorInfo::GetShape().

◆ CalculateStridedSliceOutputTensorInfo()

void CalculateStridedSliceOutputTensorInfo ( const armnn::TensorInfo inputTensorInfo,
const armnn::StridedSliceDescriptor desc,
armnn::TensorInfo outputTensorInfo 
)

Create output tensor info for a StridedSlice operator.

Definition at line 103 of file ParserHelper.cpp.

106 {
107  const armnn::TensorShape& inputShape = inputTensorInfo.GetShape();
108 
109  std::vector<unsigned int> outputShapeVector;
110  for (unsigned int i = 0; i < inputTensorInfo.GetNumDimensions(); i++)
111  {
112  if (desc.m_ShrinkAxisMask & (1 << i))
113  {
114  continue;
115  }
116 
117  int stride = desc.m_Stride[i];
118  int start = desc.GetStartForAxis(inputShape, i);
119  int stop = desc.GetStopForAxis(inputShape, i, start);
120 
121  int newSize = stride > 0 ? ((stop - start) + stride - 1) / stride :
122  ((start - stop) - stride - 1) / -stride;
123 
124  newSize = std::max(0, newSize);
125 
126  outputShapeVector.push_back(static_cast<unsigned int>(newSize));
127  }
128 
129  armnn::TensorShape outputTensorShape(inputTensorInfo.GetNumDimensions(), &outputShapeVector[0]);
130  outputTensorInfo = armnn::TensorInfo(armnn::TensorShape(outputTensorShape), inputTensorInfo.GetDataType());
131 }

References TensorInfo::GetDataType(), TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), StridedSliceDescriptor::GetStartForAxis(), StridedSliceDescriptor::GetStopForAxis(), StridedSliceDescriptor::m_ShrinkAxisMask, and StridedSliceDescriptor::m_Stride.

◆ CheckSizes()

void armnnUtils::CheckSizes ( const std::vector< PrimitiveType > &  data,
const armnn::TensorInfo tensorInfo,
unsigned int  size = 1 
)

Definition at line 262 of file TensorUtils.cpp.

263 {
264  if (data.size() / size != tensorInfo.GetNumElements())
265  {
267  fmt::format("The data does not contain the expected number of elements {} != {}. {}",
268  data.size(), tensorInfo.GetNumElements(), CHECK_LOCATION().AsString()));
269  }
270 }

References CHECK_LOCATION, and TensorInfo::GetNumElements().

Referenced by ToFloatArray().

◆ CheckValidSize()

void CheckValidSize ( std::initializer_list< size_t >  validInputCounts,
size_t  actualValue,
const char *  validExpr,
const char *  actualExpr,
const CheckLocation location 
)

Definition at line 16 of file VerificationHelpers.cpp.

21 {
22  bool isValid = std::any_of(validInputCounts.begin(),
23  validInputCounts.end(),
24  [&actualValue](size_t x) { return x == actualValue; } );
25  if (!isValid)
26  {
27  throw ParseException(fmt::format("{} = {} is not valid, not in {{}}. {}",
28  actualExpr,
29  actualValue,
30  validExpr,
31  location.AsString()));
32  }
33 }

References CheckLocation::AsString().

◆ CompatibleTypes()

bool CompatibleTypes ( armnn::DataType  )

Definition at line 17 of file CompatibleTypes.cpp.

18 {
19  return false;
20 }

◆ CompatibleTypes< BFloat16 >()

Definition at line 35 of file CompatibleTypes.cpp.

36 {
37  return dataType == DataType::BFloat16;
38 }

References armnn::BFloat16.

◆ CompatibleTypes< float >()

bool armnnUtils::CompatibleTypes< float > ( DataType  dataType)

Definition at line 23 of file CompatibleTypes.cpp.

24 {
25  return dataType == DataType::Float32;
26 }

References armnn::Float32.

◆ CompatibleTypes< Half >()

bool armnnUtils::CompatibleTypes< Half > ( DataType  dataType)

Definition at line 29 of file CompatibleTypes.cpp.

30 {
31  return dataType == DataType::Float16;
32 }

References armnn::Float16.

◆ CompatibleTypes< int16_t >()

bool armnnUtils::CompatibleTypes< int16_t > ( DataType  dataType)

Definition at line 54 of file CompatibleTypes.cpp.

55 {
56  return dataType == DataType::QSymmS16;
57 }

References armnn::QSymmS16.

◆ CompatibleTypes< int32_t >()

bool armnnUtils::CompatibleTypes< int32_t > ( DataType  dataType)

Definition at line 60 of file CompatibleTypes.cpp.

61 {
62  return dataType == DataType::Signed32;
63 }

References armnn::Signed32.

◆ CompatibleTypes< int8_t >()

bool armnnUtils::CompatibleTypes< int8_t > ( DataType  dataType)

Definition at line 47 of file CompatibleTypes.cpp.

48 {
49  return dataType == DataType::QSymmS8
50  || dataType == DataType::QAsymmS8;
51 }

References armnn::QAsymmS8, and armnn::QSymmS8.

◆ CompatibleTypes< uint8_t >()

bool armnnUtils::CompatibleTypes< uint8_t > ( DataType  dataType)

Definition at line 41 of file CompatibleTypes.cpp.

42 {
43  return dataType == DataType::Boolean || dataType == DataType::QAsymmU8;
44 }

References armnn::Boolean, and armnn::QAsymmU8.

◆ ConvertInt32ToOctalString()

std::string ConvertInt32ToOctalString ( int  value)

Converts an int value into the Prototxt octal representation.

Definition at line 17 of file PrototxtConversions.cpp.

18 {
19  std::stringstream ss;
20  std::string returnString;
21  for (int i = 0; i < 4; ++i)
22  {
23  ss << "\\";
24  ss << std::setw(3) << std::setfill('0') << std::oct << ((value >> (i * 8)) & 0xFF);
25  }
26 
27  ss >> returnString;
28  return returnString;
29 }

◆ ConvertTensorShapeToString()

std::string ConvertTensorShapeToString ( const armnn::TensorShape shape)

Converts an TensorShape into Prototxt representation.

Definition at line 32 of file PrototxtConversions.cpp.

33 {
34  std::stringstream ss;
35  for (unsigned int i = 0 ; i < shape.GetNumDimensions() ; i++)
36  {
37  ss << "dim {\n";
38  ss << "size: " << std::to_string(shape[i]) << "\n";
39  ss << "}\n";
40  }
41  return ss.str();
42 
43 }

References TensorShape::GetNumDimensions().

◆ ExpandDims()

TensorShape ExpandDims ( const armnn::TensorShape tensorShape,
int  axis 
)

Definition at line 140 of file TensorUtils.cpp.

141 {
142  unsigned int outputDim = tensorShape.GetNumDimensions() + 1;
143 
144  if (axis < -armnn::numeric_cast<int>(outputDim) || axis > armnn::numeric_cast<int>(tensorShape.GetNumDimensions()))
145  {
146  throw InvalidArgumentException(fmt::format("Invalid expansion axis {} for {}D input tensor. {}",
147  axis,
148  tensorShape.GetNumDimensions(),
149  CHECK_LOCATION().AsString()));
150  }
151 
152  if (axis < 0)
153  {
154  axis = armnn::numeric_cast<int>(outputDim) + axis;
155  }
156 
157  std::vector<unsigned int> outputShape;
158  outputShape.reserve(tensorShape.GetNumDimensions());
159  for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i)
160  {
161  outputShape.push_back(tensorShape[i]);
162  }
163  outputShape.insert(outputShape.begin() + axis, 1);
164 
165  return { outputDim, outputShape.data() };
166 }

References CHECK_LOCATION, and TensorShape::GetNumDimensions().

◆ ExpandDimsToRank()

TensorShape ExpandDimsToRank ( const armnn::TensorShape tensorShape,
unsigned int  rank 
)

Definition at line 168 of file TensorUtils.cpp.

169 {
170  // Can't expand if rank is smaller than current shape
171  if (tensorShape.GetNumDimensions() >= rank)
172  {
173  return tensorShape;
174  }
175 
176  std::vector<unsigned int> newShape;
177 
178  // First add 1s to the beginning of the tensorInfo to fill in the space
179  for (unsigned int i = 0; i < rank - tensorShape.GetNumDimensions(); ++i)
180  {
181  newShape.push_back(1);
182  }
183 
184  // Then iterate through the original shape and append it to the new shape with the added 1s
185  for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i)
186  {
187  newShape.push_back(tensorShape[i]);
188  }
189 
190  return TensorShape(static_cast<unsigned int>(newShape.size()), newShape.data());
191 }

References TensorShape::GetNumDimensions().

◆ FindMinMax()

std::pair< float, float > FindMinMax ( armnn::ITensorHandle tensorHandle)

Definition at line 79 of file TensorUtils.cpp.

80 {
81  auto tensor_data = static_cast<const float *>(tensorHandle->Map(true));
82  auto tensor_size = tensorHandle->GetShape().GetNumElements();
83 
84  // Set min/max initially to first value in tensor
85  float min = tensor_data[0];
86  float max = tensor_data[0];
87 
88  // Loop over rest of tensor and update min/max if necessary
89  for (unsigned int val = 1; val < tensor_size; val++)
90  {
91  if (tensor_data[val] < min)
92  {
93  min = tensor_data[val];
94  }
95  else if (tensor_data[val] > max)
96  {
97  max = tensor_data[val];
98  }
99  }
100 
101  tensorHandle->Unmap();
102 
103  return std::make_pair(min, max);
104 }

References TensorShape::GetNumElements(), ITensorHandle::GetShape(), ITensorHandle::Map(), and ITensorHandle::Unmap().

◆ GetNumElementsAfter()

unsigned int GetNumElementsAfter ( const armnn::TensorShape shape,
unsigned int  axis 
)

Definition at line 234 of file TensorUtils.cpp.

235 {
236  unsigned int numDim = shape.GetNumDimensions();
237  ARMNN_ASSERT(axis <= numDim - 1);
238  unsigned int count = 1;
239  for (unsigned int i = axis+1; i < numDim; i++)
240  {
241  count *= shape[i];
242  }
243  return count;
244 }

References ARMNN_ASSERT, and TensorShape::GetNumDimensions().

Referenced by GetPerAxisParams(), PerAxisIterator< const int8_t, Decoder< float > >::PerAxisIterator(), and ToFloatArray().

◆ GetNumElementsBetween()

unsigned int GetNumElementsBetween ( const armnn::TensorShape shape,
unsigned int  firstAxisInclusive,
unsigned int  lastAxisExclusive 
)

Definition at line 207 of file TensorUtils.cpp.

210 {
211  ARMNN_ASSERT(firstAxisInclusive <= lastAxisExclusive);
212  ARMNN_ASSERT(lastAxisExclusive <= shape.GetNumDimensions());
213  unsigned int count = 1;
214  for (unsigned int i = firstAxisInclusive; i < lastAxisExclusive; i++)
215  {
216  count *= shape[i];
217  }
218  return count;
219 }

References ARMNN_ASSERT, and TensorShape::GetNumDimensions().

Referenced by armnn::ArgMinMax(), armnn::LogSoftmax(), and armnn::Softmax().

◆ GetPerAxisParams()

std::pair< unsigned int, std::vector< float > > GetPerAxisParams ( const armnn::TensorInfo info)

Definition at line 246 of file TensorUtils.cpp.

247 {
248  const std::vector<float>& scales = info.GetQuantizationScales();
249  armnn::Optional<unsigned int> quantizationDim = info.GetQuantizationDim();
250  if (!info.HasPerAxisQuantization())
251  {
253  std::string("Per-axis quantization params not set for tensor of type ") +
254  armnn::GetDataTypeName(info.GetDataType()), CHECK_LOCATION());
255  }
256  unsigned int axisFactor = GetNumElementsAfter(info.GetShape(), quantizationDim.value()) ;
257 
258  return { axisFactor, scales };
259 }

References CHECK_LOCATION, armnn::GetDataTypeName(), GetNumElementsAfter(), armnn::info, and OptionalReferenceSwitch< IsReference, T >::value().

Referenced by armnn::MakeDecoder(), and armnn::MakeEncoder().

◆ GetTensorInfo() [1/2]

TensorInfo GetTensorInfo ( unsigned int  numberOfBatches,
unsigned int  numberOfChannels,
unsigned int  depth,
unsigned int  height,
unsigned int  width,
const armnn::DataLayout  dataLayout,
const armnn::DataType  dataType 
)

Definition at line 58 of file TensorUtils.cpp.

65 {
66  switch (dataLayout)
67  {
68  case DataLayout::NDHWC:
69  return TensorInfo({numberOfBatches, depth, height, width, numberOfChannels}, dataType);
70  case DataLayout::NCDHW:
71  return TensorInfo({numberOfBatches, numberOfChannels, depth, height, width}, dataType);
72  default:
73  throw InvalidArgumentException("Unknown data layout ["
74  + std::to_string(static_cast<int>(dataLayout)) +
75  "]", CHECK_LOCATION());
76  }
77 }

References CHECK_LOCATION, armnn::NCDHW, and armnn::NDHWC.

◆ GetTensorInfo() [2/2]

TensorInfo GetTensorInfo ( unsigned int  numberOfBatches,
unsigned int  numberOfChannels,
unsigned int  height,
unsigned int  width,
const armnn::DataLayout  dataLayout,
const armnn::DataType  dataType 
)

Definition at line 38 of file TensorUtils.cpp.

44 {
45  switch (dataLayout)
46  {
47  case DataLayout::NCHW:
48  return TensorInfo({numberOfBatches, numberOfChannels, height, width}, dataType);
49  case DataLayout::NHWC:
50  return TensorInfo({numberOfBatches, height, width, numberOfChannels}, dataType);
51  default:
52  throw InvalidArgumentException("Unknown data layout ["
53  + std::to_string(static_cast<int>(dataLayout)) +
54  "]", CHECK_LOCATION());
55  }
56 }

References CHECK_LOCATION, armnn::NCHW, and armnn::NHWC.

◆ GetTensorShape()

TensorShape GetTensorShape ( unsigned int  numberOfBatches,
unsigned int  numberOfChannels,
unsigned int  height,
unsigned int  width,
const armnn::DataLayout  dataLayout 
)

Definition at line 19 of file TensorUtils.cpp.

24 {
25  switch (dataLayout)
26  {
27  case DataLayout::NCHW:
28  return TensorShape({numberOfBatches, numberOfChannels, height, width});
29  case DataLayout::NHWC:
30  return TensorShape({numberOfBatches, height, width, numberOfChannels});
31  default:
32  throw InvalidArgumentException("Unknown data layout ["
33  + std::to_string(static_cast<int>(dataLayout)) +
34  "]", CHECK_LOCATION());
35  }
36 }

References CHECK_LOCATION, armnn::NCHW, and armnn::NHWC.

◆ GetUnsignedAxis()

unsigned int GetUnsignedAxis ( const unsigned int  inputDimension,
const int  axis 
)

Definition at line 221 of file TensorUtils.cpp.

222 {
223  ARMNN_ASSERT_MSG(axis < armnn::numeric_cast<int>(inputDimension),
224  "Required axis index greater than number of dimensions.");
225  ARMNN_ASSERT_MSG(axis >= -armnn::numeric_cast<int>(inputDimension),
226  "Required axis index lower than negative of the number of dimensions");
227 
228  unsigned int uAxis = axis < 0 ?
229  inputDimension - armnn::numeric_cast<unsigned int>(abs(axis))
230  : armnn::numeric_cast<unsigned int>(axis);
231  return uAxis;
232 }

References ARMNN_ASSERT_MSG.

Referenced by armnn::ArgMinMax(), ClArgMinMaxWorkload::ClArgMinMaxWorkload(), ArgMinMaxLayer::InferOutputShapes(), NeonArgMinMaxWorkload::NeonArgMinMaxWorkload(), and ArgMinMaxQueueDescriptor::Validate().

◆ GraphTopologicalSort()

bool armnnUtils::GraphTopologicalSort ( const TTargetNodes &  targetNodes,
std::function< std::vector< TNodeId >(TNodeId)>  getIncomingEdges,
std::vector< TNodeId > &  outSorted 
)

Definition at line 110 of file GraphTopologicalSort.hpp.

114 {
115  outSorted.clear();
116  std::map<TNodeId, NodeState> nodeStates;
117 
118  for (TNodeId targetNode : targetNodes)
119  {
120  if (!TopologicallySort(targetNode, getIncomingEdges, outSorted, nodeStates))
121  {
122  return false;
123  }
124  }
125 
126  return true;
127 }

◆ MakeInputTensors()

armnn::InputTensors armnnUtils::MakeInputTensors ( const std::vector< armnn::BindingPointInfo > &  inputBindings,
const std::vector< TContainer > &  inputDataContainers 
)
inline

Definition at line 17 of file TensorIOUtils.hpp.

19 {
20  armnn::InputTensors inputTensors;
21 
22  const size_t numInputs = inputBindings.size();
23  if (numInputs != inputDataContainers.size())
24  {
25  throw armnn::Exception(fmt::format("The number of inputs does not match number of "
26  "tensor data containers: {0} != {1}",
27  numInputs,
28  inputDataContainers.size()));
29  }
30 
31  for (size_t i = 0; i < numInputs; i++)
32  {
33  const armnn::BindingPointInfo& inputBinding = inputBindings[i];
34  const TContainer& inputData = inputDataContainers[i];
35 
36  mapbox::util::apply_visitor([&](auto&& value)
37  {
38  if (value.size() != inputBinding.second.GetNumElements())
39  {
40  throw armnn::Exception(fmt::format("The input tensor has incorrect size (expected {0} got {1})",
41  inputBinding.second.GetNumElements(),
42  value.size()));
43  }
44  armnn::TensorInfo inputTensorInfo = inputBinding.second;
45  inputTensorInfo.SetConstant(true);
46  armnn::ConstTensor inputTensor(inputTensorInfo, value.data());
47  inputTensors.push_back(std::make_pair(inputBinding.first, inputTensor));
48  },
49  inputData);
50  }
51 
52  return inputTensors;
53 }

References TensorInfo::SetConstant().

◆ MakeOutputTensors()

armnn::OutputTensors armnnUtils::MakeOutputTensors ( const std::vector< armnn::BindingPointInfo > &  outputBindings,
std::vector< TContainer > &  outputDataContainers 
)
inline

Definition at line 56 of file TensorIOUtils.hpp.

58 {
59  armnn::OutputTensors outputTensors;
60 
61  const size_t numOutputs = outputBindings.size();
62  if (numOutputs != outputDataContainers.size())
63  {
64  throw armnn::Exception(fmt::format("Number of outputs does not match number"
65  "of tensor data containers: {0} != {1}",
66  numOutputs,
67  outputDataContainers.size()));
68  }
69 
70  for (size_t i = 0; i < numOutputs; i++)
71  {
72  const armnn::BindingPointInfo& outputBinding = outputBindings[i];
73  TContainer& outputData = outputDataContainers[i];
74 
75  mapbox::util::apply_visitor([&](auto&& value)
76  {
77  if (value.size() != outputBinding.second.GetNumElements())
78  {
79  throw armnn::Exception("Output tensor has incorrect size");
80  }
81 
82  armnn::Tensor outputTensor(outputBinding.second, value.data());
83  outputTensors.push_back(std::make_pair(outputBinding.first, outputTensor));
84  },
85  outputData);
86  }
87 
88  return outputTensors;
89 }

◆ NonNegative()

uint32_t NonNegative ( const char *  expr,
int32_t  value,
const CheckLocation location 
)

Definition at line 35 of file VerificationHelpers.cpp.

38 {
39  if (value < 0)
40  {
41  throw ParseException(fmt::format("'{}' must be non-negative, received: {} at {}",
42  expr,
43  value,
44  location.AsString()));
45  }
46  else
47  {
48  return static_cast<uint32_t>(value);
49  }
50 }

References CheckLocation::AsString().

◆ operator==() [1/2]

bool operator== ( const armnn::DataLayout dataLayout,
const DataLayoutIndexed indexed 
)

Equality methods.

Definition at line 46 of file DataLayoutIndexed.cpp.

47 {
48  return dataLayout == indexed.GetDataLayout();
49 }

References DataLayoutIndexed::GetDataLayout().

◆ operator==() [2/2]

bool operator== ( const DataLayoutIndexed indexed,
const armnn::DataLayout dataLayout 
)

Definition at line 51 of file DataLayoutIndexed.cpp.

52 {
53  return indexed.GetDataLayout() == dataLayout;
54 }

References DataLayoutIndexed::GetDataLayout().

◆ Permute()

void Permute ( const armnn::TensorShape dstShape,
const armnn::PermutationVector mappings,
const void *  src,
void *  dst,
size_t  dataTypeSize 
)

Definition at line 131 of file Permute.cpp.

133 {
134  PermuteLoop(dstShape, mappings).Unroll(src, dst, dataTypeSize);
135 }

Referenced by armnnOnnxParser::CreateConstTensorImpl(), armnn::DepthToSpace(), PermuteLayer::PermuteLayer(), armnn::PermuteTensor(), and armnn_driver::SwizzleAndroidNn4dTensorToArmNn().

◆ Permuted() [1/2]

armnn::TensorInfo Permuted ( const armnn::TensorInfo info,
const armnn::PermutationVector mappings 
)

Definition at line 115 of file Permute.cpp.

117 {
118  armnn::TensorInfo outInfo(info);
119  outInfo.SetShape(Permuted(info.GetShape(), mappings));
120 
121  // If TensorInfo has Per-Axis Quantization then it also has a QuantizationDim which needs to
122  // be permuted according to the mapping
123  if (info.GetQuantizationDim().has_value())
124  {
125  outInfo.SetQuantizationDim(mappings[info.GetQuantizationDim().value()]);
126  }
127 
128  return outInfo;
129 }

References armnn::info, Permuted(), TensorInfo::SetQuantizationDim(), and TensorInfo::SetShape().

◆ Permuted() [2/2]

armnn::TensorShape Permuted ( const armnn::TensorShape srcShape,
const armnn::PermutationVector mappings 
)

Definition at line 98 of file Permute.cpp.

100 {
101  assert(srcShape.GetNumDimensions() == mappings.GetSize());
102 
103  const unsigned int numDims = mappings.GetSize();
104  unsigned int outDims[armnn::MaxNumOfTensorDimensions];
105 
106  for (unsigned int i = 0U; i < numDims; ++i)
107  {
108  outDims[mappings[i]] = srcShape[i];
109  }
110 
111  armnn::TensorShape permutedShape(numDims, outDims);
112  return permutedShape;
113 }

References TensorShape::GetNumDimensions(), PermutationVector::GetSize(), and armnn::MaxNumOfTensorDimensions.

Referenced by armnn::Convert1HWOTensorInfoToAcl(), armnn::ConvertWeightTensorInfoFromArmnnToAcl(), armnnOnnxParser::CreateConstTensorImpl(), BatchMatMulLayer::InferOutputShapes(), PermuteLayer::InferOutputShapes(), Permuted(), armnn::PermuteTensor(), MovePermuteUpImpl::Run(), armnn_driver::SwizzleAndroidNn4dTensorToArmNn(), and BatchMatMulQueueDescriptor::Validate().

◆ ProcessConcatInputTensorInfo()

void ProcessConcatInputTensorInfo ( armnn::TensorInfo inputTensorInfo,
armnn::OriginsDescriptor concatDescriptor,
const unsigned int &  concatAxis,
unsigned int  inputIndex,
unsigned int &  mergeDimOrigin 
)

Definition at line 19 of file ParserHelper.cpp.

24 {
25  const uint32_t inputRank = concatDescriptor.GetNumDimensions();
26 
27  // double check dimensions of the tensors
28  if (inputTensorInfo.GetNumDimensions() != inputRank)
29  {
30  throw armnn::ParseException(fmt::format(
31  "The number of dimensions: {0} for input tensors of the "
32  "concatenation op should be {1} {2}",
33  inputTensorInfo.GetNumDimensions(),
34  inputRank,
35  CHECK_LOCATION().AsString()));
36  }
37 
38  for (unsigned int j = 0; j < concatAxis; ++j)
39  {
40  concatDescriptor.SetViewOriginCoord(inputIndex, j, 0);
41  }
42 
43  concatDescriptor.SetViewOriginCoord(inputIndex, concatAxis, mergeDimOrigin);
44  mergeDimOrigin += inputTensorInfo.GetShape()[concatAxis];
45 
46  for (unsigned int j = concatAxis + 1; j < inputRank; ++j)
47  {
48  concatDescriptor.SetViewOriginCoord(inputIndex, j, 0);
49  }
50 }

References CHECK_LOCATION, TensorInfo::GetNumDimensions(), OriginsDescriptor::GetNumDimensions(), TensorInfo::GetShape(), and OriginsDescriptor::SetViewOriginCoord().

◆ QuantizedVector() [1/3]

std::vector<T> armnnUtils::QuantizedVector ( const std::vector< float > &  array,
float  qScale = 1.f,
int32_t  qOffset = 0 
)

Definition at line 121 of file QuantizeHelper.hpp.

122 {
123  return QuantizedVector<T>(array.begin(), array.end(), qScale, qOffset);
124 }

◆ QuantizedVector() [2/3]

std::vector<T> armnnUtils::QuantizedVector ( FloatIt  first,
FloatIt  last,
float  qScale,
int32_t  qOffset 
)

Definition at line 105 of file QuantizeHelper.hpp.

106 {
107  std::vector<T> quantized;
108  quantized.reserve(armnn::numeric_cast<size_t>(std::distance(first, last)));
109 
110  for (auto it = first; it != last; ++it)
111  {
112  auto f = *it;
113  T q = SelectiveQuantize<T>(f, qScale, qOffset);
114  quantized.push_back(q);
115  }
116 
117  return quantized;
118 }

◆ QuantizedVector() [3/3]

std::vector<T> armnnUtils::QuantizedVector ( std::initializer_list< float >  array,
float  qScale = 1.f,
int32_t  qOffset = 0 
)

Definition at line 127 of file QuantizeHelper.hpp.

128 {
129  return QuantizedVector<T>(array.begin(), array.end(), qScale, qOffset);
130 }

◆ ReduceDims() [1/2]

TensorInfo ReduceDims ( const armnn::TensorInfo tensorInfo,
unsigned int  dimensions 
)

Definition at line 132 of file TensorUtils.cpp.

133 {
134  TensorInfo strippedTensor(tensorInfo);
135  TensorShape strippedShape = ReduceDims(tensorInfo.GetShape(), dimensions);
136  strippedTensor.SetShape(strippedShape);
137  return strippedTensor;
138 }

References TensorInfo::GetShape(), ReduceDims(), and TensorInfo::SetShape().

◆ ReduceDims() [2/2]

TensorShape ReduceDims ( const armnn::TensorShape tensorInfo,
unsigned int  dimensions 
)

Definition at line 106 of file TensorUtils.cpp.

107 {
108  if (tensorShape.GetNumDimensions() <= dimensions)
109  {
110  return tensorShape;
111  }
112  std::vector<unsigned int> newShape;
113 
114  unsigned int dimsToSkip = tensorShape.GetNumDimensions() - dimensions;
115  unsigned int dimsSkipped = 0;
116  bool insertRemainder = false;
117 
118  for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i)
119  {
120  if (tensorShape[i] == 1 && dimsSkipped < dimsToSkip && !insertRemainder)
121  {
122  ++dimsSkipped;
123  continue;
124  }
125  newShape.push_back(tensorShape[i]);
126  // Once we insert the first dimension we can't skip any more
127  insertRemainder = true;
128  }
129  return TensorShape(static_cast<unsigned int>(newShape.size()), newShape.data());
130 }

References TensorShape::GetNumDimensions().

Referenced by ReduceDims().

◆ SelectiveDequantize()

float armnnUtils::SelectiveDequantize ( value,
float  scale,
int32_t  offset 
)

Definition at line 91 of file QuantizeHelper.hpp.

92 {
93  return SelectiveQuantizer<T, armnn::IsQuantizedType<T>()>::Dequantize(value, scale, offset);
94 };

◆ SelectiveQuantize()

T armnnUtils::SelectiveQuantize ( float  value,
float  scale,
int32_t  offset 
)

Definition at line 85 of file QuantizeHelper.hpp.

86 {
87  return SelectiveQuantizer<T, armnn::IsQuantizedType<T>()>::Quantize(value, scale, offset);
88 };

◆ SplitBy()

std::vector< std::string > SplitBy ( const std::string &  originalString,
const std::string &  delimiter = " ",
bool  includeEmptyToken = false 
)

Split a string into tokens by a delimiter.

Parameters
[in]originalStringOriginal string to be split
[in]delimiterDelimiter used to split originalString
[in]includeEmptyToeknIf true, include empty tokens in the result
Returns
A vector of tokens split from originalString by \delimiter

Definition at line 40 of file ModelAccuracyChecker.cpp.

41 {
42  std::vector<std::string> tokens;
43  size_t cur = 0;
44  size_t next = 0;
45  while ((next = originalString.find(delimiter, cur)) != std::string::npos)
46  {
47  // Skip empty tokens, unless explicitly stated to include them.
48  if (next - cur > 0 || includeEmptyToken)
49  {
50  tokens.push_back(originalString.substr(cur, next - cur));
51  }
52  cur = next + delimiter.size();
53  }
54  // Get the remaining token
55  // Skip empty tokens, unless explicitly stated to include them.
56  if (originalString.size() - cur > 0 || includeEmptyToken)
57  {
58  tokens.push_back(originalString.substr(cur, originalString.size() - cur));
59  }
60  return tokens;
61 }

◆ SqueezeDims()

std::vector< unsigned int > SqueezeDims ( const armnn::TensorShape tensorShape)

Definition at line 193 of file TensorUtils.cpp.

194 {
195  std::vector<unsigned int> squeezedDims;
196 
197  for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i)
198  {
199  if (tensorShape[i] != 1)
200  {
201  squeezedDims.push_back(tensorShape[i]);
202  }
203  }
204  return squeezedDims;
205 }

References TensorShape::GetNumDimensions().

Referenced by Layer::ValidateAndCopyShape().

◆ Strip()

std::string Strip ( const std::string &  originalString,
const std::string &  characterSet = " " 
)

Remove any preceding and trailing character specified in the characterSet.

Parameters
[in]originalStringOriginal string to be stripped
[in]characterSetSet of characters to be stripped from originalString
Returns
A string stripped of all characters specified in characterSet from originalString

Definition at line 64 of file ModelAccuracyChecker.cpp.

65 {
66  ARMNN_ASSERT(!characterSet.empty());
67  const std::size_t firstFound = originalString.find_first_not_of(characterSet);
68  const std::size_t lastFound = originalString.find_last_not_of(characterSet);
69  // Return empty if the originalString is empty or the originalString contains only to-be-striped characters
70  if (firstFound == std::string::npos || lastFound == std::string::npos)
71  {
72  return "";
73  }
74  return originalString.substr(firstFound, lastFound + 1 - firstFound);
75 }

References ARMNN_ASSERT.

◆ ToFloatArray() [1/2]

std::unique_ptr< float[]> ToFloatArray ( const std::vector< PrimitiveType > &  data,
const armnn::TensorInfo tensorInfo 
)

Definition at line 273 of file TensorUtils.cpp.

274 {
275  CheckSizes(data, tensorInfo);
276 
277  std::unique_ptr<float[]> returnBuffer(new float[tensorInfo.GetNumElements()]);
278 
279  if (tensorInfo.HasPerAxisQuantization())
280  {
281  unsigned int axis = tensorInfo.GetQuantizationDim().value();
282  auto axisDimensionality = tensorInfo.GetShape()[axis];
283  auto axisFactor = armnnUtils::GetNumElementsAfter(tensorInfo.GetShape(), axis);
284 
285  for (unsigned int i = 0; i < tensorInfo.GetNumElements(); ++i)
286  {
287  unsigned int axisIndex;
288 
289  if (i < axisFactor)
290  {
291  axisIndex = 0;
292  }
293  else
294  {
295  axisIndex = (i / axisFactor) % axisDimensionality;
296  }
297  returnBuffer[i] = Dequantize<PrimitiveType>(data[i],
298  tensorInfo.GetQuantizationScales()[axisIndex],
299  tensorInfo.GetQuantizationOffset());
300  }
301  }
302  else
303  {
304  for (unsigned int i = 0; i < tensorInfo.GetNumElements(); ++i)
305  {
306  returnBuffer[i] = Dequantize<PrimitiveType>(data[i],
307  tensorInfo.GetQuantizationScale(),
308  tensorInfo.GetQuantizationOffset());
309  }
310  }
311  return returnBuffer;
312 }

References CheckSizes(), TensorInfo::GetNumElements(), GetNumElementsAfter(), TensorInfo::GetQuantizationDim(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::GetQuantizationScales(), TensorInfo::GetShape(), TensorInfo::HasPerAxisQuantization(), and OptionalReferenceSwitch< IsReference, T >::value().

◆ ToFloatArray() [2/2]

std::unique_ptr< float[]> ToFloatArray ( const std::vector< uint8_t > &  data,
const armnn::TensorInfo tensorInfo 
)

Definition at line 314 of file TensorUtils.cpp.

315 {
316  if (tensorInfo.GetDataType() == DataType::QAsymmS8 || tensorInfo.GetDataType() == DataType::QSymmS8)
317  {
318  CheckSizes(data, tensorInfo);
319  std::vector<int8_t> buffer(tensorInfo.GetNumElements());
320  ::memcpy(buffer.data(), data.data(), data.size());
321  return ToFloatArray<int8_t>(buffer, tensorInfo);
322  }
323  else if (tensorInfo.GetDataType() == DataType::QAsymmU8)
324  {
325  CheckSizes(data, tensorInfo);
326  return ToFloatArray<uint8_t>(data, tensorInfo);
327  }
328  else if (tensorInfo.GetDataType() == DataType::Signed32)
329  {
330  CheckSizes(data, tensorInfo, 4);
331  std::vector<int32_t> buffer(tensorInfo.GetNumElements());
332  ::memcpy(buffer.data(), data.data(), data.size());
333  return ToFloatArray<int32_t>(buffer, tensorInfo);
334  }
335  else if (tensorInfo.GetDataType() == DataType::Signed64)
336  {
337  CheckSizes(data, tensorInfo, 8);
338  std::vector<int64_t> buffer(tensorInfo.GetNumElements());
339  ::memcpy(buffer.data(), data.data(), data.size());
340  return ToFloatArray<int64_t>(buffer, tensorInfo);
341  }
343  fmt::format("Unsupported datatype {}. {}",
344  GetDataTypeName(tensorInfo.GetDataType()),
345  CHECK_LOCATION().AsString()));
346 }

References CHECK_LOCATION, CheckSizes(), TensorInfo::GetDataType(), armnn::GetDataTypeName(), TensorInfo::GetNumElements(), armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS8, armnn::Signed32, and armnn::Signed64.

◆ Transpose()

void Transpose ( const armnn::TensorShape dstShape,
const armnn::PermutationVector mappings,
const void *  src,
void *  dst,
size_t  dataTypeSize 
)

Definition at line 120 of file Transpose.cpp.

122 {
123  TransposeLoop(srcShape, mappings).Unroll(src, dst, dataTypeSize);
124 }

Referenced by TransposeLayer::TransposeLayer().

◆ TransposeTensorShape() [1/2]

armnn::TensorInfo TransposeTensorShape ( const armnn::TensorInfo info,
const armnn::PermutationVector mappings 
)

Definition at line 113 of file Transpose.cpp.

114 {
115  armnn::TensorInfo outInfo(info);
116  outInfo.SetShape(TransposeTensorShape(info.GetShape(), mappings));
117  return outInfo;
118 }

References armnn::info, TensorInfo::SetShape(), and TransposeTensorShape().

◆ TransposeTensorShape() [2/2]

armnn::TensorShape TransposeTensorShape ( const armnn::TensorShape srcShape,
const armnn::PermutationVector mappings 
)

Definition at line 98 of file Transpose.cpp.

99 {
100  assert(srcShape.GetNumDimensions() == mappings.GetSize());
101 
102  const unsigned int numDims = mappings.GetSize();
103  unsigned int outDims[armnn::MaxNumOfTensorDimensions];
104 
105  for (unsigned int i = 0U; i < numDims; ++i)
106  {
107  outDims[i] = srcShape[mappings[i]];
108  }
109  armnn::TensorShape permutedShape(numDims, outDims);
110  return permutedShape;
111 }

References TensorShape::GetNumDimensions(), PermutationVector::GetSize(), and armnn::MaxNumOfTensorDimensions.

Referenced by TransposeLayer::InferOutputShapes(), MoveTransposeUpImpl::Run(), and TransposeTensorShape().

◆ VerifyInt32()

int32_t VerifyInt32 ( const char *  expr,
int64_t  value,
const armnn::CheckLocation location 
)

Definition at line 52 of file VerificationHelpers.cpp.

55 {
56  if (value < std::numeric_limits<int>::min() || value > std::numeric_limits<int>::max())
57  {
58  throw ParseException(fmt::format("'{}' must should fit into a int32 (ArmNN don't support int64),"
59  " received: {} at {}",
60  expr,
61  value,
62  location.AsString()));
63  }
64  else
65  {
66  return static_cast<int32_t>(value);
67  }
68 }

References CheckLocation::AsString().

◆ within_percentage_tolerance()

bool armnnUtils::within_percentage_tolerance ( float  a,
float  b,
float  tolerancePercent = 1.0f 
)
inline

Compare two floats and return true if their values are within a specified tolerance of each other.

Parameters
a
b
tolerancePercentageIf not supplied default will be 1% tolerance (1.0f)
Returns
true if the value of float b is within tolerancePercentage of the value for float a.

Definition at line 20 of file FloatingPointComparison.hpp.

21 {
22  float toleranceValue = std::fabs(a * (tolerancePercent / 100));
23  return std::fabs(a - b) <= toleranceValue;
24 }

Variable Documentation

◆ ArmNNToNHWC

const armnn::PermutationVector ArmNNToNHWC = { 0, 3, 1, 2 }

Definition at line 17 of file ParserHelper.cpp.

◆ NHWCToArmNN

const armnn::PermutationVector NHWCToArmNN = { 0, 2, 3, 1 }

Definition at line 16 of file ParserHelper.cpp.

armnn::TensorInfo::GetQuantizationOffset
int32_t GetQuantizationOffset() const
Definition: Tensor.cpp:478
armnn::TensorInfo::GetQuantizationScale
float GetQuantizationScale() const
Definition: Tensor.cpp:461
armnn::Exception
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
armnn::OriginsDescriptor::GetNumDimensions
uint32_t GetNumDimensions() const
Get the number of dimensions.
Definition: Descriptors.cpp:192
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnnUtils::CheckSizes
void CheckSizes(const std::vector< PrimitiveType > &data, const armnn::TensorInfo &tensorInfo, unsigned int size=1)
Definition: TensorUtils.cpp:262
armnn::TensorShape::GetNumElements
unsigned int GetNumElements() const
Function that calculates the tensor elements by multiplying all dimension size which are Specified.
Definition: Tensor.cpp:181
armnn::ITensorHandle::GetShape
virtual TensorShape GetShape() const =0
Get the number of elements for each dimension ordered from slowest iterating dimension to fastest ite...
armnn::ParseException
Definition: Exceptions.hpp:92
armnn::ConstTensor
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327
armnnUtils::DataLayoutIndexed::GetDataLayout
armnn::DataLayout GetDataLayout() const
Definition: DataLayoutIndexed.hpp:22
armnnUtils::TContainer
mapbox::util::variant< std::vector< float >, std::vector< int >, std::vector< unsigned char >, std::vector< int8_t > > TContainer
Definition: TContainer.hpp:18
armnn::PermutationVector::GetSize
SizeType GetSize() const
Definition: Types.hpp:349
armnnUtils::TransposeTensorShape
armnn::TensorShape TransposeTensorShape(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Transpose.cpp:98
armnn::TensorInfo::SetConstant
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
Definition: Tensor.cpp:514
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::StridedSliceDescriptor::GetStopForAxis
int GetStopForAxis(const TensorShape &inputShape, unsigned int axis, int startForAxis) const
Definition: Descriptors.cpp:393
armnn::OptionalReferenceSwitch::value
const T & value() const
Definition: Optional.hpp:146
armnn::CheckLocation::AsString
std::string AsString() const
Definition: Exceptions.hpp:29
armnnUtils::Permuted
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98
armnnUtils::GetNumElementsAfter
unsigned int GetNumElementsAfter(const armnn::TensorShape &shape, unsigned int axis)
Definition: TensorUtils.cpp:234
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::ITensorHandle::Map
virtual const void * Map(bool blocking=true) const =0
Map the tensor data for access.
armnn::InputTensors
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:392
armnn::TensorInfo::GetNumDimensions
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195
armnn::TensorInfo::GetNumElements
unsigned int GetNumElements() const
Definition: Tensor.hpp:196
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::TensorInfo::HasPerAxisQuantization
bool HasPerAxisQuantization() const
Definition: Tensor.cpp:446
armnn::StridedSliceDescriptor::GetStartForAxis
int GetStartForAxis(const TensorShape &inputShape, unsigned int axis) const
Definition: Descriptors.cpp:366
armnnUtils::ReduceDims
armnn::TensorShape ReduceDims(const armnn::TensorShape &tensorInfo, unsigned int dimensions)
Definition: TensorUtils.cpp:106
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
armnn::StridedSliceDescriptor::m_Stride
std::vector< int > m_Stride
Stride values for the input that will be sliced.
Definition: Descriptors.hpp:1313
ARMNN_ASSERT_MSG
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
armnn::abs
Definition: Abs.hpp:13
armnn::StridedSliceDescriptor::m_ShrinkAxisMask
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1.
Definition: Descriptors.hpp:1322
armnn::TensorShape::GetNumDimensions
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
armnn::TensorInfo::GetQuantizationDim
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:494
ARMNN_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::Quantize
QuantizedType Quantize(float value, float scale, int32_t offset)
Quantize a floating point data type into an 8-bit data type.
Definition: TypesUtils.cpp:30
armnn::OutputTensors
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
Definition: Tensor.hpp:393
armnn::Optional< unsigned int >
armnn::numeric_cast
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
armnn::Tensor
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:319
armnn::TensorInfo::GetQuantizationScales
std::vector< float > GetQuantizationScales() const
Definition: Tensor.cpp:451
armnn::Dequantize
float Dequantize(QuantizedType value, float scale, int32_t offset)
Dequantize an 8-bit data type into a floating point data type.
Definition: TypesUtils.cpp:46
armnn::GetDataTypeName
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:220
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnn::ITensorHandle::Unmap
virtual void Unmap() const =0
Unmap the tensor data.
armnn::MaxNumOfTensorDimensions
constexpr unsigned int MaxNumOfTensorDimensions
Definition: Types.hpp:31
armnn::OriginsDescriptor::SetViewOriginCoord
Status SetViewOriginCoord(uint32_t view, uint32_t coord, uint32_t value)
@Brief Set the view origin coordinates.
Definition: Descriptors.cpp:167
armnn::TensorInfo::GetDataType
DataType GetDataType() const
Definition: Tensor.hpp:198
armnn::BoostLogSeverityMapping::info
@ info
armnn::BindingPointInfo
std::pair< armnn::LayerBindingId, armnn::TensorInfo > BindingPointInfo
Definition: Tensor.hpp:274