main.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2020-2021 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. #include <freertos/FreeRTOS.h>
  15. #include <freertos/task.h>
  16. #include <esp_log.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <test_functions.h>
  21. #include <esp_timer.h>
  22. static const char *TAG = "test_app";
  23. static uint32_t start_c, start_opt, total_c, total_opt;
  24. void profile_c_start()
  25. {
  26. /* initiate profiling */
  27. start_c = esp_cpu_get_ccount();
  28. }
  29. void profile_c_end()
  30. {
  31. /* record profile number */
  32. total_c = esp_cpu_get_ccount() - start_c;
  33. }
  34. void profile_opt_start()
  35. {
  36. /* initiate profiling */
  37. start_opt = esp_cpu_get_ccount();
  38. }
  39. void profile_opt_end()
  40. {
  41. /* record profile number */
  42. total_opt = esp_cpu_get_ccount() - start_opt;
  43. }
  44. void app_main()
  45. {
  46. /* s8 tests */
  47. ESP_LOGI(TAG, "Running s8 tests...");
  48. esp_nn_add_elementwise_s8_test();
  49. printf("add, c %u opt %u\n", total_c, total_opt);
  50. esp_nn_mul_elementwise_s8_test();
  51. printf("mul, c %u opt %u\n", total_c, total_opt);
  52. esp_nn_depthwise_conv_s8_test();
  53. printf("depthwise, c %u opt %u\n", total_c, total_opt);
  54. esp_nn_conv_s8_test();
  55. printf("conv2d, c %u opt %u\n", total_c, total_opt);
  56. esp_nn_relu6_s8_test();
  57. printf("relu, c %u opt %u\n", total_c, total_opt);
  58. esp_nn_avg_pool_s8_test();
  59. printf("avg_pool, c %u opt %u\n", total_c, total_opt);
  60. esp_nn_max_pool_s8_test();
  61. printf("max_pool, c %u opt %u\n", total_c, total_opt);
  62. esp_nn_fully_connected_s8_test();
  63. printf("fully_connected, c %u opt %u\n", total_c, total_opt);
  64. esp_nn_softmax_s8_test();
  65. printf("softmax, c %u opt %u\n", total_c, total_opt);
  66. ESP_LOGI(TAG, "s8 tests done!\n");
  67. /* u8 tests */
  68. //ESP_LOGI(TAG, "Running u8 tests...");
  69. //esp_nn_add_elementwise_u8_test();
  70. //esp_nn_depthwise_conv_u8_test();
  71. //esp_nn_conv_u8_test();
  72. //esp_nn_avg_pool_u8_test();
  73. //esp_nn_max_pool_u8_test();
  74. //esp_nn_fully_connected_u8_test();
  75. //ESP_LOGI(TAG, "u8 tests done!\n");
  76. }