22.08
|
#include <armnn/Logging.hpp>
#include <armnn/utility/StringUtils.hpp>
#include <armnn/utility/NumericCast.hpp>
#include <armnn/BackendRegistry.hpp>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <iterator>
Go to the source code of this file.
Classes | |
struct | OutputWriteInfo |
Functions | |
bool | CheckInferenceTimeThreshold (const std::chrono::duration< double, std::milli > &duration, const double &thresholdTime) |
Given a measured duration and a threshold time tell the user whether we succeeded or not. More... | |
bool | CheckRequestedBackendsAreValid (const std::vector< armnn::BackendId > &backendIds, armnn::Optional< std::string &> invalidBackendIds=armnn::EmptyOptional()) |
std::vector< unsigned int > | ParseArray (std::istream &stream) |
std::vector< std::string > | ParseStringList (const std::string &inputString, const char *delimiter) |
Splits a given string at every accurance of delimiter into a vector of string. More... | |
template<typename T > | |
std::vector< float > | DequantizeArray (const void *array, unsigned int numElements, float scale, int32_t offset) |
Dequantize an array of a given type. More... | |
void | LogAndThrow (std::string eMsg) |
bool | ValidatePath (const std::string &file, const bool expectFile) |
Verifies if the given string is a valid path. More... | |
bool | ValidatePaths (const std::vector< std::string > &fileVec, const bool expectFile) |
Verifies if a given vector of strings are valid paths. More... | |
template<typename Integer , typename std::enable_if_t< std::is_integral< Integer >::value > * = nullptr> | |
std::function< Integer(const std::string &)> | GetParseElementFunc () |
Returns a function of read the given type as a string. More... | |
template<typename Float , std::enable_if_t< std::is_floating_point< Float >::value > * = nullptr> | |
std::function< Float(const std::string &)> | GetParseElementFunc () |
template<typename T > | |
void | PopulateTensorWithData (T *tensor, const unsigned int numElements, const armnn::Optional< std::string > &dataFile, const std::string &inputName) |
template<typename T > | |
void | WriteToFile (const std::string &outputTensorFileName, const std::string &outputName, const T *const array, const unsigned int numElements) |
template<typename T > | |
void | PrintTensor (OutputWriteInfo &info, const char *formatString) |
template<typename T > | |
void | PrintQuantizedTensor (OutputWriteInfo &info) |
template<typename T , typename TParseElementFunc > | |
std::vector< T > | ParseArrayImpl (std::istream &stream, TParseElementFunc parseElementFunc, const char *chars="\,:") |
template<typename T > | |
float | ComputeRMSE (const void *expected, const void *actual, const size_t size) |
Compute the root-mean-square error (RMSE) More... | |
bool CheckInferenceTimeThreshold | ( | const std::chrono::duration< double, std::milli > & | duration, |
const double & | thresholdTime | ||
) |
Given a measured duration and a threshold time tell the user whether we succeeded or not.
duration | the measured inference duration. |
thresholdTime | the threshold time in milliseconds. |
Definition at line 17 of file NetworkExecutionUtils.cpp.
References ARMNN_LOG.
Referenced by ArmNNExecutor::ArmNNExecutor(), and TfLiteExecutor::Execute().
|
inline |
Definition at line 28 of file NetworkExecutionUtils.hpp.
References armnn::BackendRegistryInstance(), BackendRegistry::GetBackendIds(), ParseArray(), and ParseStringList().
Referenced by InferenceModel< IParser, TDataType >::InferenceModel(), main(), and ExecuteNetworkParams::ValidateParams().
float ComputeRMSE | ( | const void * | expected, |
const void * | actual, | ||
const size_t | size | ||
) |
Compute the root-mean-square error (RMSE)
expected | |
actual | |
size | size of the tensor |
Definition at line 278 of file NetworkExecutionUtils.hpp.
std::vector<float> DequantizeArray | ( | const void * | array, |
unsigned int | numElements, | ||
float | scale, | ||
int32_t | offset | ||
) |
Dequantize an array of a given type.
array | Type erased array to dequantize |
numElements | Elements in the array |
array | Type erased array to dequantize |
Definition at line 67 of file NetworkExecutionUtils.hpp.
References armnn::Dequantize(), LogAndThrow(), ValidatePath(), and ValidatePaths().
std::function<Integer(const std::string&)> GetParseElementFunc | ( | ) |
Returns a function of read the given type as a string.
Definition at line 100 of file NetworkExecutionUtils.hpp.
References armnn::numeric_cast().
std::function<Float(const std::string&)> GetParseElementFunc | ( | ) |
Definition at line 106 of file NetworkExecutionUtils.hpp.
void LogAndThrow | ( | std::string | eMsg | ) |
Definition at line 75 of file NetworkExecutionUtils.cpp.
References ARMNN_LOG.
Referenced by ArmNNExecutor::CompareAndPrintResult(), DequantizeArray(), TfLiteExecutor::Execute(), ArmNNExecutor::PrintNetworkInfo(), and TfLiteExecutor::TfLiteExecutor().
std::vector<unsigned int> ParseArray | ( | std::istream & | stream | ) |
Definition at line 55 of file NetworkExecutionUtils.cpp.
References armnn::numeric_cast().
Referenced by CheckRequestedBackendsAreValid(), and ProgramOptions::ParseOptions().
std::vector<T> ParseArrayImpl | ( | std::istream & | stream, |
TParseElementFunc | parseElementFunc, | ||
const char * | chars = "\t ,:" |
||
) |
Definition at line 245 of file NetworkExecutionUtils.hpp.
References ARMNN_LOG, and armnn::stringUtils::StringTokenizer().
std::vector<std::string> ParseStringList | ( | const std::string & | inputString, |
const char * | delimiter | ||
) |
Splits a given string at every accurance of delimiter into a vector of string.
Definition at line 10 of file NetworkExecutionUtils.cpp.
References armnn::stringUtils::StringTrimCopy().
Referenced by CheckRequestedBackendsAreValid(), GetBackendIDs(), and ProgramOptions::ParseOptions().
void PopulateTensorWithData | ( | T * | tensor, |
const unsigned int | numElements, | ||
const armnn::Optional< std::string > & | dataFile, | ||
const std::string & | inputName | ||
) |
Definition at line 112 of file NetworkExecutionUtils.hpp.
References ARMNN_LOG, OptionalBase::has_value(), armnn::stringUtils::StringTokenizer(), and OptionalReferenceSwitch< IsReference, T >::value().
void PrintQuantizedTensor | ( | OutputWriteInfo & | info | ) |
Definition at line 218 of file NetworkExecutionUtils.hpp.
References OptionalBase::has_value(), OutputWriteInfo::m_OutputName, OutputWriteInfo::m_OutputTensorFile, OutputWriteInfo::m_PrintTensor, OutputWriteInfo::m_Tensor, OptionalReferenceSwitch< IsReference, T >::value(), and WriteToFile().
void PrintTensor | ( | OutputWriteInfo & | info, |
const char * | formatString | ||
) |
Definition at line 196 of file NetworkExecutionUtils.hpp.
References BaseTensor< MemoryType >::GetMemoryArea(), BaseTensor< MemoryType >::GetNumElements(), OptionalBase::has_value(), OutputWriteInfo::m_OutputName, OutputWriteInfo::m_OutputTensorFile, OutputWriteInfo::m_PrintTensor, OutputWriteInfo::m_Tensor, OptionalReferenceSwitch< IsReference, T >::value(), and WriteToFile().
bool ValidatePath | ( | const std::string & | file, |
const bool | expectFile | ||
) |
Verifies if the given string is a valid path.
Reports invalid paths to std::err.
file | string - A string containing the path to check |
expectFile | bool - If true, checks for a regular file. |
Definition at line 40 of file NetworkExecutionUtils.cpp.
Referenced by CheckClTuningParameter(), DequantizeArray(), and ValidatePaths().
bool ValidatePaths | ( | const std::vector< std::string > & | fileVec, |
const bool | expectFile | ||
) |
Verifies if a given vector of strings are valid paths.
Reports invalid paths to std::err.
fileVec | vector of string - A vector of string containing the paths to check |
expectFile | bool - If true, checks for a regular file. |
Definition at line 62 of file NetworkExecutionUtils.cpp.
References ValidatePath().
Referenced by DequantizeArray(), and ExecuteNetworkParams::ValidateParams().
void WriteToFile | ( | const std::string & | outputTensorFileName, |
const std::string & | outputName, | ||
const T *const | array, | ||
const unsigned int | numElements | ||
) |
Definition at line 168 of file NetworkExecutionUtils.hpp.
References ARMNN_LOG.
Referenced by PrintQuantizedTensor(), and PrintTensor().