esp_nn_defs.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2022 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <stdint.h>
  16. /**
  17. * @brief structure to club data dims
  18. * this structure can be used for input, output and filter
  19. */
  20. typedef struct data_dims {
  21. int32_t width;
  22. int32_t height;
  23. int32_t channels;
  24. int32_t extra; // can be used as batch or any other param
  25. } data_dims_t;
  26. /**
  27. * @brief 2d data structure (width, height)
  28. *
  29. */
  30. typedef struct data_2d {
  31. int32_t width;
  32. int32_t height;
  33. } data_2d_t;
  34. /**
  35. * @brief min/max activation
  36. */
  37. typedef struct act_params {
  38. int32_t min;
  39. int32_t max;
  40. } act_params_t;
  41. /**
  42. * @brief per channel quant data
  43. *
  44. * @note number of shift and mult elements are equal to output channels
  45. */
  46. typedef struct quant_data {
  47. int32_t *shift;
  48. int32_t *mult;
  49. } quant_data_t;
  50. /**
  51. * @brief params specific to convolution 2d
  52. *
  53. */
  54. typedef struct conv_params {
  55. int32_t in_offset;
  56. int32_t out_offset;
  57. data_2d_t stride;
  58. data_2d_t padding;
  59. data_2d_t dilation;
  60. act_params_t activation;
  61. } conv_params_t;
  62. /**
  63. * @brief params specific to depthwise convolution 2d
  64. *
  65. */
  66. typedef struct dw_conv_params {
  67. int32_t in_offset;
  68. int32_t out_offset;
  69. int32_t ch_mult; // channel multiplier. (in_ch * ch_mult = out_ch)
  70. data_2d_t stride;
  71. data_2d_t padding;
  72. data_2d_t dilation;
  73. act_params_t activation;
  74. } dw_conv_params_t;