Conversion functions
Functions to acceleratе conversion in Synet Framework. More...
Functions | |
SIMD_API void | SimdSynetConvertImage (size_t batch, size_t channels, size_t spatial, const float *src, SimdTensorFormatType srcFormat, float *dst, SimdTensorFormatType dstFormat) |
Converts (input/output) image between different formats of 4D-tensor. More... | |
SIMD_API void | SimdSynetConvertFilter (size_t output, size_t input, size_t kernel, const float *src, SimdTensorFormatType srcFormat, float *dst, SimdTensorFormatType dstFormat) |
Converts 2d-convolution filter weight between different formats of 4D-tensor. 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
◆ SimdSynetConvertImage()
void SimdSynetConvertImage | ( | size_t | batch, |
size_t | channels, | ||
size_t | spatial, | ||
const float * | src, | ||
SimdTensorFormatType | srcFormat, | ||
float * | dst, | ||
SimdTensorFormatType | dstFormat | ||
) |
Converts (input/output) image between different formats of 4D-tensor.
- Note
- This function is used in Synet Framework. Conversion between SimdTensorFormatNchw4c, SimdTensorFormatNchw8c, SimdTensorFormatNchw16c is not supported.
- Parameters
-
[in] batch - a batch (number of images in the batch). [in] channels - a number of image channels. [in] spatial - a spatial size (height*width) of image. [in] src - a pointer to input image data. [in] srcFormat - a format of input image. It can be SimdTensorFormatNchw, SimdTensorFormatNhwc, SimdTensorFormatNchw4c, SimdTensorFormatNchw8c, SimdTensorFormatNchw16c. [out] dst - a pointer to output image data. [in] dstFormat - a format of output image. It can be SimdTensorFormatNchw, SimdTensorFormatNhwc, SimdTensorFormatNchw4c, SimdTensorFormatNchw8c, SimdTensorFormatNchw16c.
◆ SimdSynetConvertFilter()
void SimdSynetConvertFilter | ( | size_t | output, |
size_t | input, | ||
size_t | kernel, | ||
const float * | src, | ||
SimdTensorFormatType | srcFormat, | ||
float * | dst, | ||
SimdTensorFormatType | dstFormat | ||
) |
Converts 2d-convolution filter weight between different formats of 4D-tensor.
- Note
- This function is used in Synet Framework. Conversion between SimdTensorFormatOyxi4o, SimdTensorFormatOyxi8o, SimdTensorFormatOyxi16o is not supported.
- Parameters
-
[in] output - a number of output channels in filter. [in] input - a number of intput channels in filter. [in] kernel - a size (width*height) of filter kernel. [in] src - a pointer to input filter data.
[in] srcFormat - a format of input filter. It can be SimdTensorFormatOiyx, SimdTensorFormatYxio, SimdTensorFormatOyxi4o, SimdTensorFormatOyxi8o, SimdTensorFormatOyxi16o. [out] dst - a pointer to output filter data. [in] dstFormat - a format of output filter. It can be SimdTensorFormatOiyx, SimdTensorFormatYxio, SimdTensorFormatOyxi4o, SimdTensorFormatOyxi8o, SimdTensorFormatOyxi16o.
◆ 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
- 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. [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
- 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.