vx_khr_nn.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. /*
  2. * Copyright (c) 2012-2017 The Khronos Group Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _VX_KHR_NN_H_
  17. #define _VX_KHR_NN_H_
  18. /*!
  19. * \file
  20. * \brief The Khronos Extension for Deep Convolutional Networks Functions.
  21. *
  22. * \defgroup group_cnn Extension: Deep Convolutional Networks API
  23. * \brief Convolutional Network Nodes.
  24. */
  25. #define OPENVX_KHR_NN "vx_khr_nn"
  26. #include <vector>
  27. #include <VX/vx.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /*==============================================================================
  32. CONVOLUTIONAL_NETWORK structs and enums
  33. =============================================================================*/
  34. /*! \brief The Neural Network Extension Library Set
  35. * \ingroup group_cnn
  36. */
  37. #define VX_LIBRARY_KHR_NN_EXTENSION (0x1)
  38. /*! \brief The list of Neural Network Extension Kernels.
  39. * \ingroup group_cnn
  40. */
  41. enum vx_kernel_nn_ext_e {
  42. /*! \brief The Neural Network Extension convolution Kernel.
  43. * \see group_cnn
  44. */
  45. VX_KERNEL_CONVOLUTION_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x0,
  46. /*! \brief The Neural Network Extension fully connected Kernel.
  47. * \see group_cnn
  48. */
  49. VX_KERNEL_FULLY_CONNECTED_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x1,
  50. /*! \brief The Neural Network Extension pooling Kernel.
  51. * \see group_cnn
  52. */
  53. VX_KERNEL_POOLING_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x2,
  54. /*! \brief The Neural Network Extension softmax Kernel.
  55. * \see group_cnn
  56. */
  57. VX_KERNEL_SOFTMAX_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x3,
  58. /*! \brief The Neural Network Extension normalization Kernel.
  59. * \see group_cnn
  60. */
  61. VX_KERNEL_NORMALIZATION_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x4,
  62. /*! \brief The Neural Network Extension activation Kernel.
  63. * \see group_cnn
  64. */
  65. VX_KERNEL_ACTIVATION_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x5,
  66. /*! \brief The Neural Network POI Pooling Kernel.
  67. * \see group_cnn
  68. */
  69. VX_KERNEL_ROI_POOLING_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x6,
  70. /*! \brief The Neural Network Extension Deconvolution Kernel.
  71. * \see group_cnn
  72. */
  73. VX_KERNEL_DECONVOLUTION_LAYER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_NN_EXTENSION) + 0x7,
  74. };
  75. /*! \brief NN extension type enums.
  76. * \ingroup group_cnn
  77. */
  78. enum vx_nn_enum_e
  79. {
  80. VX_ENUM_NN_ROUNDING_TYPE = 0x1A,
  81. VX_ENUM_NN_POOLING_TYPE = 0x1B,
  82. VX_ENUM_NN_NORMALIZATION_TYPE = 0x1C,
  83. VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE = 0x1D,
  84. };
  85. /*! \brief down scale rounding.
  86. * \details Due to different scheme of downscale size calculation in the various training frameworks. Implementation must support 2 rounding methods for down scale calculation.
  87. * The floor and the ceiling. In convolution and pooling functions.
  88. * Relevant when input size is even.
  89. * \ingroup group_cnn
  90. */
  91. enum vx_nn_rounding_type_e
  92. {
  93. /*! \brief floor rounding */
  94. VX_NN_DS_SIZE_ROUNDING_FLOOR = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ROUNDING_TYPE) + 0x0,
  95. /*! \brief ceil rounding */
  96. VX_NN_DS_SIZE_ROUNDING_CEILING = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ROUNDING_TYPE) + 0x1
  97. };
  98. /*! \brief The Neural Network pooling type list.
  99. * \details kind of pooling done in pooling function
  100. * \ingroup group_cnn
  101. */
  102. enum vx_nn_pooling_type_e
  103. {
  104. /*! \brief max pooling*/
  105. VX_NN_POOLING_MAX = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_POOLING_TYPE) + 0x0,
  106. /*! \brief average pooling*/
  107. VX_NN_POOLING_AVG = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_POOLING_TYPE) + 0x1
  108. };
  109. /*! \brief The Neural Network normalization type list.
  110. * \ingroup group_cnn
  111. */
  112. enum vx_nn_norm_type_e
  113. {
  114. /*! \brief normalization is done on same IFM*/
  115. VX_NN_NORMALIZATION_SAME_MAP = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_NORMALIZATION_TYPE) + 0x0,
  116. /*! \brief Normalization is done across different IFMs*/
  117. VX_NN_NORMALIZATION_ACROSS_MAPS = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_NORMALIZATION_TYPE) + 0x1,
  118. };
  119. /*! \brief The Neural Network activation functions list.
  120. * \details
  121. * <table>
  122. * <tr><td> <B>Function name </B> <td> <B>Mathematical definition</B> <td> <B>Parameters</B> <td> <B>Parameters type</B>
  123. * <tr><td>logistic <td> \f$f(x)=1/(1+e^{-x}) \f$ <td> <td>
  124. * <tr><td>hyperbolic tangent <td> \f$f(x)=a\cdot tanh(b\cdot x) \f$ <td> a,b <td> VX_FLOAT32
  125. * <tr><td>relu <td> \f$f(x)=max(0,x)\f$ <td> <td>
  126. * <tr><td>bounded relu <td> \f$f(x)=min(a,max(0,x)) \f$ <td> a <td> VX_FLOAT32
  127. * <tr><td>soft relu <td> \f$f(x)=log(1+e^{x}) \f$ <td> <td>
  128. * <tr><td>abs <td> \f$f(x)=\mid x\mid \f$ <td> <td>
  129. * <tr><td>square <td> \f$f(x)= x^2 \f$ <td> <td>
  130. * <tr><td>square root <td> \f$f(x)=\sqrt{x} \f$ <td> <td>
  131. * <tr><td>linear <td> \f$f(x)=ax+b \f$ <td> a,b <td> VX_FLOAT32
  132. * </table>
  133. * \ingroup group_cnn
  134. */
  135. enum vx_nn_activation_function_e
  136. {
  137. VX_NN_ACTIVATION_LOGISTIC = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x0,
  138. VX_NN_ACTIVATION_HYPERBOLIC_TAN = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x1,
  139. VX_NN_ACTIVATION_RELU = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x2,
  140. VX_NN_ACTIVATION_BRELU = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x3,
  141. VX_NN_ACTIVATION_SOFTRELU = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x4,
  142. VX_NN_ACTIVATION_ABS = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x5,
  143. VX_NN_ACTIVATION_SQUARE = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x6,
  144. VX_NN_ACTIVATION_SQRT = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x7,
  145. VX_NN_ACTIVATION_LINEAR = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x8,
  146. VX_NN_ACTIVATION_PRELU = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0x9,
  147. VX_NN_ACTIVATION_RELU6 = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0xA,
  148. VX_NN_ACTIVATION_HARDSIGMOID = VX_ENUM_BASE(VX_ID_KHRONOS, VX_ENUM_NN_ACTIVATION_FUNCTION_TYPE) + 0xB,
  149. };
  150. /*! \brief The type enumeration lists all NN extension types.
  151. * \ingroup group_cnn
  152. */
  153. enum vx_nn_type_e {
  154. VX_TYPE_NN_CONVOLUTION_PARAMS = 0x025,/*!< \brief A <tt>\ref vx_nn_convolution_params_t</tt>. */
  155. VX_TYPE_NN_DECONVOLUTION_PARAMS = 0x026,/*!< \brief A <tt>\ref vx_nn_deconvolution_params_t</tt>. */
  156. VX_TYPE_NN_ROI_POOL_PARAMS = 0x027,/*!< \brief A <tt>\ref vx_nn_roi_pool_params_t</tt>. */
  157. VX_TYPE_NN_POOL_PARAMS = 0x028,
  158. VX_TYPE_NN_PERMUTE_PARAMS = 0x02D,
  159. VX_TYPE_NN_TENSOR_PYRAMID = 0x02E,
  160. VX_TYPE_NN_CUSTOM_PARAMS = 0x02F,
  161. };
  162. /*! \brief Input parameters for a convolution operation.
  163. * \ingroup group_cnn
  164. */
  165. typedef struct _vx_nn_convolution_params_t
  166. {
  167. vx_size padding_xl; /*!< \brief Number of elements added at each side in the x dimension of the input. */
  168. vx_size padding_xr;
  169. vx_size padding_yl; /*!< \brief Number of elements added at each side in the y dimension of the input. */
  170. vx_size padding_yr;
  171. vx_enum overflow_policy; /*!< \brief A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_convert_policy_e</tt> enumeration. */
  172. vx_enum rounding_policy; /*!< \brief A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_round_policy_e</tt> enumeration. */
  173. vx_enum down_scale_size_rounding; /*!< \brief Rounding method for calculating output dimensions. See <tt>\ref vx_nn_rounding_type_e</tt> */
  174. vx_size dilation_x; /*!< \brief “inflate” the kernel by inserting zeros between the kernel elements in the x direction. The value is the number of zeros to insert.*/
  175. vx_size dilation_y; /*!< \brief “inflate” the kernel by inserting zeros between the kernel elements in the y direction. The value is the number of zeros to insert.*/
  176. vx_size input_channel;
  177. vx_size input_channel_offset;
  178. vx_size input_channel_width;
  179. vx_size output_channel;
  180. vx_size output_channel_offset;
  181. vx_size output_channel_width;
  182. vx_size group;
  183. vx_size executor;
  184. } vx_nn_convolution_params_t;
  185. typedef struct _vx_nn_custom_params_t
  186. {
  187. vx_size num;
  188. vx_float32 params[16];
  189. }vx_nn_custom_params_t;
  190. typedef struct _vx_nn_pooling_params_t
  191. {
  192. vx_enum pooling_type;
  193. vx_size pooling_size_x;
  194. vx_size pooling_size_y;
  195. vx_size pooling_padding_x;
  196. vx_size pooling_padding_y;
  197. vx_enum rounding_policy;
  198. } vx_nn_pooling_params_t;
  199. typedef struct _vx_tensor_array_t
  200. {
  201. vx_size num;
  202. vx_tensor tensors[256];
  203. }vx_tensor_array_t;
  204. typedef struct _vx_nn_permute_params_t
  205. {
  206. vx_size axis_order0;
  207. vx_size axis_order1;
  208. vx_size axis_order2;
  209. vx_size axis_order3;
  210. }vx_nn_permute_params_t;
  211. /*==============================================================================
  212. NN Nodes
  213. =============================================================================*/
  214. /*! \brief [Graph] Creates a Convolutional Network Convolution Layer Node.
  215. * \details This function implement Convolutional Network Convolution layer.
  216. * For fixed-point data types, a fixed point calculation is performed with round and saturate according to the number of accumulator bits. The number of the accumulator bits are implementation defined,
  217. * and should be at least 16.\n
  218. * round: rounding according the <tt>vx_round_policy_e</tt> enumeration. \n
  219. * saturate: A saturation according the <tt>vx_convert_policy_e</tt> enumeration.
  220. * The following equation is implemented: \n
  221. * \f$ outputs[j,k,i] = saturate(round(\sum_{l} (\sum_{m,n} inputs[j+m,k+n,l] \times weights[m,n,l,i])+biasses[j,k,i])) \f$\n
  222. * Where \f$m,n\f$ are indexes on the convolution matrices. \f$ l\f$ is an index on all the convolutions per input.\f$ i\f$ is an index per output.
  223. * \f$ j,k \f$ are the inputs/outputs spatial indexes.
  224. * Convolution is done on the width and height dimensions of the <tt>\ref vx_tensor</tt>. Therefore, we use here the term x for index along the width dimension and y for index along the height dimension.\n
  225. * before the Convolution is done, a padding with zeros of the width and height input dimensions is performed.
  226. * Then down scale is done by picking the results according to a skip jump. The skip in the x and y is determined by the output size dimensions.
  227. * The relation between input to output is as follows: \n
  228. * \f$ width_{output} = round(\frac{(width_{input} + 2 * padding_x - kernel_x - (kernel_x -1) * dilation_x)}{skip_x} + 1) \f$\n
  229. * and \n
  230. * \f$ height_{output} = round(\frac{(height + 2 * padding_y - kernel_y - (kernel_y -1) * dilation_y)}{skip_y} + 1) \f$\n
  231. * where \f$width\f$ is the size of the input width dimension. \f$height\f$ is the size of the input height dimension.
  232. * \f$width_{output}\f$ is the size of the output width dimension. \f$height_{output}\f$ is the size of the output height dimension.
  233. * \f$kernel_x\f$ and \f$kernel_y\f$ are the convolution sizes in width and height dimensions.
  234. * skip is calculated by the relation between input and output. In case of ambiguity in the inverse calculation of the skip. The minimum solution is chosen. Skip must be a positive non zero integer.
  235. * rounding is done according to <tt>\ref vx_nn_rounding_type_e</tt>.
  236. * Notice that this node creation function has more parameters than the corresponding kernel. Numbering of kernel parameters (required if you create this node using the generic interface) is explicitly specified here.
  237. * \param [in] graph The handle to the graph.
  238. * \param [in] inputs The input tensor data. 3 lower dimensions represent a single input, all following dimensions represent number of batches, possibly nested.
  239. * The dimension order is [width, height, #IFM, #batches]\n. Implementations must support input tensor data types indicated by the extension strings 'KHR_NN_8' or 'KHR_NN_8 KHR_NN_16'. (Kernel parameter #0)
  240. * \param [in] weights [static] Weights are 4d tensor with dimensions [kernel_x, kernel_y, #IFM, #OFM]. see <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt> \n Weights data type must match the data type of the inputs. (Kernel parameter #1)
  241. * \param [in] biases [static] Optional, ignored if NULL. The biases, which may be shared (one per ofm) or unshared (one per ofm * output location). The possible layouts are
  242. * either [#OFM] or [width, height, #OFM]. Biases data type must match the data type of the inputs. (Kernel parameter #2)
  243. * \param [in] convolution_params [static] Pointer to parameters of type <tt>\ref vx_nn_convolution_params_t</tt>. (Kernel parameter #3)
  244. * \param [in] size_of_convolution_params [static] Size in bytes of convolution_params. Note that this parameter is not counted as one of the kernel parameters.
  245. * \param [out] outputs The output tensor data. Output will have the same number and structure of dimensions as input. Output tensor data type must be same as the inputs. (Kernel parameter #4)
  246. * \return <tt> vx_node</tt>.
  247. * \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
  248. * successful creation should be checked using <tt>\ref vxGetStatus</tt>.
  249. * \ingroup group_cnn
  250. */
  251. VX_API_ENTRY vx_node VX_API_CALL vxConvolutionLayer(vx_graph graph,
  252. const vx_char* name,
  253. vx_size name_len,
  254. vx_tensor inputs,
  255. vx_tensor weights,
  256. vx_tensor biases,
  257. const vx_nn_convolution_params_t* convolution_params,
  258. vx_size size_of_convolution_params,
  259. vx_tensor outputs);
  260. /*! \brief [Graph] Creates a Fully connected Convolutional Network Layer Node.
  261. * \details This function implement Fully connected Convolutional Network layers.
  262. * For fixed-point data types, a fixed point calculation is performed with round and saturate according to the number of accumulator bits. The number of the accumulator bits are implementation defined,
  263. * and should be at least 16.\n
  264. * round: rounding according the <tt>vx_round_policy_e</tt> enumeration. \n
  265. * saturate: A saturation according the <tt>vx_convert_policy_e</tt> enumeration.
  266. * The equation for Fully connected layer:\n
  267. * \f$ outputs[i] = saturate(round(\sum_{j} (inputs[j] \times weights[j,i])+biasses[i])) \f$\n
  268. * Where \f$j\f$ is a index on the input feature and \f$i\f$ is a index on the output.
  269. * \param [in] graph The handle to the graph.
  270. * \param [in] inputs The input tensor data. There two possible input layouts:
  271. * 1. [#IFM, #batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>.
  272. * 2. [width, height, #IFM, #batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>\n
  273. * In both cases number of batches are optional and may be multidimensional.
  274. * The second option is a special case to deal with convolution layer followed by fully connected.
  275. * The dimension order is [#IFM, #batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>. Note that batch may be multidimensional. Implementations must support input tensor data types indicated by the extension strings 'KHR_NN_8' or 'KHR_NN_8 KHR_NN_16'.
  276. * \param [in] weights [static] Number of dimensions is 2. Dimensions are [#IFM, #OFM]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>.\n Implementations must support input tensor data type same as the inputs.
  277. * \param [in] biases [static] Optional, ignored if NULL. The biases have one dimension [#OFM]. Implementations must support input tensor data type same as the inputs.
  278. * \param [in] overflow_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_convert_policy_e</tt> enumeration.
  279. * \param [in] rounding_policy [static] A <tt> VX_TYPE_ENUM</tt> of the <tt> vx_round_policy_e</tt> enumeration.
  280. * \param [out] outputs The output tensor data. Output dimension layout is [#OFM,#batches]. See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>, where #batches may be multidimensional. Output tensor data type must be same as the inputs.
  281. * \return <tt> vx_node</tt>.
  282. * \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
  283. * successful creation should be checked using <tt>\ref vxGetStatus</tt>.
  284. * \ingroup group_cnn
  285. */
  286. VX_API_ENTRY vx_node VX_API_CALL vxFullyConnectedLayer(vx_graph graph, const vx_char* name, vx_size name_len, vx_tensor inputs, vx_tensor weights, vx_tensor biases, vx_enum overflow_policy, vx_enum rounding_policy, vx_tensor outputs);
  287. /*! \brief [Graph] Creates a Convolutional Network Pooling Layer Node.
  288. * \details Pooling is done on the width and height dimensions of the <tt>\ref vx_tensor</tt>. Therefore, we use here the term x for the width dimension and y for the height dimension.\n
  289. * Pooling operation is a function operation over a rectangle size and then a nearest neighbour down scale.
  290. * Here we use pooling_size_x and pooling_size_y to specify the rectangle size on which the operation
  291. * is performed. \n
  292. * before the operation is done (average or maximum value). the data is padded with zeros in width and height dimensions .
  293. * 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.
  294. * The first pixel of the down scale output is the first pixel in the input.
  295. * \param [in] graph The handle to the graph.
  296. * \param [in] inputs The input tensor data. 3 lower dimensions represent a single input, 4th dimension for batch of inputs is optional.Dimension layout is [width, height, #IFM, #batches].
  297. * See <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>
  298. * Implementations must support input tensor data types indicated by the extension strings 'KHR_NN_8' or 'KHR_NN_8 KHR_NN_16'.
  299. * \param [in] pooling_type [static] Either max pooling or average pooling (see <tt>\ref vx_nn_pooling_type_e</tt>).
  300. * \param [in] pooling_size_x [static] Size of the pooling region in the x dimension
  301. * \param [in] pooling_size_y [static] Size of the pooling region in the y dimension.
  302. * \param [in] pooling_padding_x [static] Padding size in the x dimension.
  303. * \param [in] pooling_padding_y [static] Padding size in the y dimension.
  304. * \param [in] rounding [static] Rounding method for calculating output dimensions. See <tt>\ref vx_nn_rounding_type_e</tt>
  305. * \param [out] outputs The output tensor data. Output will have the same number of dimensions as input. Output tensor data type must be same as the inputs.
  306. * \return <tt> vx_node</tt>.
  307. * \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
  308. * successful creation should be checked using <tt>\ref vxGetStatus</tt>.
  309. * \ingroup group_cnn
  310. */
  311. VX_API_ENTRY vx_node VX_API_CALL vxPoolingLayer(
  312. vx_graph graph,
  313. const vx_char* name,
  314. vx_size name_len,
  315. vx_tensor inputs,
  316. const vx_nn_pooling_params_t* pooling_params,
  317. vx_size size_of_pooling_params,
  318. vx_tensor outputs);
  319. /*! \brief [Graph] Creates a Convolutional Network Softmax Layer Node.
  320. * \details the softmax function, is a generalization of the logistic function that "squashes" a K-dimensional vector \f$ z \f$ of arbitrary real values to a K-dimensional vector
  321. * \f$ \sigma(z) \f$ of real values in the range (0, 1) that add up to 1. The function is given by:
  322. * \f$ \sigma(z) = \frac{\exp^z}{\sum_i \exp^{z_i}} \f$
  323. * \param [in] graph The handle to the graph.
  324. * \param [in] inputs The input tensor, with the number of dimensions according to the following scheme.
  325. * In case IFM dimension is 1. Softmax is be calculated on that dimension.
  326. * In case IFM dimension is 2. Softmax is be calculated on the first dimension. The second dimension is batching.
  327. * In case IFM dimension is 3. Dimensions are [Width, Height, Classes]. And Softmax is calculated on the third dimension.
  328. * In case IFM dimension is 4. Dimensions are [Width, Height, Classes, batching]. Softmax is calculated on the third dimension.
  329. * Regarding the layout specification, see <tt>\ref vxCreateTensor</tt> and <tt>\ref vxCreateVirtualTensor</tt>.
  330. * In all cases Implementations must support input tensor data types indicated by the extension strings 'KHR_NN_8' or 'KHR_NN_8 KHR_NN_16'.
  331. * \param [out] outputs The output tensor. Output will have the same number of dimensions as input. Output tensor data type must be same as the inputs.
  332. * \ingroup group_cnn
  333. * \return <tt> vx_node</tt>.
  334. * \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
  335. * successful creation should be checked using <tt>\ref vxGetStatus</tt>.
  336. */
  337. VX_API_ENTRY vx_node VX_API_CALL vxSoftmaxLayer(vx_graph graph, vx_tensor inputs, vx_tensor outputs);
  338. /*! \brief [Graph] Creates a Convolutional Network Activation Layer Node.
  339. * The function operate a specific function (Specified in <tt>\ref vx_nn_activation_function_e</tt>), On the input data.
  340. * the equation for the layer is:
  341. * \f$ outputs(i,j,k,l) = function(inputs(i,j,k,l), a, b) \f$ for all i,j,k,l.
  342. * \param [in] graph The handle to the graph.
  343. * \param [in] inputs The input tensor data.
  344. * Implementations must support input tensor data types indicated by the extension strings 'KHR_NN_8' or 'KHR_NN_8 KHR_NN_16'.
  345. * \param [in] function [static] Non-linear function (see <tt>\ref vx_nn_activation_function_e</tt>). Implementations must support <tt>\ref VX_NN_ACTIVATION_LOGISTIC</tt>, <tt>\ref VX_NN_ACTIVATION_HYPERBOLIC_TAN</tt> and <tt>\ref VX_NN_ACTIVATION_RELU</tt>
  346. * \param [in] a [static] Function parameters a. must be positive.
  347. * \param [in] b [static] Function parameters b. must be positive.
  348. * \param [out] outputs The output tensor data. Output will have the same number of dimensions as input.
  349. * \ingroup group_cnn
  350. * \return <tt> vx_node</tt>.
  351. * \returns A node reference <tt>\ref vx_node</tt>. Any possible errors preventing a
  352. * successful creation should be checked using <tt>\ref vxGetStatus</tt>.
  353. */
  354. VX_API_ENTRY vx_node VX_API_CALL vxActivationLayer(vx_graph graph, const vx_char* name, vx_size name_len, vx_tensor inputs, vx_enum function, vx_tensor weights, vx_tensor outputs);
  355. #ifdef __cplusplus
  356. }
  357. #endif
  358. #endif