![]() |
OpenVX Neural Network Extension
7505566
|
Convolutional Network Nodes. More...
Enumerations | |
enum | vx_convolutional_network_activation_func_e { VX_CONVOLUTIONAL_NETWORK_ACTIVATION_LOGISTIC = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x0, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_HYPERBOLIC_TAN = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x1, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_RELU = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x2, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_BRELU = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x3, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_SOFTRELU = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x4, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_ABS = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x5, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_SQUARE = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x6, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_SQRT = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x7, VX_CONVOLUTIONAL_NETWORK_ACTIVATION_LINEAR = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ACTIVATION_FUNC << 12)) + 0x8 } |
The Convolutional Network activation functions list. More... | |
enum | vx_convolutional_network_norm_type_e { VX_CONVOLUTIONAL_NETWORK_NORM_SAME_MAP = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_NORM_TYPE << 12)) + 0x0, VX_CONVOLUTIONAL_NETWORK_NORM_ACROSS_MAPS = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_NORM_TYPE << 12)) + 0x1 } |
The Convolutional Network normalization type list. More... | |
enum | vx_convolutional_network_pooling_type_e { VX_CONVOLUTIONAL_NETWORK_POOLING_MAX = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_POOL_TYPE << 12)) + 0x0, VX_CONVOLUTIONAL_NETWORK_POOLING_AVG = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_POOL_TYPE << 12)) + 0x1 } |
The Convolutional Network pooling type list. More... | |
enum | vx_convolutional_networks_rounding_type_e { VX_CONVOLUTIONAL_NETWORK_DS_SIZE_ROUNDING_FLOOR = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ROUNDING_TYPE << 12)) + 0x0, VX_CONVOLUTIONAL_NETWORK_DS_SIZE_ROUNDING_CEILING = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_CONVOLUTIONAL_NETWORK_ROUNDING_TYPE << 12)) + 0x1 } |
The Convolutional Network down scaling size rounding type list. More... | |
Functions | |
vx_node | vxActivationLayer (vx_graph graph, vx_tensor inputs, vx_enum func, vx_int32 a, vx_int32 b, vx_tensor outputs) |
[Graph] Creates a Convolutional Network Activation Layer Node. More... | |
vx_node | vxConvolutionLayer (vx_graph graph, vx_tensor inputs, vx_tensor weights, vx_tensor biases, vx_uint32 pad_x, vx_uint32 pad_y, vx_uint8 accumulator_bits, vx_enum overflow_policy, vx_enum rounding_policy, vx_enum down_scale_size_rounding, vx_tensor outputs) |
[Graph] Creates a Convolutional Network Convolution Layer Node. More... | |
vx_node | vxFullyConnectedLayer (vx_graph graph, vx_tensor inputs, vx_tensor weights, vx_tensor biases, vx_uint32 pad, vx_uint8 accumulator_bits, vx_enum overflow_policy, vx_enum rounding_policy, vx_enum down_scale_size_rounding, vx_tensor outputs) |
[Graph] Creates a Fully connected Convolutional Network Layer Node. More... | |
vx_node | vxNormalizationLayer (vx_graph graph, vx_tensor inputs, vx_enum type, vx_uint32 norm_size, vx_float32 alpha, vx_float32 beta, vx_tensor outputs) |
[Graph] Creates a Convolutional Network Normalization Layer Node. More... | |
vx_node | vxPoolingLayer (vx_graph graph, vx_tensor inputs, vx_enum pool_type, vx_uint32 pool_size_x, vx_uint32 pool_size_y, vx_uint32 pool_pad_x, vx_uint32 pool_pad_y, vx_enum rounding, vx_tensor outputs) |
[Graph] Creates a Convolutional Network Pooling Layer Node. More... | |
vx_node | vxSoftmaxLayer (vx_graph graph, vx_tensor inputs, vx_tensor outputs) |
[Graph] Creates a Convolutional Network Softmax Layer Node. More... | |
Convolutional Network Nodes.
The Convolutional Network activation functions list.
Function name | Mathematical definition | Parameters | Parameters type |
logistic | \(f(x)=1/(1+e^{-x}) \) | ||
hyperbolic tangent | \(f(x)=a\cdot tanh(b\cdot x) \) | a,b | VX_INT32 |
relu | \(f(x)=max(0,x)\) | ||
bounded relu | \(f(x)=min(a,max(0,x)) \) | a | VX_INT32 |
soft relu | \(f(x)=log(1+e^{x}) \) | ||
abs | \(f(x)=\mid x\mid \) | ||
square | \(f(x)= x^2 \) | ||
square root | \(f(x)=\sqrt{x} \) | ||
linear | \(f(x)=ax+b \) | a,b | VX_INT32 |
Definition at line 161 of file vx_khr_cnn.h.
The Convolutional Network normalization type list.
Enumerator | |
---|---|
VX_CONVOLUTIONAL_NETWORK_NORM_SAME_MAP |
normalization is done on same IFM |
VX_CONVOLUTIONAL_NETWORK_NORM_ACROSS_MAPS |
Normalization is done across different IFMs. |
Definition at line 135 of file vx_khr_cnn.h.
The Convolutional Network pooling type list.
kind of pooling done in pooling function
Enumerator | |
---|---|
VX_CONVOLUTIONAL_NETWORK_POOLING_MAX |
max pooling |
VX_CONVOLUTIONAL_NETWORK_POOLING_AVG |
average pooling |
Definition at line 123 of file vx_khr_cnn.h.
The Convolutional Network down scaling size rounding type list.
rounding done downscaling, In convolution and pooling functions. Relevant when input size is even.
Enumerator | |
---|---|
VX_CONVOLUTIONAL_NETWORK_DS_SIZE_ROUNDING_FLOOR |
floor rounding |
VX_CONVOLUTIONAL_NETWORK_DS_SIZE_ROUNDING_CEILING |
ceil rounding |
Definition at line 110 of file vx_khr_cnn.h.
vx_node vxActivationLayer | ( | vx_graph | graph, |
vx_tensor | inputs, | ||
vx_enum | func, | ||
vx_int32 | a, | ||
vx_int32 | b, | ||
vx_tensor | outputs | ||
) |
[Graph] Creates a Convolutional Network Activation Layer Node.
[in] | graph | The handle to the graph. |
[in] | inputs | The input tensor data. |
[in] | func | Non-linear function (see vx_convolutional_network_activation_func_e ). |
[in] | a | Function parameters a. (see vx_convolutional_network_activation_func_e ). |
[in] | b | Function parameters b. (see vx_convolutional_network_activation_func_e ). |
[out] | outputs | The output tensor data. Output will have the same number of dimensions as input. |
vx_node
. 0 | Node could not be created. |
* | Node handle. |
vx_node vxConvolutionLayer | ( | vx_graph | graph, |
vx_tensor | inputs, | ||
vx_tensor | weights, | ||
vx_tensor | biases, | ||
vx_uint32 | pad_x, | ||
vx_uint32 | pad_y, | ||
vx_uint8 | accumulator_bits, | ||
vx_enum | overflow_policy, | ||
vx_enum | rounding_policy, | ||
vx_enum | down_scale_size_rounding, | ||
vx_tensor | outputs | ||
) |
[Graph] Creates a Convolutional Network Convolution Layer Node.
This function implement Convolutional Network Convolution layer. In case the input and output vx_tensor
are signed 16. A fixed point calculation is performed with round and saturate according to the number of accumulator bits.
round: rounding according the vx_round_policy_e
enumeration.
saturate: A saturation according the vx_convert_policy_e
enumeration. The saturation is done based on the accumulator_bits parameter. According the accumulator_bits, the saturation might not be performed every operation. But every a specified amount of operations, that are suspected to saturate the accumulation bits
The following equation is implemented:
\( outputs[j,k,i] = (\sum_{l} \sum_{m,n} saturate(round(inputs[j-m,k-n,l] \times weights[m,n,l,i])))+biasses[j,k,i] \)
Where \(m,n\) are indexes on the convolution matrices. \( l\) is an index on all the convolutions per input. \( i\) is an index per output. \( j,k \) are the inputs/outputs spatial indexes. Convolution is done on the first 2 dimensions of the vx_tensor
. Therefore, we use here the term x for the first dimension and y for the second.
before the Convolution is done, a padding of the first 2D with zeros is performed. Then down scale is done by picking the results according to a skip jump. The skip in the x and y dimension is determined by the output size dimensions. The relation between input to output is as follows:
\( width_{output} = round(\frac{(width + 2 * pad_x - kernel_x)}{skip_x} + 1) \)
and
\( height_{output} = round(\frac{(height + 2 * pad_y - kernel_y)}{skip_y} + 1) \)
where \(width\) is the size of the first input dimension. \(height\) is the size of the second input dimension. \(width_{output}\) is the size of the first output dimension. \(height_{output}\) is the size of the second output dimension. \(kernel_x\) and \(kernel_y\) are the convolution sizes in x and y. skip is calculated by the relation between input and output. rounding is done according to vx_convolutional_network_rounding_type_e
.
[in] | graph | The handle to the graph. |
[in] | inputs | The input tensor data. 3 lower dims represent a single input, and an optional 4th dimension for batch of inputs. |
[in] | weights | Weights are 4d tensor with dimensions [kernel_x, kernel_y, #IFM, #OFM]. |
[in] | biases | The biases, which may be shared (one per ofm) or unshared (one per ofm * output location). |
[in] | pad_x | Number of elements added at each side in the x dimension of the input. |
[in] | pad_y | Number of elements added at each side in the y dimension of the input. In fully connected layers this input is ignored. |
[in] | accumulator_bits | Is the total number of bits used during intermediate accumulation. |
[in] | overflow_policy | A VX_TYPE_ENUM of the vx_convert_policy_e enumeration. |
[in] | rounding_policy | A VX_TYPE_ENUM of the vx_round_policy_e enumeration. |
[in] | down_scale_size_rounding | Rounding method for calculating output dimensions. See vx_convolutional_network_rounding_type_e |
[out] | outputs | The output tensor data. Output will have the same number of dimensions as input. |
vx_node
. 0 | Node could not be created. |
* | Node handle. |
vx_node vxFullyConnectedLayer | ( | vx_graph | graph, |
vx_tensor | inputs, | ||
vx_tensor | weights, | ||
vx_tensor | biases, | ||
vx_uint32 | pad, | ||
vx_uint8 | accumulator_bits, | ||
vx_enum | overflow_policy, | ||
vx_enum | rounding_policy, | ||
vx_enum | down_scale_size_rounding, | ||
vx_tensor | outputs | ||
) |
[Graph] Creates a Fully connected Convolutional Network Layer Node.
This function implement Fully connected Convolutional Network layers. In case the input and output vx_tensor
are signed 16. A fixed point calculation is performed with round and saturate according to the number of accumulator bits.
round: rounding according the vx_round_policy_e
enumeration.
saturate: A saturation according the vx_convert_policy_e
enumeration. The saturation is done based on the accumulator_bits parameter. According the accumulator_bits, the saturation might not be performed every operation. But every a specified amount of operations, that are suspected to saturate the accumulation bits
The equation for Fully connected layer:
\( outputs[i] = ( \sum_{j} saturate(round(inputs[j] \times weights[j,i])))+biasses[i] \)
Where \(j\) is a index on the input feature and \(i\) is a index on the output. before the fully connected is done, a padding of the input is performed. Then down scale is done by picking the results according to a skip jump. The skip is determined by the output size dimensions. The relation between input to output is as follows: \( size_{output} = round(\frac{(size_{input} + 2 * pad)}{skip} + 1) \)
where \(size_{input}\) is the size of the input dimension. \(size_{output}\) is the size of the output dimension. skip is calculated by the relation between input and output. rounding is done according to vx_convolutional_network_rounding_type_e
.
[in] | graph | The handle to the graph. |
[in] | inputs | The input tensor data. 1-3 lower dims represent a single input, and all dims above dim(weights)-1 are optional for batch of inputs. Note that batch may be multidimensional. |
[in] | weights | Number of dimensions equals dim(single input)+1. Single input dims are [width, height, #IFM], with height and #IFM being optional. |
[in] | biases | The biases, which may be shared (one per ofm) or unshared (one per ofm * output location). |
[in] | pad | Number of elements added at each side in the input. |
[in] | accumulator_bits | Is the total number of bits used during intermediate accumulation. |
[in] | overflow_policy | A VX_TYPE_ENUM of the vx_convert_policy_e enumeration. |
[in] | rounding_policy | A VX_TYPE_ENUM of the vx_round_policy_e enumeration. |
[in] | down_scale_size_rounding | Rounding method for calculating output dimensions. See vx_convolutional_network_rounding_type_e |
[out] | outputs | The output tensor data. Output will have the same number of dimensions as input. |
vx_node
. 0 | Node could not be created. |
* | Node handle. |
vx_node vxNormalizationLayer | ( | vx_graph | graph, |
vx_tensor | inputs, | ||
vx_enum | type, | ||
vx_uint32 | norm_size, | ||
vx_float32 | alpha, | ||
vx_float32 | beta, | ||
vx_tensor | outputs | ||
) |
[Graph] Creates a Convolutional Network Normalization Layer Node.
Normalizing over local input regions. Each input value is divided by \( (1+\frac{\alpha}{n}\sum_i x^2_i)^\beta \) , where n is the number of elements to normalize across. and the sum is taken over the region centred at that value (zero padding is added where necessary).
[in] | graph | The handle to the graph. |
[in] | inputs | The input tensor data. 3 lower dims represent a single input with dimensions [width, height, IFM], and an optional 4th dimension for batch of inputs. |
[in] | type | Either same map or across maps (see vx_convolutional_network_norm_type_e). |
[in] | norm_size | Number of elements to normalize across. |
[in] | alpha | Alpha parameter in the normalization equation. |
[in] | beta | Beta parameter in the normalization equation. |
[out] | outputs | The output tensor data. Output will have the same number of dimensions as input. |
vx_node
. 0 | Node could not be created. |
* | Node handle. |
vx_node vxPoolingLayer | ( | vx_graph | graph, |
vx_tensor | inputs, | ||
vx_enum | pool_type, | ||
vx_uint32 | pool_size_x, | ||
vx_uint32 | pool_size_y, | ||
vx_uint32 | pool_pad_x, | ||
vx_uint32 | pool_pad_y, | ||
vx_enum | rounding, | ||
vx_tensor | outputs | ||
) |
[Graph] Creates a Convolutional Network Pooling Layer Node.
Pooling is done on the first 2 dimensions or the vx_tensor
. Therefore, we use here the term x for the first dimension and y for the second.
Pooling operation is a function operation over a rectangle size and then a nearest neighbour down scale. Here we use pool_size_x and pool_size_y to specify the rectangle size on which the operation is performed.
before the operation is done (average or maximum value). the data is padded in the first 2D with zeros. The down scale is done by picking the results according to a skip jump. The skip in the x and y dimension is determined by the output size dimensions.
[in] | graph | The handle to the graph. |
[in] | inputs | The input tensor data. 3 lower dims represent a single input with dimensions [width, height, IFM], and an optional 4th dimension for batch of inputs. |
[in] | pool_type | Either max pooling or average pooling (see vx_convolutional_network_pooling_type_e ). |
[in] | pool_size_x | Size of the pooling region in the x dimension |
[in] | pool_size_y | Size of the pooling region in the y dimension. |
[in] | pool_pad_x | Padding size in the x dimension. |
[in] | pool_pad_y | Padding size in the y dimension. |
[in] | rounding,Rounding | method for calculating output dimensions. See vx_convolutional_network_rounding_type_e |
[out] | outputs | The output tensor data. Output will have the same number of dimensions as input. |
vx_node
. 0 | Node could not be created. |
* | Node handle. |
[Graph] Creates a Convolutional Network Softmax Layer Node.
[in] | graph | The handle to the graph. |
[in] | inputs | The input tensor data, with number of dimensions equals dim(input batch) + 1. Softmax will be calculated per IFM. |
[out] | outputs | The output tensor data. Output will have the same number of dimensions as input. |
vx_node
. 0 | Node could not be created. |
* | Node handle. |