Compute Library
 19.08
arm_compute::support::cpp11 Namespace Reference

Enumerations

enum  NumericBase { BASE_10, BASE_16 }
 

Functions

int stoi (const std::string &str, std::size_t *pos=0, NumericBase base=NumericBase::BASE_10)
 Convert string values to integer. More...
 
unsigned long stoul (const std::string &str, std::size_t *pos=0, NumericBase base=NumericBase::BASE_10)
 Convert string values to unsigned long. More...
 
template<typename T >
std::string to_string (T &&value)
 Convert integer and float values to string. More...
 
template<typename T >
nearbyint (T value)
 Rounds the floating-point argument arg to an integer value in floating-point format, using the current rounding mode. More...
 
template<typename... Ts>
int stof (Ts &&... args)
 Convert string values to float. More...
 
template<typename T , typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
round (T value)
 Round floating-point value with half value rounding away from zero. More...
 
template<typename T , typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
trunc (T value)
 Truncate floating-point value. More...
 
template<typename T , typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
copysign (T x, T y)
 Composes a floating point value with the magnitude of x and the sign of y. More...
 
template<typename T , typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
fma (T x, T y, T z)
 Computes (x*y) + z as if to infinite precision and rounded only once to fit the result type. More...
 
template<typename... Ts>
int snprintf (char *s, std::size_t n, const char *fmt, Ts &&... args)
 Loads the data from the given location, converts them to character string equivalents and writes the result to a character string buffer. More...
 
std::string to_string (bool value)
 
void * align (std::size_t alignment, std::size_t size, void *&ptr, std::size_t &space)
 
template<typename T >
lowest ()
 
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
bool isfinite (T value)
 
bool isfinite (half_float::half value)
 

Enumeration Type Documentation

◆ NumericBase

enum NumericBase
strong
Enumerator
BASE_10 
BASE_16 

Definition at line 46 of file ToolchainSupport.h.

Function Documentation

◆ align()

void* arm_compute::support::cpp11::align ( std::size_t  alignment,
std::size_t  size,
void *&  ptr,
std::size_t &  space 
)
inline

Definition at line 368 of file ToolchainSupport.h.

369 {
370  std::uintptr_t pn = reinterpret_cast<std::uintptr_t>(ptr);
371  std::uintptr_t aligned = (pn + alignment - 1) & -alignment;
372  std::size_t padding = aligned - pn;
373  if(space < size + padding)
374  {
375  return nullptr;
376  }
377 
378  space -= padding;
379 
380  return ptr = reinterpret_cast<void *>(aligned);
381 }

References arm_compute::test::validation::padding.

Referenced by MemoryRegion::MemoryRegion(), and arm_compute::test::validation::TEST_CASE().

◆ copysign()

T arm_compute::support::cpp11::copysign ( x,
y 
)
inline

Composes a floating point value with the magnitude of x and the sign of y.

Note
This function implements the same behaviour as std::copysign except that it doesn't support Integral type. The latter is not in the namespace std in some Android toolchains.
Parameters
[in]xvalue that contains the magnitude to be used in constructing the result.
[in]yvalue that contains the sign to be used in construct in the result.
Returns
Floating-point value with magnitude of x and sign of y.

Definition at line 319 of file ToolchainSupport.h.

320 {
321  return std::copysign(x, y);
322 }
T copysign(T x, T y)
Composes a floating point value with the magnitude of x and the sign of y.

◆ fma()

T arm_compute::support::cpp11::fma ( x,
y,
z 
)
inline

Computes (x*y) + z as if to infinite precision and rounded only once to fit the result type.

Note
This function implements the same behaviour as std::fma except that it doesn't support Integral type. The latter is not in the namespace std in some Android toolchains.
Parameters
[in]xfloating-point value
[in]yfloating-point value
[in]zfloating-point value
Returns
Result floating point value equal to (x*y) + z.

Definition at line 336 of file ToolchainSupport.h.

337 {
338  return std::fma(x, y, z);
339 }
T fma(T x, T y, T z)
Computes (x*y) + z as if to infinite precision and rounded only once to fit the result type.

◆ isfinite() [1/2]

bool arm_compute::support::cpp11::isfinite ( value)
inline

◆ isfinite() [2/2]

bool arm_compute::support::cpp11::isfinite ( half_float::half  value)
inline

Definition at line 404 of file ToolchainSupport.h.

405 {
406  return half_float::isfinite(value);
407 }
bool isfinite(half_float::half value)

◆ lowest()

◆ nearbyint()

T arm_compute::support::cpp11::nearbyint ( value)
inline

Rounds the floating-point argument arg to an integer value in floating-point format, using the current rounding mode.

Note
This function acts as a convenience wrapper around std::nearbyint. The latter is missing in some Android toolchains.
Parameters
[in]valueValue to be rounded.
Returns
The rounded value.

Definition at line 257 of file ToolchainSupport.h.

258 {
259  return std::nearbyint(value);
260 }
T nearbyint(T value)
Rounds the floating-point argument arg to an integer value in floating-point format,...

Referenced by arm_compute::test::validation::reference::elementwise_unary().

◆ round()

T arm_compute::support::cpp11::round ( value)
inline

Round floating-point value with half value rounding away from zero.

Note
This function implements the same behaviour as std::round except that it doesn't support Integral type. The latter is not in the namespace std in some Android toolchains.
Parameters
[in]valuefloating-point value to be rounded.
Returns
Floating-point value of rounded value.

Definition at line 287 of file ToolchainSupport.h.

288 {
289  //Workaround Valgrind's mismatches: when running from Valgrind the call to std::round(-4.500000) == -4.000000 instead of 5.00000
290  return (value < 0.f) ? static_cast<int>(value - 0.5f) : static_cast<int>(value + 0.5f);
291 }

Referenced by arm_compute::round(), and NEROIPoolingLayerKernel::run().

◆ snprintf()

int arm_compute::support::cpp11::snprintf ( char *  s,
std::size_t  n,
const char *  fmt,
Ts &&...  args 
)
inline

Loads the data from the given location, converts them to character string equivalents and writes the result to a character string buffer.

Parameters
[in]sPointer to a character string to write to
[in]nUp to buf_size - 1 characters may be written, plus the null terminator
[in]fmtPointer to a null-terminated multibyte string specifying how to interpret the data.
[in]argsArguments forwarded to std::snprintf.
Returns
Number of characters that would have been written for a sufficiently large buffer if successful (not including the terminating null character), or a negative value if an error occurred.

Definition at line 353 of file ToolchainSupport.h.

354 {
355  return std::snprintf(s, n, fmt, std::forward<Ts>(args)...);
356 }
int snprintf(char *s, std::size_t n, const char *fmt, Ts &&... args)
Loads the data from the given location, converts them to character string equivalents and writes the ...

Referenced by arm_compute::create_error_va_list(), and arm_compute::logging::string_with_format().

◆ stof()

int arm_compute::support::cpp11::stof ( Ts &&...  args)

Convert string values to float.

Note
This function acts as a convenience wrapper around std::stof. The latter is missing in some Android toolchains.
Parameters
[in]argsArguments forwarded to std::stof.
Returns
Float representation of input string.

Definition at line 272 of file ToolchainSupport.h.

273 {
274  return ::std::stof(std::forward<Ts>(args)...);
275 }
int stof(Ts &&... args)
Convert string values to float.

◆ stoi()

int arm_compute::support::cpp11::stoi ( const std::string &  str,
std::size_t *  pos = 0,
NumericBase  base = NumericBase::BASE_10 
)
inline

Convert string values to integer.

Note
This function implements the same behaviour as std::stoi. The latter is missing in some Android toolchains.
Parameters
[in]strString to be converted to int.
[in]posIf idx is not a null pointer, the function sets the value of pos to the position of the first character in str after the number.
[in]baseNumeric base used to interpret the string.
Returns
Integer representation of str.

Definition at line 63 of file ToolchainSupport.h.

64 {
65  assert(base == NumericBase::BASE_10 || base == NumericBase::BASE_16);
66  unsigned int x;
67  std::stringstream ss;
68  if(base == NumericBase::BASE_16)
69  {
70  ss << std::hex;
71  }
72  ss << str;
73  ss >> x;
74  return x;
75 }

References BASE_10, and BASE_16.

Referenced by CLTuner::load_from_file().

◆ stoul()

unsigned long arm_compute::support::cpp11::stoul ( const std::string &  str,
std::size_t *  pos = 0,
NumericBase  base = NumericBase::BASE_10 
)
inline

Convert string values to unsigned long.

Note
This function implements the same behaviour as std::stoul. The latter is missing in some Android toolchains.
Parameters
[in]strString to be converted to unsigned long.
[in]posIf idx is not a null pointer, the function sets the value of pos to the position of the first character in str after the number.
[in]baseNumeric base used to interpret the string.
Returns
Unsigned long representation of str.

Definition at line 88 of file ToolchainSupport.h.

89 {
90  assert(base == NumericBase::BASE_10 || base == NumericBase::BASE_16);
91  std::stringstream stream;
92  unsigned long value = 0;
93  if(base == NumericBase::BASE_16)
94  {
95  stream << std::hex;
96  }
97  stream << str;
98  stream >> value;
99  return value;
100 }

References BASE_10, and BASE_16.

◆ to_string() [1/2]

std::string arm_compute::support::cpp11::to_string ( T &&  value)
inline

Convert integer and float values to string.

Note
This function acts as a convenience wrapper around std::to_string. The latter is missing in some Android toolchains.
Parameters
[in]valueValue to be converted to string.
Returns
String representation of value.

Definition at line 242 of file ToolchainSupport.h.

243 {
244  return ::std::to_string(std::forward<T>(value));
245 }
std::string to_string(bool value)

Referenced by GCLogits1DMaxKernel::configure(), CLIntegralImageHorKernel::configure(), CLElementWiseUnaryLayerKernel::configure(), CLMedian3x3Kernel::configure(), GCTransposeKernel::configure(), CLWarpAffineKernel::configure(), GCScaleKernel::configure(), CLScaleKernel::configure(), GCGEMMMatrixAccumulateBiasesKernel::configure(), CLGEMMMatrixAccumulateBiasesKernel::configure(), CLDepthwiseConvolutionLayer3x3NCHWKernel::configure(), CLGEMMMatrixVectorMultiplyKernel::configure(), CLDepthwiseConvolutionLayer3x3NHWCKernel::configure(), CLDequantizationLayerKernel::configure(), CLDepthwiseConvolutionLayerReshapeWeightsKernel::configure(), CLFlattenLayerKernel::configure(), CLMinMaxLayerKernel::configure(), CLFloorKernel::configure(), CLGaussianPyramidHorKernel::configure(), CLReverseKernel::configure(), CLChannelShuffleLayerKernel::configure(), CLCopyKernel::configure(), CLComputeAllAnchorsKernel::configure(), CLHistogramKernel::configure(), CLNormalizationLayerKernel::configure(), CLPermuteKernel::configure(), CLBatchToSpaceLayerKernel::configure(), CLSpaceToDepthLayerKernel::configure(), CLDepthToSpaceLayerKernel::configure(), CLGradientKernel::configure(), CLMinMaxKernel::configure(), CLQuantizationLayerKernel::configure(), CLReorgLayerKernel::configure(), CLGatherKernel::configure(), CLSpaceToBatchLayerKernel::configure(), CLTileKernel::configure(), CLDepthConvertLayerKernel::configure(), CLUpsampleLayerKernel::configure(), CLComparisonKernel::configure(), CLDepthwiseConvolutionLayerReshapeWeightsGenericKernel::configure(), GCDepthwiseConvolutionLayer3x3Kernel::configure(), GCPixelWiseMultiplicationKernel::configure(), GCPoolingLayerKernel::configure(), CLActivationLayerKernel::configure(), CLMeanStdDevNormalizationKernel::configure(), CLMemsetKernel::configure(), CLDerivativeKernel::configure(), CLFFTScaleKernel::configure(), CLSobel3x3Kernel::configure(), GCActivationLayerKernel::configure(), GCFillBorderKernel::configure(), GCGEMMMatrixAdditionKernel::configure(), GCNormalizationLayerKernel::configure(), CLHOGOrientationBinningKernel::configure(), CLFFTDigitReverseKernel::configure(), CLNormalizePlanarYUVLayerKernel::configure(), CLFillBorderKernel::configure(), CLPixelWiseMultiplicationKernel::configure(), CLPoolingLayerKernel::configure(), CLSobel5x5HorKernel::configure(), CLSobel7x7HorKernel::configure(), CLWidthConcatenate2TensorsKernel::configure(), CLDepthwiseVectorToTensorKernel::configure(), CLHeightConcatenateLayerKernel::configure(), CLBoundingBoxTransformKernel::configure(), GCNormalizePlanarYUVLayerKernel::configure(), CLCropKernel::configure(), CLPriorBoxLayerKernel::configure(), CLReductionOperationKernel::configure(), CLGEMMLowpMatrixMultiplyNativeKernel::configure(), CLWidthConcatenateLayerKernel::configure(), GCAbsoluteDifferenceKernel::configure(), GCArithmeticAdditionKernel::configure(), GCGEMMTranspose1xWKernel::configure(), CLColorConvertKernel::configure(), CLL2NormalizeLayerKernel::configure(), CLMagnitudePhaseKernel::configure(), CLGEMMReshapeRHSMatrixKernel::configure(), CLRangeKernel::configure(), CLWidthConcatenate4TensorsKernel::configure(), CLFFTRadixStageKernel::configure(), CLSelectKernel::configure(), GCBatchNormalizationLayerKernel::configure(), GCDepthConcatenateLayerKernel::configure(), GCDirectConvolutionLayerKernel< kernel_size >::configure(), CLConvertFullyConnectedWeightsKernel::configure(), CLConvolutionKernel< matrix_size >::configure(), CLBatchConcatenateLayerKernel::configure(), CLDepthwiseIm2ColKernel::configure(), CLDepthConcatenateLayerKernel::configure(), CLStackLayerKernel::configure(), CLGEMMReshapeLHSMatrixKernel::configure(), CLIntegralImageVertKernel::configure(), CLGEMMLowpMatrixMultiplyReshapedOnlyRHSKernel::configure(), CLWinogradInputTransformKernel::configure(), CLYOLOLayerKernel::configure(), CLROIPoolingLayerKernel::configure(), CLFuseBatchNormalizationKernel::configure(), CLROIAlignLayerKernel::configure(), CLGEMMMatrixMultiplyNativeKernel::configure(), CLWinogradFilterTransformKernel::configure(), GCDropoutLayerKernel::configure(), GCLogits1DShiftExpSumKernel::configure(), CLDirectConvolutionLayerOutputStageKernel::configure(), CLGEMMLowpMatrixMultiplyKernel::configure(), CLBatchNormalizationLayerKernel::configure(), GCGEMMMatrixMultiplyKernel::configure(), CLGEMMLowpMatrixMultiplyReshapedKernel::configure(), CLStridedSliceKernel::configure(), CLGEMMLowpOffsetContributionOutputStageKernel::configure(), CLHarrisScoreKernel::configure(), CLGEMMMatrixMultiplyReshapedOnlyRHSKernel::configure(), CLFastCornersKernel::configure(), CLWinogradOutputTransformKernel::configure(), CLHOGDetectorKernel::configure(), CLGEMMMatrixMultiplyKernel::configure(), CLGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel::configure(), CLDirectConvolutionLayerKernel::configure(), CLDeconvolutionReshapeOutputKernel::configure(), GCGEMMInterleave4x4Kernel::configure(), CLGEMMLowpQuantizeDownInt32ToUint8ScaleByFloatKernel::configure(), CLGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointKernel::configure(), CLGEMMMatrixMultiplyReshapedKernel::configure(), CLGEMMLowpQuantizeDownInt32ToUint8ScaleKernel::configure(), CLGEMMLowpOffsetContributionKernel::configure(), GCTensorShiftKernel::configure(), CLGEMMLowpMatrixAReductionKernel::configure(), CLCol2ImKernel::configure(), GCWeightsReshapeKernel::configure(), GCCol2ImKernel::configure(), CLIm2ColKernel::configure(), CLWeightsReshapeKernel::configure(), GCIm2ColKernel::configure(), CLHistogramBorderKernel::configure(), CLGaussianPyramidVertKernel::configure(), CLEdgeNonMaxSuppressionKernel::configure(), CLHOGBlockNormalizationKernel::configure(), CLSeparableConvolutionHorKernel< matrix_size >::configure(), GCLogits1DNormKernel::configure(), CLGEMMLowpMatrixBReductionKernel::configure(), CLSobel7x7VertKernel::configure(), CLSobel5x5VertKernel::configure(), CLCopyToArrayKernel::configure(), CLSeparableConvolutionVertKernel< matrix_size >::configure(), CLEdgeTraceKernel::configure(), CLConvolutionRectangleKernel::configure(), CLKernelLibrary::create_kernel(), RangeDataset< T >::iterator::description(), SingletonDataset< T >::iterator::description(), ContainerDataset< T >::iterator::description(), arm_compute::utils::get_typestring(), arm_compute::test::get_typestring(), arm_compute::test::join(), main(), OpenCLClock< output_timestamps >::measurements(), MaliCounter::measurements(), SchedulerClock< output_timestamps >::measurements(), Size2D::to_string(), arm_compute::to_string(), and CLTuner::tune_kernel_dynamic().

◆ to_string() [2/2]

std::string arm_compute::support::cpp11::to_string ( bool  value)
inline

Definition at line 359 of file ToolchainSupport.h.

360 {
361  std::stringstream str;
362  str << std::boolalpha << value;
363  return str.str();
364 }

◆ trunc()

T arm_compute::support::cpp11::trunc ( value)
inline

Truncate floating-point value.

Note
This function implements the same behaviour as std::truncate except that it doesn't support Integral type. The latter is not in the namespace std in some Android toolchains.
Parameters
[in]valuefloating-point value to be truncated.
Returns
Floating-point value of truncated value.

Definition at line 303 of file ToolchainSupport.h.

304 {
305  return std::trunc(value);
306 }
T trunc(T value)
Truncate floating-point value.

Referenced by arm_compute::test::validation::apply_2d_spatial_filter(), and FilePrinter::FilePrinter().