Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub
Neural Network

Artificial Neural Network's functions for accelerating of Simd::Neural. More...

Functions

SIMD_API void SimdNeuralConvert (const uint8_t *src, size_t srcStride, size_t width, size_t height, float *dst, size_t dstStride, int inversion)
 Converts a 8-bit gray image to the 32-bit float array. More...
 
SIMD_API void SimdNeuralDerivativeSigmoid (const float *src, size_t size, const float *slope, float *dst)
 Multiplies output 32-bit float array by derivative of sigmoid from input 32-bit float array. More...
 
SIMD_API void SimdNeuralDerivativeTanh (const float *src, size_t size, const float *slope, float *dst)
 Multiplies output 32-bit float array by derivative of hyperbolic tangent from input 32-bit float array. More...
 
SIMD_API void SimdNeuralDerivativeRelu (const float *src, size_t size, const float *slope, float *dst)
 Multiplies output 32-bit float array by derivative of Relu (rectified linear unit) from input 32-bit float array. More...
 
SIMD_API void SimdNeuralPow (const float *src, size_t size, const float *exponent, float *dst)
 Calculates Pow function for 32-bit float array. More...
 
SIMD_API void SimdNeuralProductSum (const float *a, const float *b, size_t size, float *sum)
 Calculates sum of products for two 32-bit float arrays. More...
 
SIMD_API void SimdNeuralAddVectorMultipliedByValue (const float *src, size_t size, const float *value, float *dst)
 Adds the product of a vector and a scalar to given vector. More...
 
SIMD_API void SimdNeuralAddVector (const float *src, size_t size, float *dst)
 Adds a vector to given vector. More...
 
SIMD_API void SimdNeuralAddValue (const float *value, float *dst, size_t size)
 Adds a value to each elements of given vector. More...
 
SIMD_API void SimdNeuralUpdateWeights (const float *x, size_t size, const float *a, const float *b, float *d, float *w)
 Updates ANN weights. More...
 
SIMD_API void SimdNeuralAdaptiveGradientUpdate (const float *delta, size_t size, size_t batch, const float *alpha, const float *epsilon, float *gradient, float *weight)
 Updates neural network weights with using of adaptive gradients method. More...
 
SIMD_API void SimdNeuralAddConvolution2x2Forward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 2x2 convolution of 32-bit float image. More...
 
SIMD_API void SimdNeuralAddConvolution3x3Forward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 3x3 convolution of 32-bit float image. More...
 
SIMD_API void SimdNeuralAddConvolution4x4Forward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 4x4 convolution of 32-bit float image. More...
 
SIMD_API void SimdNeuralAddConvolution5x5Forward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 5x5 convolution of 32-bit float image (forward propagation). More...
 
SIMD_API void SimdNeuralAddConvolution2x2Backward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 2x2 convolution of 32-bit float image (backward propagation). More...
 
SIMD_API void SimdNeuralAddConvolution3x3Backward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 3x3 convolution of 32-bit float image (backward propagation). More...
 
SIMD_API void SimdNeuralAddConvolution4x4Backward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 4x4 convolution of 32-bit float image (backward propagation). More...
 
SIMD_API void SimdNeuralAddConvolution5x5Backward (const float *src, size_t srcStride, size_t width, size_t height, const float *weights, float *dst, size_t dstStride)
 Adds 5x5 convolution of 32-bit float image (backward propagation). More...
 
SIMD_API void SimdNeuralAddConvolution2x2Sum (const float *src, size_t srcStride, const float *dst, size_t dstStride, size_t width, size_t height, float *sums)
 Accumulates changes of weights for 2x2 convolution of 32-bit float image during backward propagation. More...
 
SIMD_API void SimdNeuralAddConvolution3x3Sum (const float *src, size_t srcStride, const float *dst, size_t dstStride, size_t width, size_t height, float *sums)
 Accumulates changes of weights for 3x3 convolution of 32-bit float image during backward propagation. More...
 
SIMD_API void SimdNeuralAddConvolution4x4Sum (const float *src, size_t srcStride, const float *dst, size_t dstStride, size_t width, size_t height, float *sums)
 Accumulates changes of weights for 4x4 convolution of 32-bit float image during backward propagation. More...
 
SIMD_API void SimdNeuralAddConvolution5x5Sum (const float *src, size_t srcStride, const float *dst, size_t dstStride, size_t width, size_t height, float *sums)
 Accumulates changes of weights for 5x5 convolution of 32-bit float image during backward propagation. More...
 
SIMD_API void SimdNeuralPooling1x1Max3x3 (const float *src, size_t srcStride, size_t width, size_t height, float *dst, size_t dstStride)
 Takes maximum value in 3x3 window of input 32-bit float image and copies to the output image. More...
 
SIMD_API void SimdNeuralPooling2x2Max2x2 (const float *src, size_t srcStride, size_t width, size_t height, float *dst, size_t dstStride)
 Reduces input 32-bit float image in two times (takes maximum value in 2x2 window and copies to the output image). More...
 
SIMD_API void SimdNeuralPooling2x2Max3x3 (const float *src, size_t srcStride, size_t width, size_t height, float *dst, size_t dstStride)
 Reduces input 32-bit float image in two times (takes maximum value in 3x3 window and copies to the output image). More...
 
SIMD_API void SimdNeuralConvolutionForward (const float *src, size_t srcWidth, size_t srcHeight, size_t srcDepth, const float *weight, size_t kernelX, size_t kernelY, size_t padX, size_t padY, size_t strideX, size_t strideY, size_t dilationX, size_t dilationY, void *buffer, size_t *size, float *dst, size_t dstWidth, size_t dstHeight, size_t dstDepth, int add)
 Adds convolution of the input multichannel 32-bit float image to the output multichannel 32-bit float image. More...
 
template<template< class > class A>
SIMD_INLINE void NeuralConvert (const View< A > &src, float *dst, size_t stride, bool inversion)
 Converts a 8-bit gray image to the 32-bit float array. More...
 

Detailed Description

Artificial Neural Network's functions for accelerating of Simd::Neural.

Function Documentation

◆ SimdNeuralConvert()

void SimdNeuralConvert ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
float *  dst,
size_t  dstStride,
int  inversion 
)

Converts a 8-bit gray image to the 32-bit float array.

The length of output array must be equal to the area of input image.

For every point:

dst[i] = inversion ? (255 - src[col]) / 255 : src[i]/255;
Note
This function has a C++ wrapper Simd::NeuralConvert(const View<A>& src, float * dst, bool inversion).
Parameters
[in]src- a pointer to pixels data of input image.
[in]srcStride- a row size (in bytes) of the image.
[in]width- an image width.
[in]height- an image height.
[out]dst- a pointer to output array.
[in]dstStride- a row size of the output array.
[in]inversion- a flag of color inversion.

◆ SimdNeuralDerivativeSigmoid()

void SimdNeuralDerivativeSigmoid ( const float *  src,
size_t  size,
const float *  slope,
float *  dst 
)

Multiplies output 32-bit float array by derivative of sigmoid from input 32-bit float array.

All arrays must have the same size.

For every element:

dst[i] *= slope*(1 - src[i])*src[i];
Note
This function is used in Simd::Neural::Function.
Parameters
[in]src- a pointer to the input array.
[in]size- a size of arrays.
[in]slope- a pointer to the slope parameter.
[in,out]dst- a pointer to output array.

◆ SimdNeuralDerivativeTanh()

void SimdNeuralDerivativeTanh ( const float *  src,
size_t  size,
const float *  slope,
float *  dst 
)

Multiplies output 32-bit float array by derivative of hyperbolic tangent from input 32-bit float array.

All arrays must have the same size.

For every element:

dst[i] *= slope*(1 - src[i]*src[i]);
Note
This function is used in Simd::Neural::Function.
Parameters
[in]src- a pointer to the input array.
[in]size- a size of arrays.
[in]slope- a pointer to the slope parameter.
[in,out]dst- a pointer to output array.

◆ SimdNeuralDerivativeRelu()

void SimdNeuralDerivativeRelu ( const float *  src,
size_t  size,
const float *  slope,
float *  dst 
)

Multiplies output 32-bit float array by derivative of Relu (rectified linear unit) from input 32-bit float array.

All arrays must have the same size.

For every element:

dst[i] *=  src[i] > 0 ? 1 : slope;
Note
This function is used in Simd::Neural::Function.
Parameters
[in]src- a pointer to the input array.
[in]size- a size of arrays.
[in]slope- a pointer to the slope parameter.
[in,out]dst- a pointer to output array.

◆ SimdNeuralPow()

void SimdNeuralPow ( const float *  src,
size_t  size,
const float *  exponent,
float *  dst 
)

Calculates Pow function for 32-bit float array.

All arrays must have the same size.

For every element:

dst[i] =  Pow(src[i], exponent[0]);
Note
This function is used in Simd::Neural::Function.
Parameters
[in]src- a pointer to the input array.
[in]size- a size of arrays.
[in]exponent- a pointer to exponent parameter.
[out]dst- a pointer to output array.

◆ SimdNeuralProductSum()

void SimdNeuralProductSum ( const float *  a,
const float *  b,
size_t  size,
float *  sum 
)

Calculates sum of products for two 32-bit float arrays.

All arrays must have the same size.

For every element:

sum += a[i]*b[i];
Note
This function is used in Simd::Neural.
Parameters
[in]a- a pointer to the first 32-bit float array.
[in]b- a pointer to the second 32-bit float array.
[in]size- a size of arrays.
[out]sum- a pointer to 32-bit float sum of products.

◆ SimdNeuralAddVectorMultipliedByValue()

void SimdNeuralAddVectorMultipliedByValue ( const float *  src,
size_t  size,
const float *  value,
float *  dst 
)

Adds the product of a vector and a scalar to given vector.

All arrays must have the same size.

For every element:

dst[i] += src[i]*value[0];
Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float array.
[in]size- a size of arrays.
[in]value- a pointer to the scalar 32-bit float value.
[in,out]dst- a pointer to cumulative 32-bit float array.

◆ SimdNeuralAddVector()

void SimdNeuralAddVector ( const float *  src,
size_t  size,
float *  dst 
)

Adds a vector to given vector.

All arrays must have the same size.

For every element:

dst[i] += src[i];
Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float array.
[in]size- a size of the arrays.
[in,out]dst- a pointer to cumulative 32-bit float array.

◆ SimdNeuralAddValue()

void SimdNeuralAddValue ( const float *  value,
float *  dst,
size_t  size 
)

Adds a value to each elements of given vector.

For every element:

dst[i] += value;
Note
This function is used in Simd::Neural.
Parameters
[in]value- a pointer to the scalar 32-bit float value.
[in,out]dst- a pointer to cumulative 32-bit float array.
[in]size- a size of the array.

◆ SimdNeuralUpdateWeights()

void SimdNeuralUpdateWeights ( const float *  x,
size_t  size,
const float *  a,
const float *  b,
float *  d,
float *  w 
)

Updates ANN weights.

All arrays must have the same size.

The algorithm performs:

for (size_t k = 0; k < size; ++k)
{
    d[k] = a[0]*d[k] + b[0]*x[k];
    w[k] += d[k];
}
Parameters
[in]x- a pointer to the X array.
[in]size- a size of arrays.
[in]a- a pointer to the first parameter.
[in]b- a pointer to the second parameter.
[in,out]d- a pointer to the D array.
[in,out]w- a pointer to the W array.

◆ SimdNeuralAdaptiveGradientUpdate()

void SimdNeuralAdaptiveGradientUpdate ( const float *  delta,
size_t  size,
size_t  batch,
const float *  alpha,
const float *  epsilon,
float *  gradient,
float *  weight 
)

Updates neural network weights with using of adaptive gradients method.

Adaptive gradients method. J Duchi, E Hazan and Y Singer, "Adaptive subgradient methods for online learning and stochastic optimization" The Journal of Machine Learning Research, pages 2121-2159, 2011.

The algorithm performs:

for (i = 0; i < size; ++i)
{
    d = delta[i]/batch;
    gradient[i] += d*d;
    weight[i] -= alpha * d / sqrt(gradient[i] + epsilon);
}
Note
All arrays must have the same size. This function is used in Simd::Neural.
Parameters
[in]delta- a pointer to the array with error (delta).
[in]size- a size of arrays.
[in]batch- a batch size.
[in]alpha- a pointer to alpha parameter (update speed).
[in]epsilon- a pointer to epsilon parameter (a small number used to avoid division by zero).
[in,out]gradient- a pointer to the array with gradients.
[in,out]weight- a pointer to the array with weights.

◆ SimdNeuralAddConvolution2x2Forward()

void SimdNeuralAddConvolution2x2Forward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 2x2 convolution of 32-bit float image.

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 1).
[in]height- a height of the output image (input image height must be equal to output image height + 1).
[in]weights- a pointer to the array with weights (its size must be at least 4).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution3x3Forward()

void SimdNeuralAddConvolution3x3Forward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 3x3 convolution of 32-bit float image.

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 2).
[in]height- a height of the output image (input image height must be equal to output image height + 2).
[in]weights- a pointer to the array with weights (its size must be at least 9).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution4x4Forward()

void SimdNeuralAddConvolution4x4Forward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 4x4 convolution of 32-bit float image.

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 3).
[in]height- a height of the output image (input image height must be equal to output image height + 3).
[in]weights- a pointer to the array with weights (its size must be at least 16).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution5x5Forward()

void SimdNeuralAddConvolution5x5Forward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 5x5 convolution of 32-bit float image (forward propagation).

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 4).
[in]height- a height of the output image (input image height must be equal to output image height + 4).
[in]weights- a pointer to the array with weights (its size must be at least 25).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution2x2Backward()

void SimdNeuralAddConvolution2x2Backward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 2x2 convolution of 32-bit float image (backward propagation).

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the input image (output image width must be equal to input image width + 1).
[in]height- a height of the input image (output image height must be equal to input image height + 1).
[in]weights- a pointer to the array with weights (its size must be at least 4).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution3x3Backward()

void SimdNeuralAddConvolution3x3Backward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 3x3 convolution of 32-bit float image (backward propagation).

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the input image (output image width must be equal to input image width + 2).
[in]height- a height of the input image (output image height must be equal to input image height + 2).
[in]weights- a pointer to the array with weights (its size must be at least 9).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution4x4Backward()

void SimdNeuralAddConvolution4x4Backward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 4x4 convolution of 32-bit float image (backward propagation).

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the input image (output image width must be equal to input image width + 3).
[in]height- a height of the input image (output image height must be equal to input image height + 3).
[in]weights- a pointer to the array with weights (its size must be at least 16).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution5x5Backward()

void SimdNeuralAddConvolution5x5Backward ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const float *  weights,
float *  dst,
size_t  dstStride 
)

Adds 5x5 convolution of 32-bit float image (backward propagation).

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the input image (output image width must be equal to input image width + 4).
[in]height- a height of the input image (output image height must be equal to input image height + 4).
[in]weights- a pointer to the array with weights (its size must be at least 25).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralAddConvolution2x2Sum()

void SimdNeuralAddConvolution2x2Sum ( const float *  src,
size_t  srcStride,
const float *  dst,
size_t  dstStride,
size_t  width,
size_t  height,
float *  sums 
)

Accumulates changes of weights for 2x2 convolution of 32-bit float image during backward propagation.

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 1).
[in]height- a height of the output image (input image height must be equal to output image height + 1).
[in,out]sums- a pointer to the array with changes of weights (its size must be at least 4).

◆ SimdNeuralAddConvolution3x3Sum()

void SimdNeuralAddConvolution3x3Sum ( const float *  src,
size_t  srcStride,
const float *  dst,
size_t  dstStride,
size_t  width,
size_t  height,
float *  sums 
)

Accumulates changes of weights for 3x3 convolution of 32-bit float image during backward propagation.

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 2).
[in]height- a height of the output image (input image height must be equal to output image height + 2).
[in,out]sums- a pointer to the array with changes of weights (its size must be at least 9).

◆ SimdNeuralAddConvolution4x4Sum()

void SimdNeuralAddConvolution4x4Sum ( const float *  src,
size_t  srcStride,
const float *  dst,
size_t  dstStride,
size_t  width,
size_t  height,
float *  sums 
)

Accumulates changes of weights for 4x4 convolution of 32-bit float image during backward propagation.

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 3).
[in]height- a height of the output image (input image height must be equal to output image height + 3).
[in,out]sums- a pointer to the array with changes of weights (its size must be at least 16).

◆ SimdNeuralAddConvolution5x5Sum()

void SimdNeuralAddConvolution5x5Sum ( const float *  src,
size_t  srcStride,
const float *  dst,
size_t  dstStride,
size_t  width,
size_t  height,
float *  sums 
)

Accumulates changes of weights for 5x5 convolution of 32-bit float image during backward propagation.

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).
[in]width- a width of the output image (input image width must be equal to output image width + 4).
[in]height- a height of the output image (input image height must be equal to output image height + 4).
[in,out]sums- a pointer to the array with changes of weights (its size must be at least 25).

◆ SimdNeuralPooling1x1Max3x3()

void SimdNeuralPooling1x1Max3x3 ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
float *  dst,
size_t  dstStride 
)

Takes maximum value in 3x3 window of input 32-bit float image and copies to the output image.

Note
This function is used in Simd::Neural. Output image must have the same size.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the input image.
[in]height- a height of the input image.
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralPooling2x2Max2x2()

void SimdNeuralPooling2x2Max2x2 ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
float *  dst,
size_t  dstStride 
)

Reduces input 32-bit float image in two times (takes maximum value in 2x2 window and copies to the output image).

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the input image (output image width must have size (width + 1)/2).
[in]height- a height of the input image (output image height must have size (height + 1)/2).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralPooling2x2Max3x3()

void SimdNeuralPooling2x2Max3x3 ( const float *  src,
size_t  srcStride,
size_t  width,
size_t  height,
float *  dst,
size_t  dstStride 
)

Reduces input 32-bit float image in two times (takes maximum value in 3x3 window and copies to the output image).

Note
This function is used in Simd::Neural.
Parameters
[in]src- a pointer to the input 32-bit float image.
[in]srcStride- a row size of the input image (in 32-float values).
[in]width- a width of the input image (output image width must have size width/2).
[in]height- a height of the input image (output image height must have size height/2).
[in,out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-float values).

◆ SimdNeuralConvolutionForward()

void SimdNeuralConvolutionForward ( const float *  src,
size_t  srcWidth,
size_t  srcHeight,
size_t  srcDepth,
const float *  weight,
size_t  kernelX,
size_t  kernelY,
size_t  padX,
size_t  padY,
size_t  strideX,
size_t  strideY,
size_t  dilationX,
size_t  dilationY,
void *  buffer,
size_t *  size,
float *  dst,
size_t  dstWidth,
size_t  dstHeight,
size_t  dstDepth,
int  add 
)

Adds convolution of the input multichannel 32-bit float image to the output multichannel 32-bit float image.

Note
There is a restriction to the size of output image:
dstWidth = (srcWidth + 2 * padX - (dilationX * (kernelX - 1) + 1)) / strideX + 1.
dstHeight = (srcHeight + 2 * padY - (dilationY * (kernelY - 1) + 1)) / strideY + 1.
Parameters
[in]src- a pointer to the input multichannel 32-bit float image. Total size of the input image is equal to srcWidth*srcHeight*srcDepth.
[in]srcWidth- a width of the input image.
[in]srcHeight- a height of the input image.
[in]srcDepth- a number of channels in the input image.
[in]weight- a pointer to the convolution weights. Total size of the weights is equal to kernelX*kernelY*srcDepth*dstDepth.
[in]kernelX- a width of the convolution kernel.
[in]kernelY- a height of the convolution kernel.
[in]padX- a pad to the x-coordinate of the input image.
[in]padY- a pad to the y-coordinate of the input image.
[in]strideX- a x-stride of the convolution.
[in]strideY- a y-stride of the convolution.
[in]dilationX- a x-stride of the convolution.
[in]dilationY- a y-stride of the convolution.
[in,out]buffer- a pointer to the external temporal buffer used by the algorithm. Can be NULL (the algorithm uses internal buffer).
[in,out]size- a pointer to the size of the external temporal buffer. If the size is too small it will contain required value. Required size is approximately equal to dstWidth*dstHeight*srcDepth*kernelX*kernelY*sizeof(float). Can be NULL.
[in,out]dst- a pointer to the output multichannel 32-bit float image. Total size of the output image is equal to dstWidth*dstHeight*dstDepth.
[in]dstWidth- a width of the output image.
[in]dstHeight- a height of the output image.
[in]dstDepth- a number of channels in the output image.
[in]add- a flag which signalizes that we want add or assign value of convolution to the output image.

◆ NeuralConvert()

void NeuralConvert ( const View< A > &  src,
float *  dst,
size_t  stride,
bool  inversion 
)

Converts a 8-bit gray image to the 32-bit float array.

The length of output array must be equal to the area of input image.

For every point:

dst[i] = inversion ? (255 - src[col]) / 255 : src[i]/255;
Note
This function is a C++ wrapper for function SimdNeuralConvert.
Parameters
[in]src- an input image.
[out]dst- a pointer to output array.
[in]stride- a row size of the output array.
[in]inversion- a flag of color inversion.