ArmNN
 22.11
TosaOperatorUtils.hpp File Reference
#include <armnn/Tensor.hpp>
#include <armnn/Types.hpp>
#include <tosa_generated.h>

Go to the source code of this file.

Functions

DType ArmNNToDType (const DataType &type)
 
std::vector< int32_t > GetTosaTensorShape (const TensorShape &shape)
 
std::string GetUniqueTosaMappingID ()
 

Function Documentation

◆ ArmNNToDType()

DType ArmNNToDType ( const DataType type)
inline

Definition at line 17 of file TosaOperatorUtils.hpp.

References armnn::BFloat16, armnn::Boolean, armnn::Float16, armnn::Float32, armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS16, armnn::QSymmS8, armnn::Signed32, and armnn::Signed64.

18 {
19  switch (type)
20  {
21  case DataType::Float16:
22  case DataType::BFloat16:
23  return DType_FP16;
24  case DataType::Float32:
25  return DType_FP32;
26  case DataType::QAsymmU8:
27  return DType_UINT8;
28  case DataType::QSymmS8:
29  case DataType::QAsymmS8:
30  return DType_INT8;
31  case DataType::QSymmS16:
32  return DType_INT16;
33  case DataType::Signed32:
34  return DType_INT32;
35  case DataType::Signed64:
36  // No signed 64, only DType_INT48.
37  return DType_UNKNOWN;
38  case DataType::Boolean:
39  return DType_BOOL;
40  default:
41  return DType_UNKNOWN;
42  }
43 }

◆ GetTosaTensorShape()

std::vector<int32_t> GetTosaTensorShape ( const TensorShape shape)
inline

Definition at line 46 of file TosaOperatorUtils.hpp.

References TensorShape::GetNumDimensions().

Referenced by ConvertAdditionToTosaOperator().

47 {
48  std::vector<int32_t> returnShape;
49  for (u_int32_t i = 0; i < shape.GetNumDimensions(); i++)
50  {
51  returnShape.push_back(static_cast<int32_t>(shape[i]));
52  }
53  return returnShape;
54 }
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174

◆ GetUniqueTosaMappingID()

std::string GetUniqueTosaMappingID ( )
inline

Definition at line 58 of file TosaOperatorUtils.hpp.

Referenced by ConvertAdditionToTosaOperator().

59 {
60  return std::to_string(++uniqueTosaMappingID);
61 }