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 an 8-bit gray image to a 32-bit floating-point image scaled to [0, 1]. More...
 
SIMD_API void SimdNeuralDerivativeSigmoid (const float *src, size_t size, const float *slope, float *dst)
 Multiplies a 32-bit float array by the derivative of sigmoid values. More...
 
SIMD_API void SimdNeuralDerivativeTanh (const float *src, size_t size, const float *slope, float *dst)
 Multiplies a 32-bit float array by the derivative of hyperbolic tangent values. More...
 
SIMD_API void SimdNeuralDerivativeRelu (const float *src, size_t size, const float *slope, float *dst)
 Multiplies a 32-bit float array by the derivative of ReLU values. More...
 
SIMD_API void SimdNeuralPow (const float *src, size_t size, const float *exponent, float *dst)
 Raises every 32-bit float array element to a scalar exponent. More...
 
SIMD_API void SimdNeuralProductSum (const float *a, const float *b, size_t size, float *sum)
 Calculates the dot product of two 32-bit float arrays. More...
 
SIMD_API void SimdNeuralAddVectorMultipliedByValue (const float *src, size_t size, const float *value, float *dst)
 Adds a source vector multiplied by a scalar to a destination vector. More...
 
SIMD_API void SimdNeuralAddVector (const float *src, size_t size, float *dst)
 Adds a source vector to a destination vector. More...
 
SIMD_API void SimdNeuralAddValue (const float *value, float *dst, size_t size)
 Adds a scalar value to every element of a vector. More...
 
SIMD_API void SimdNeuralUpdateWeights (const float *x, size_t size, const float *a, const float *b, float *d, float *w)
 Updates weight increments and weights for a 32-bit float vector. 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 by the adaptive gradient 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 a valid 2x2 convolution of a 32-bit float image to dst. 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 a valid 3x3 convolution of a 32-bit float image to dst. 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 a valid 4x4 convolution of a 32-bit float image to dst. 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 a valid 5x5 convolution of a 32-bit float image to dst. 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 a 2x2 transposed convolution contribution to dst. 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 a 3x3 transposed convolution contribution to dst. 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 a 4x4 transposed convolution contribution to dst. 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 a 5x5 transposed convolution contribution to dst. 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 2x2 convolution weight gradients into sums. 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 3x3 convolution weight gradients into sums. 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 4x4 convolution weight gradients into sums. 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 5x5 convolution weight gradients into sums. More...
 
SIMD_API void SimdNeuralPooling1x1Max3x3 (const float *src, size_t srcStride, size_t width, size_t height, float *dst, size_t dstStride)
 Performs stride-1 max pooling with a clipped 3x3 window. More...
 
SIMD_API void SimdNeuralPooling2x2Max2x2 (const float *src, size_t srcStride, size_t width, size_t height, float *dst, size_t dstStride)
 Performs stride-2 max pooling with a clipped 2x2 window. More...
 
SIMD_API void SimdNeuralPooling2x2Max3x3 (const float *src, size_t srcStride, size_t width, size_t height, float *dst, size_t dstStride)
 Performs stride-2 max pooling with a clipped 3x3 window. 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)
 Performs forward convolution for NCHW-style 32-bit float tensors. 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 an 8-bit gray image to a 32-bit floating-point image scaled to [0, 1].

For every point:

dst[x, y] = inversion ? (255 - src[x, y])/255.0 : src[x, y]/255.0;
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 8-bit gray image.
[in]srcStride- a row size of the input image (in bytes).
[in]width- an image width.
[in]height- an image height.
[out]dst- a pointer to output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-bit float values).
[in]inversion- a flag of color inversion.

◆ SimdNeuralDerivativeSigmoid()

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

Multiplies a 32-bit float array by the derivative of sigmoid values.

For every element:

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

◆ SimdNeuralDerivativeTanh()

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

Multiplies a 32-bit float array by the derivative of hyperbolic tangent values.

For every element:

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

◆ SimdNeuralDerivativeRelu()

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

Multiplies a 32-bit float array by the derivative of ReLU values.

For every element:

dst[i] *= src[i] > 0 ? 1 : slope[0];
Note
This function is used in Simd::Neural::Function.
Parameters
[in]src- a pointer to input values used to choose the derivative branch.
[in]size- a size of arrays.
[in]slope- a pointer to the slope parameter for non-positive values.
[in,out]dst- a pointer to cumulative 32-bit float array.

◆ SimdNeuralPow()

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

Raises every 32-bit float array element to a scalar exponent.

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 the dot product of two 32-bit float arrays.

For every element:

sum[0] = 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 dot product.

◆ SimdNeuralAddVectorMultipliedByValue()

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

Adds a source vector multiplied by a scalar to a destination vector.

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 source vector to a destination vector.

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 scalar value to every element of a vector.

For every element:

dst[i] += value[0];
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 weight increments and weights for a 32-bit float vector.

For every element:

d[i] = a[0]*d[i] + b[0]*x[i];
w[i] += d[i];
Parameters
[in]x- a pointer to the input X array.
[in]size- a size of arrays.
[in]a- a pointer to the first scalar parameter.
[in]b- a pointer to the second scalar 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 by the adaptive gradient method.

For every element:

d = delta[i]/batch;
gradient[i] += d*d;
weight[i] -= alpha[0]*d/Sqrt(gradient[i] + epsilon[0]);
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 gradients.
[in]size- a size of arrays.
[in]batch- a batch size used to normalize delta.
[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 accumulated squared 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 a valid 2x2 convolution of a 32-bit float image to dst.

For every output point:

dst[x, y] += Sum(src[x + kx, y + ky]*weights[ky*2 + kx]), 0 <= kx, ky < 2;
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-bit 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-bit 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 a valid 3x3 convolution of a 32-bit float image to dst.

For every output point:

dst[x, y] += Sum(src[x + kx, y + ky]*weights[ky*3 + kx]), 0 <= kx, ky < 3;
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-bit 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-bit 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 a valid 4x4 convolution of a 32-bit float image to dst.

For every output point:

dst[x, y] += Sum(src[x + kx, y + ky]*weights[ky*4 + kx]), 0 <= kx, ky < 4;
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-bit 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-bit 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 a valid 5x5 convolution of a 32-bit float image to dst.

For every output point:

dst[x, y] += Sum(src[x + kx, y + ky]*weights[ky*5 + kx]), 0 <= kx, ky < 5;
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-bit 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-bit 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 a 2x2 transposed convolution contribution to dst.

For every source point:

dst[x + kx, y + ky] += src[x, y]*weights[ky*2 + kx], 0 <= kx, ky < 2;
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-bit 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-bit 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 a 3x3 transposed convolution contribution to dst.

For every source point:

dst[x + kx, y + ky] += src[x, y]*weights[ky*3 + kx], 0 <= kx, ky < 3;
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-bit 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-bit 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 a 4x4 transposed convolution contribution to dst.

For every source point:

dst[x + kx, y + ky] += src[x, y]*weights[ky*4 + kx], 0 <= kx, ky < 4;
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-bit 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-bit 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 a 5x5 transposed convolution contribution to dst.

For every source point:

dst[x + kx, y + ky] += src[x, y]*weights[ky*5 + kx], 0 <= kx, ky < 5;
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-bit 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-bit 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 2x2 convolution weight gradients into sums.

For every weight:

sums[ky*2 + kx] += Sum(src[x + kx, y + ky]*dst[x, y]);
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-bit float values).
[in]dst- a pointer to the output-gradient 32-bit float image.
[in]dstStride- a row size of the output-gradient image (in 32-bit float values).
[in]width- a width of the output-gradient image (input image width must be equal to width + 1).
[in]height- a height of the output-gradient image (input image height must be equal to height + 1).
[in,out]sums- a pointer to the array with accumulated weight gradients (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 3x3 convolution weight gradients into sums.

For every weight:

sums[ky*3 + kx] += Sum(src[x + kx, y + ky]*dst[x, y]);
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-bit float values).
[in]dst- a pointer to the output-gradient 32-bit float image.
[in]dstStride- a row size of the output-gradient image (in 32-bit float values).
[in]width- a width of the output-gradient image (input image width must be equal to width + 2).
[in]height- a height of the output-gradient image (input image height must be equal to height + 2).
[in,out]sums- a pointer to the array with accumulated weight gradients (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 4x4 convolution weight gradients into sums.

For every weight:

sums[ky*4 + kx] += Sum(src[x + kx, y + ky]*dst[x, y]);
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-bit float values).
[in]dst- a pointer to the output-gradient 32-bit float image.
[in]dstStride- a row size of the output-gradient image (in 32-bit float values).
[in]width- a width of the output-gradient image (input image width must be equal to width + 3).
[in]height- a height of the output-gradient image (input image height must be equal to height + 3).
[in,out]sums- a pointer to the array with accumulated weight gradients (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 5x5 convolution weight gradients into sums.

For every weight:

sums[ky*5 + kx] += Sum(src[x + kx, y + ky]*dst[x, y]);
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-bit float values).
[in]dst- a pointer to the output-gradient 32-bit float image.
[in]dstStride- a row size of the output-gradient image (in 32-bit float values).
[in]width- a width of the output-gradient image (input image width must be equal to width + 4).
[in]height- a height of the output-gradient image (input image height must be equal to height + 4).
[in,out]sums- a pointer to the array with accumulated weight gradients (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 
)

Performs stride-1 max pooling with a clipped 3x3 window.

The output image has the same width and height as the input image. For inner pixels the function uses a 3x3 window; at image borders it uses only valid input pixels.

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-bit float values).
[in]width- a width of the input and output images.
[in]height- a height of the input and output images.
[out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-bit float values).

◆ SimdNeuralPooling2x2Max2x2()

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

Performs stride-2 max pooling with a clipped 2x2 window.

The output image size is (width + 1)/2 by (height + 1)/2. Full 2x2 windows are used where available; the last row or column uses only valid input pixels when width or height is odd.

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-bit float values).
[in]width- a width of the input image.
[in]height- a height of the input image.
[out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-bit float values).

◆ SimdNeuralPooling2x2Max3x3()

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

Performs stride-2 max pooling with a clipped 3x3 window.

The output image size is width/2 by height/2. Full 3x3 windows are used where available; windows touching the last output row or column use only valid input pixels.

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-bit float values).
[in]width- a width of the input image.
[in]height- a height of the input image.
[out]dst- a pointer to the output 32-bit float image.
[in]dstStride- a row size of the output image (in 32-bit 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 
)

Performs forward convolution for NCHW-style 32-bit float tensors.

The source tensor is stored as srcDepth planes of size srcHeight*srcWidth. The destination tensor is stored as dstDepth planes of size dstHeight*dstWidth. The weight tensor is stored as dstDepth filters, each containing srcDepth*kernelY*kernelX values. Input samples outside the source image because of padding are treated as zero.

For every output channel od and output point (dx, dy):

if(!add)
    dst[od, dy, dx] = 0;
for(id = 0; id < srcDepth; ++id)
    for(ky = 0; ky < kernelY; ++ky)
        for(kx = 0; kx < kernelX; ++kx)
        {
            sx = dx*strideX + kx*dilationX - padX;
            sy = dy*strideY + ky*dilationY - padY;
            if(0 <= sx && sx < srcWidth && 0 <= sy && sy < srcHeight)
                dst[od, dy, dx] += src[id, sy, sx]*weight[od, id, ky, kx];
        }

The output dimensions must satisfy:

dstWidth = (srcWidth + 2*padX - (dilationX*(kernelX - 1) + 1))/strideX + 1;
dstHeight = (srcHeight + 2*padY - (dilationY*(kernelY - 1) + 1))/strideY + 1;

If buffer and size provide a large enough temporary buffer, it can be used by the algorithm; otherwise an internal buffer is allocated. When size is not NULL and the supplied buffer is too small, size[0] is updated with the required size in bytes.

Parameters
[in]src- a pointer to the input tensor. Total size is srcWidth*srcHeight*srcDepth.
[in]srcWidth- a width of the input tensor.
[in]srcHeight- a height of the input tensor.
[in]srcDepth- a number of channels in the input tensor.
[in]weight- a pointer to the convolution weights. Total size is 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 tensor.
[in]padY- a pad to the y-coordinate of the input tensor.
[in]strideX- a x-stride of the convolution.
[in]strideY- a y-stride of the convolution.
[in]dilationX- a x-dilation of the convolution.
[in]dilationY- a y-dilation of the convolution.
[in,out]buffer- a pointer to an optional external temporary buffer. Can be NULL.
[in,out]size- a pointer to the size of the external temporary buffer. Can be NULL.
[in,out]dst- a pointer to the output tensor. Total size is dstWidth*dstHeight*dstDepth.
[in]dstWidth- a width of the output tensor.
[in]dstHeight- a height of the output tensor.
[in]dstDepth- a number of channels in the output tensor.
[in]add- a flag: if non-zero, convolution is added to dst; otherwise dst is cleared before accumulation.

◆ 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.