Conversion functions
Functions to acceleratŠµ conversion in Synet Framework. More...
Functions | |
SIMD_API void | SimdSynetConvert32fTo8u (const float *src, size_t batch, size_t channels, size_t height, size_t width, SimdTensorFormatType format, const float *scale, const float *shift, uint8_t *dst, SimdSynetCompatibilityType compatibility) |
Converts 32-bit float point image to 8-bit unsigned integer image. More... | |
SIMD_API void | SimdSynetConvert8uTo32f (const uint8_t *src, size_t batch, size_t channels, size_t height, size_t width, SimdTensorFormatType format, const float *scale, const float *shift, float *dst, SimdSynetCompatibilityType compatibility) |
Converts 8-bit unsigned integer image to 32-bit float point image. More... | |
SIMD_API void | SimdSynetSetInput (const uint8_t *src, size_t width, size_t height, size_t stride, SimdPixelFormatType srcFormat, const float *lower, const float *upper, float *dst, size_t channels, SimdTensorFormatType dstFormat) |
Sets image to the input of neural network of Synet Framework. More... | |
template<template< class > class A> | |
SIMD_INLINE void | SynetSetInput (const View< A > &src, const float *lower, const float *upper, float *dst, size_t channels, SimdTensorFormatType format) |
Sets image to the input of neural network of Synet Framework. More... | |
Detailed Description
Functions to acceleratŠµ conversion in Synet Framework.
Function Documentation
◆ SimdSynetConvert32fTo8u()
void SimdSynetConvert32fTo8u | ( | const float * | src, |
size_t | batch, | ||
size_t | channels, | ||
size_t | height, | ||
size_t | width, | ||
SimdTensorFormatType | format, | ||
const float * | scale, | ||
const float * | shift, | ||
uint8_t * | dst, | ||
SimdSynetCompatibilityType | compatibility | ||
) |
Converts 32-bit float point image to 8-bit unsigned integer image.
- Note
- This function is used in Synet Framework.
- Parameters
-
[in] src - a pointer to the 32-bit float array with input image tensor. [in] batch - a number of images in the batch of (input/output) image tensor. [in] channels - a number of channels in the (input/output) image tensor. [in] height - a height of (input/output) image tensor. [in] width - a width of (input/output) image tensor. [in] format - a format of (input/output) image tensor. [in] scale - a pointer to the 32-bit float array with scale coefficients. [in] shift - a pointer to the 32-bit float array with shift coefficients. [out] dst - a pointer to the 8-bit unsigned integer array with output image tensor. [in] compatibility - a flags of calculation compatibility.
◆ SimdSynetConvert8uTo32f()
void SimdSynetConvert8uTo32f | ( | const uint8_t * | src, |
size_t | batch, | ||
size_t | channels, | ||
size_t | height, | ||
size_t | width, | ||
SimdTensorFormatType | format, | ||
const float * | scale, | ||
const float * | shift, | ||
float * | dst, | ||
SimdSynetCompatibilityType | compatibility | ||
) |
Converts 8-bit unsigned integer image to 32-bit float point image.
- Note
- This function is used in Synet Framework.
- Parameters
-
[in] src - a pointer to the 8-bit unsigned integer array with input image tensor. [in] batch - a number of images in the batch of (input/output) image tensor. [in] channels - a number of channels in the (input/output) image tensor. [in] height - a height of (input/output) image tensor. [in] width - a width of (input/output) image tensor. [in] format - a format of (input/output) image tensor. [in] scale - a pointer to the 32-bit float array with scale coefficients. [in] shift - a pointer to the 32-bit float array with shift coefficients. [out] dst - a pointer to the array with 32-bit float output image tensor. [in] compatibility - a flags of calculation compatibility.
◆ SimdSynetSetInput()
void void SimdSynetSetInput | ( | const uint8_t * | src, |
size_t | width, | ||
size_t | height, | ||
size_t | stride, | ||
SimdPixelFormatType | srcFormat, | ||
const float * | lower, | ||
const float * | upper, | ||
float * | dst, | ||
size_t | channels, | ||
SimdTensorFormatType | dstFormat | ||
) |
Sets image to the input of neural network of Synet Framework.
Algorithm's details (example for BGRA pixel format and NCHW tensor format):
for(c = 0; c < channels; ++c) for(y = 0; y < height; ++y) for(x = 0; x < width; ++x) dst[(c*height + y)*width + x] = src[stride*y + width*4 + c]*(upper[c] - lower[c])/255 + lower[c];
Note that there are following relationships:
upper[c] = (1 - mean[c]) / std[c]; lower[c] = - mean[c] / std[c];
- Note
- This function has a C++ wrappers: Simd::SynetSetInput(const View<A> & src, const float * lower, const float * upper, float * dst, size_t channels, SimdTensorFormatType format).
- Parameters
-
[in] src - a pointer to pixels data of input image. [in] width - a width of input image and output image tensor. [in] height - a height of input image and output image tensor. [in] stride - a row size of input image. [in] srcFormat - a pixel format of input image. There are supported following pixel formats: SimdPixelFormatGray8, SimdPixelFormatBgr24, SimdPixelFormatBgra32, SimdPixelFormatRgb24, SimdPixelFormatRgba32. [in] lower - a pointer to the array with lower bound of values of the output tensor. The size of the array have to correspond number of channels in the output image tensor. [in] upper - a pointer to the array with upper bound of values of the output tensor. The size of the array have to correspond number of channels in the output image tensor. [out] dst - a pointer to the output 32-bit float image tensor. [in] channels - a number of channels in the output image tensor. It can be 1 or 3. [in] dstFormat - a format of output image tensor. There are supported following tensor formats: SimdTensorFormatNchw, SimdTensorFormatNhwc.
◆ SynetSetInput()
void SynetSetInput | ( | const View< A > & | src, |
const float * | lower, | ||
const float * | upper, | ||
float * | dst, | ||
size_t | channels, | ||
SimdTensorFormatType | format | ||
) |
Sets image to the input of neural network of Synet Framework.
Algorithm's details (example for BGRA pixel format and NCHW tensor format):
for(c = 0; c < channels; ++c) for(y = 0; y < src.height; ++y) for(x = 0; x < src.width; ++x) dst[(c*height + y)*width + x] = src.data[src.stride*y + src.width*4 + c]*(upper[c] - lower[c])/255 + lower[c];
Note that there are following relationships:
upper[c] = (1 - mean[c]) / std[c]; lower[c] = - mean[c] / std[c];
- Note
- This function is a C++ wrapper for function SimdSynetSetInput.
- Parameters
-
[in] src - an input image.There are supported following image formats: View<A>::Gray8, View<A>::Bgr24, View<A>::Bgra32, View<A>::Rgb24. [in] lower - a pointer to the array with lower bound of values of the output tensor. The size of the array have to correspond number of channels in the output image tensor. [in] upper - a pointer to the array with upper bound of values of the output tensor. The size of the array have to correspond number of channels in the output image tensor. [out] dst - a pointer to the output 32-bit float image tensor. [in] channels - a number of channels in the output image tensor. It can be 1 or 3. [in] format - a format of output image tensor. There are supported following tensor formats: SimdTensorFormatNchw, SimdTensorFormatNhwc.