Răsfoiți Sursa

CMSIS-NN: Add unit test support depthwise conv

- Add support for depthwise convolution in generate test data script.
- Add 3 unit tests targetting depthwise convolution.
- Improve unit test summary and fail more gracefully in case of invalid
  test cases.
Måns Nilsson 5 ani în urmă
părinte
comite
40fb3cedcd
44 a modificat fișierele cu 2042 adăugiri și 55 ștergeri
  1. 2 0
      Tests/UnitTest/PregeneratedData/depthwise_2/bias.txt
  2. 31 0
      Tests/UnitTest/PregeneratedData/depthwise_2/input.txt
  3. 37 0
      Tests/UnitTest/PregeneratedData/depthwise_2/kernel.txt
  4. 12 0
      Tests/UnitTest/PregeneratedData/depthwise_2/params.txt
  5. 2 0
      Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/bias.txt
  6. 21 0
      Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/input.txt
  7. 37 0
      Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/kernel.txt
  8. 12 0
      Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/params.txt
  9. 2 0
      Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/bias.txt
  10. 21 0
      Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/input.txt
  11. 46 0
      Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/kernel.txt
  12. 12 0
      Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/params.txt
  13. 35 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/biases_data.h
  14. 41 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/config_data.h
  15. 116 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/input_data.h
  16. 35 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/output_mult_data.h
  17. 107 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/output_ref_data.h
  18. 35 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/output_shift_data.h
  19. 27 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/test_data.h
  20. 134 0
      Tests/UnitTest/TestCases/TestData/depthwise_2/weights_data.h
  21. 32 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/biases_data.h
  22. 41 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/config_data.h
  23. 146 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/input_data.h
  24. 32 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/output_mult_data.h
  25. 146 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/output_ref_data.h
  26. 32 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/output_shift_data.h
  27. 27 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/test_data.h
  28. 62 0
      Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/weights_data.h
  29. 31 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/biases_data.h
  30. 41 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/config_data.h
  31. 126 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/input_data.h
  32. 31 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/output_mult_data.h
  33. 56 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/output_ref_data.h
  34. 31 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/output_shift_data.h
  35. 27 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/test_data.h
  36. 71 0
      Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/weights_data.h
  37. 47 0
      Tests/UnitTest/TestCases/test_arm_depthwise_conv_3x3_s8/Unity/unity_test_arm_depthwise_conv_3x3_s8.c
  38. 60 0
      Tests/UnitTest/TestCases/test_arm_depthwise_conv_3x3_s8/test_arm_depthwise_conv_3x3_s8.c
  39. 5 0
      Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8/Unity/unity_test_arm_depthwwise_conv_s8.c
  40. 37 0
      Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8/test_arm_depthwise_conv_s8.c
  41. 5 0
      Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8_opt/Unity/unity_test_arm_depthwise_conv_s8_opt.c
  42. 45 6
      Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8_opt/test_arm_depthwise_conv_s8_opt.c
  43. 109 26
      Tests/UnitTest/generate_test_data.py
  44. 37 23
      Tests/UnitTest/unittest_targets.py

+ 2 - 0
Tests/UnitTest/PregeneratedData/depthwise_2/bias.txt

@@ -0,0 +1,2 @@
+# 9
+-1.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00

+ 31 - 0
Tests/UnitTest/PregeneratedData/depthwise_2/input.txt

@@ -0,0 +1,31 @@
+# 1,5,6,3
+-1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+1.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00
+0.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+1.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+-1.000000000000000000e+00,1.000000000000000000e+00,0.000000000000000000e+00
+-2.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+0.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+0.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00
+1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00
+1.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00
+1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
+1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00
+0.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00

+ 37 - 0
Tests/UnitTest/PregeneratedData/depthwise_2/kernel.txt

@@ -0,0 +1,37 @@
+# 4,3,3,3
+0.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+0.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00
+-1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+1.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00
+0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
+-2.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00
+1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+0.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00
+0.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+-2.000000000000000000e+00,1.000000000000000000e+00,0.000000000000000000e+00

+ 12 - 0
Tests/UnitTest/PregeneratedData/depthwise_2/params.txt

@@ -0,0 +1,12 @@
+3
+9
+6
+5
+3
+4
+2
+2
+0
+1
+1
+1

+ 2 - 0
Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/bias.txt

@@ -0,0 +1,2 @@
+# 6
+-2.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00

+ 21 - 0
Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/input.txt

@@ -0,0 +1,21 @@
+# 1,5,4,6
+-2.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
+1.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00
+-2.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00
+1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
+1.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+-1.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00
+0.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00

+ 37 - 0
Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/kernel.txt

@@ -0,0 +1,37 @@
+# 3,2,6,1
+-1.000000000000000000e+00
+0.000000000000000000e+00
+1.000000000000000000e+00
+-2.000000000000000000e+00
+-2.000000000000000000e+00
+1.000000000000000000e+00
+1.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00
+-2.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+0.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+0.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+-1.000000000000000000e+00
+-2.000000000000000000e+00
+1.000000000000000000e+00
+-2.000000000000000000e+00
+-1.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00
+-1.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00
+-1.000000000000000000e+00
+0.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+1.000000000000000000e+00
+-1.000000000000000000e+00

+ 12 - 0
Tests/UnitTest/PregeneratedData/depthwise_eq_in_out_ch/params.txt

@@ -0,0 +1,12 @@
+6
+6
+4
+5
+2
+3
+1
+1
+0
+1
+1
+1

+ 2 - 0
Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/bias.txt

@@ -0,0 +1,2 @@
+# 5
+-1.000000000000000000e+00,0.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00

+ 21 - 0
Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/input.txt

@@ -0,0 +1,21 @@
+# 1,5,4,5
+1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00
+-1.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00,0.000000000000000000e+00
+0.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00
+-2.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00
+0.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,-1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00
+-1.000000000000000000e+00,0.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00
+1.000000000000000000e+00,-2.000000000000000000e+00,-2.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00
+1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00
+1.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00
+-2.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,-1.000000000000000000e+00,0.000000000000000000e+00
+0.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,-2.000000000000000000e+00,1.000000000000000000e+00

+ 46 - 0
Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/kernel.txt

@@ -0,0 +1,46 @@
+# 3,3,5,1
+-1.000000000000000000e+00
+-2.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+0.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+-2.000000000000000000e+00
+-1.000000000000000000e+00
+0.000000000000000000e+00
+-1.000000000000000000e+00
+-2.000000000000000000e+00
+-1.000000000000000000e+00
+-2.000000000000000000e+00
+-2.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+-2.000000000000000000e+00
+0.000000000000000000e+00
+0.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00
+-2.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+-2.000000000000000000e+00
+-2.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+0.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00
+-2.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00
+0.000000000000000000e+00
+-1.000000000000000000e+00
+0.000000000000000000e+00
+-1.000000000000000000e+00
+1.000000000000000000e+00

+ 12 - 0
Tests/UnitTest/PregeneratedData/depthwise_kernel_3x3/params.txt

@@ -0,0 +1,12 @@
+5
+5
+4
+5
+3
+3
+2
+2
+0
+1
+1
+1

+ 35 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/biases_data.h

@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_2_biases[9] =
+{
+  -2699,
+  0,
+  0,
+  -2699,
+  0,
+  2699,
+  0,
+  2699,
+  2699
+};

+ 41 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/config_data.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#define DEPTHWISE_2_OUT_CH 9
+#define DEPTHWISE_2_IN_CH 3
+#define DEPTHWISE_2_CH_MULT 3  // (Only for depthwise conv)
+#define DEPTHWISE_2_INPUT_W 6
+#define DEPTHWISE_2_INPUT_H 5
+#define DEPTHWISE_2_FILTER_X 3
+#define DEPTHWISE_2_FILTER_Y 4
+#define DEPTHWISE_2_STRIDE_X 2
+#define DEPTHWISE_2_STRIDE_Y 2
+#define DEPTHWISE_2_PAD_X 0
+#define DEPTHWISE_2_PAD_Y 1
+#define DEPTHWISE_2_OUTPUT_W 3
+#define DEPTHWISE_2_OUTPUT_H 3
+#define DEPTHWISE_2_DST_SIZE 81
+#define DEPTHWISE_2_INPUT_SIZE 90
+#define DEPTHWISE_2_INPUT_OFFSET 0
+#define DEPTHWISE_2_OUTPUT_OFFSET -1
+#define DEPTHWISE_2_OUT_ACTIVATION_MIN -128
+#define DEPTHWISE_2_OUT_ACTIVATION_MAX 127
+#define DEPTHWISE_2_INPUT_BATCHES 1

+ 116 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/input_data.h

@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_2_input[90] =
+{
+  -42,
+  -85,
+  42,
+  42,
+  42,
+  -42,
+  -85,
+  -85,
+  0,
+  0,
+  42,
+  42,
+  -85,
+  0,
+  42,
+  42,
+  -85,
+  -42,
+  42,
+  -42,
+  -85,
+  42,
+  -42,
+  0,
+  -85,
+  -42,
+  -42,
+  0,
+  -85,
+  42,
+  -85,
+  0,
+  -42,
+  -42,
+  42,
+  -85,
+  -42,
+  -85,
+  42,
+  -42,
+  42,
+  0,
+  -85,
+  0,
+  -85,
+  0,
+  0,
+  -42,
+  0,
+  -42,
+  -42,
+  -42,
+  -85,
+  -42,
+  -85,
+  -42,
+  42,
+  -85,
+  -42,
+  42,
+  42,
+  0,
+  -85,
+  0,
+  -85,
+  -42,
+  42,
+  42,
+  42,
+  42,
+  42,
+  -42,
+  42,
+  0,
+  -85,
+  -42,
+  0,
+  0,
+  42,
+  -85,
+  -85,
+  0,
+  0,
+  42,
+  0,
+  -85,
+  42,
+  0,
+  -85,
+  -42
+};

+ 35 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/output_mult_data.h

@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_2_output_mult[9] =
+{
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280
+};

+ 107 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/output_ref_data.h

@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_2_output_ref[81] =
+{
+  -3,
+  -1,
+  4,
+  2,
+  9,
+  2,
+  3,
+  -6,
+  8,
+  4,
+  7,
+  7,
+  3,
+  7,
+  10,
+  10,
+  -1,
+  -2,
+  -3,
+  4,
+  3,
+  1,
+  -3,
+  -3,
+  1,
+  -1,
+  -1,
+  -2,
+  2,
+  5,
+  5,
+  8,
+  12,
+  12,
+  0,
+  8,
+  -9,
+  -11,
+  7,
+  -5,
+  5,
+  6,
+  2,
+  6,
+  7,
+  -3,
+  -7,
+  3,
+  3,
+  -6,
+  -5,
+  3,
+  5,
+  4,
+  0,
+  -1,
+  2,
+  -1,
+  6,
+  -1,
+  2,
+  11,
+  3,
+  -1,
+  1,
+  -5,
+  0,
+  12,
+  1,
+  3,
+  2,
+  3,
+  -1,
+  0,
+  -4,
+  3,
+  0,
+  -1,
+  -1,
+  -2,
+  0
+};

+ 35 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/output_shift_data.h

@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_2_output_shift[9] =
+{
+  -11,
+  -11,
+  -11,
+  -11,
+  -11,
+  -11,
+  -11,
+  -11,
+  -11
+};

+ 27 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/test_data.h

@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+// Generated by generate_test_data.py
+#include "config_data.h"
+#include "output_ref_data.h"
+#include "output_shift_data.h"
+#include "output_mult_data.h"
+#include "biases_data.h"
+#include "weights_data.h"
+#include "input_data.h"

+ 134 - 0
Tests/UnitTest/TestCases/TestData/depthwise_2/weights_data.h

@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_2_weights[108] =
+{
+  0,
+  64,
+  -127,
+  0,
+  -64,
+  0,
+  -64,
+  0,
+  -127,
+  64,
+  0,
+  -64,
+  64,
+  -127,
+  -64,
+  -127,
+  -64,
+  -64,
+  0,
+  0,
+  0,
+  -127,
+  64,
+  -64,
+  -127,
+  -127,
+  0,
+  64,
+  64,
+  -127,
+  -127,
+  -127,
+  -64,
+  -64,
+  -127,
+  -64,
+  -127,
+  0,
+  -64,
+  0,
+  0,
+  64,
+  0,
+  64,
+  -127,
+  64,
+  64,
+  -127,
+  -64,
+  -127,
+  64,
+  0,
+  -127,
+  -127,
+  -64,
+  -127,
+  0,
+  0,
+  -127,
+  -64,
+  -64,
+  0,
+  -127,
+  -64,
+  -127,
+  -127,
+  0,
+  -64,
+  -127,
+  64,
+  0,
+  64,
+  -127,
+  -127,
+  -64,
+  -127,
+  -64,
+  -64,
+  -64,
+  64,
+  -127,
+  -127,
+  -127,
+  64,
+  64,
+  64,
+  64,
+  -127,
+  0,
+  64,
+  0,
+  -64,
+  64,
+  -127,
+  0,
+  -64,
+  -127,
+  -127,
+  64,
+  0,
+  0,
+  -64,
+  -64,
+  0,
+  -127,
+  -127,
+  64,
+  0
+};

+ 32 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/biases_data.h

@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_eq_in_out_ch_biases[6] =
+{
+  -5398,
+  0,
+  -5398,
+  2699,
+  -2699,
+  -5398
+};

+ 41 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/config_data.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#define DEPTHWISE_EQ_IN_OUT_CH_OUT_CH 6
+#define DEPTHWISE_EQ_IN_OUT_CH_IN_CH 6
+#define DEPTHWISE_EQ_IN_OUT_CH_CH_MULT 1  // (Only for depthwise conv)
+#define DEPTHWISE_EQ_IN_OUT_CH_INPUT_W 4
+#define DEPTHWISE_EQ_IN_OUT_CH_INPUT_H 5
+#define DEPTHWISE_EQ_IN_OUT_CH_FILTER_X 2
+#define DEPTHWISE_EQ_IN_OUT_CH_FILTER_Y 3
+#define DEPTHWISE_EQ_IN_OUT_CH_STRIDE_X 1
+#define DEPTHWISE_EQ_IN_OUT_CH_STRIDE_Y 1
+#define DEPTHWISE_EQ_IN_OUT_CH_PAD_X 0
+#define DEPTHWISE_EQ_IN_OUT_CH_PAD_Y 1
+#define DEPTHWISE_EQ_IN_OUT_CH_OUTPUT_W 4
+#define DEPTHWISE_EQ_IN_OUT_CH_OUTPUT_H 5
+#define DEPTHWISE_EQ_IN_OUT_CH_DST_SIZE 120
+#define DEPTHWISE_EQ_IN_OUT_CH_INPUT_SIZE 120
+#define DEPTHWISE_EQ_IN_OUT_CH_INPUT_OFFSET 0
+#define DEPTHWISE_EQ_IN_OUT_CH_OUTPUT_OFFSET -1
+#define DEPTHWISE_EQ_IN_OUT_CH_OUT_ACTIVATION_MIN -128
+#define DEPTHWISE_EQ_IN_OUT_CH_OUT_ACTIVATION_MAX 127
+#define DEPTHWISE_EQ_IN_OUT_CH_INPUT_BATCHES 1

+ 146 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/input_data.h

@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_eq_in_out_ch_input[120] =
+{
+  -85,
+  0,
+  -42,
+  -42,
+  0,
+  42,
+  0,
+  42,
+  42,
+  0,
+  0,
+  0,
+  42,
+  0,
+  -42,
+  -85,
+  -85,
+  -85,
+  -85,
+  0,
+  42,
+  42,
+  -85,
+  -85,
+  -85,
+  -85,
+  -42,
+  0,
+  42,
+  -42,
+  42,
+  0,
+  -85,
+  42,
+  0,
+  42,
+  0,
+  -85,
+  0,
+  -42,
+  -85,
+  -85,
+  42,
+  -85,
+  42,
+  -85,
+  -42,
+  -85,
+  -42,
+  42,
+  42,
+  -85,
+  0,
+  0,
+  42,
+  42,
+  -42,
+  0,
+  0,
+  -42,
+  -42,
+  -42,
+  -42,
+  0,
+  0,
+  -42,
+  -42,
+  -42,
+  0,
+  -85,
+  42,
+  42,
+  0,
+  0,
+  0,
+  -85,
+  -42,
+  42,
+  0,
+  -42,
+  0,
+  -85,
+  42,
+  -85,
+  42,
+  -42,
+  -42,
+  -85,
+  0,
+  -85,
+  -85,
+  -85,
+  42,
+  -42,
+  -85,
+  42,
+  -42,
+  -42,
+  42,
+  -42,
+  -85,
+  0,
+  -85,
+  -85,
+  42,
+  -42,
+  0,
+  42,
+  -85,
+  -85,
+  42,
+  42,
+  -85,
+  0,
+  0,
+  42,
+  -85,
+  -85,
+  -42,
+  42
+};

+ 32 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/output_mult_data.h

@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_eq_in_out_ch_output_mult[6] =
+{
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280
+};

+ 146 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/output_ref_data.h

@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_eq_in_out_ch_output_ref[120] =
+{
+  -1,
+  -4,
+  -4,
+  -2,
+  -1,
+  -3,
+  -6,
+  -2,
+  1,
+  -1,
+  0,
+  0,
+  1,
+  -5,
+  -5,
+  6,
+  -3,
+  3,
+  -4,
+  -3,
+  -4,
+  2,
+  -5,
+  -1,
+  -2,
+  -2,
+  0,
+  5,
+  -1,
+  -2,
+  -3,
+  1,
+  -2,
+  3,
+  2,
+  5,
+  -7,
+  -3,
+  -4,
+  4,
+  3,
+  1,
+  0,
+  -4,
+  -2,
+  0,
+  2,
+  -6,
+  -2,
+  -2,
+  -4,
+  4,
+  -4,
+  -4,
+  -2,
+  1,
+  -3,
+  6,
+  -1,
+  7,
+  -1,
+  -2,
+  -1,
+  8,
+  -2,
+  -1,
+  -2,
+  -4,
+  -3,
+  5,
+  -1,
+  -6,
+  0,
+  -4,
+  -4,
+  5,
+  -7,
+  0,
+  -5,
+  -4,
+  -4,
+  -3,
+  -3,
+  -1,
+  3,
+  0,
+  -7,
+  6,
+  -1,
+  -8,
+  -2,
+  -2,
+  -1,
+  6,
+  -7,
+  -3,
+  1,
+  1,
+  -5,
+  7,
+  -2,
+  1,
+  2,
+  0,
+  -6,
+  9,
+  0,
+  -1,
+  -6,
+  -2,
+  1,
+  4,
+  -2,
+  -8,
+  -1,
+  0,
+  -2,
+  2,
+  1,
+  -2
+};

+ 32 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/output_shift_data.h

@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_eq_in_out_ch_output_shift[6] =
+{
+  -11,
+  -12,
+  -11,
+  -11,
+  -11,
+  -11
+};

+ 27 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/test_data.h

@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+// Generated by generate_test_data.py
+#include "config_data.h"
+#include "output_ref_data.h"
+#include "output_shift_data.h"
+#include "output_mult_data.h"
+#include "biases_data.h"
+#include "weights_data.h"
+#include "input_data.h"

+ 62 - 0
Tests/UnitTest/TestCases/TestData/depthwise_eq_in_out_ch/weights_data.h

@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_eq_in_out_ch_weights[36] =
+{
+  -64,
+  0,
+  64,
+  -127,
+  -127,
+  64,
+  64,
+  -127,
+  64,
+  -127,
+  0,
+  -127,
+  0,
+  127,
+  0,
+  0,
+  64,
+  0,
+  -127,
+  -127,
+  -127,
+  64,
+  -127,
+  -64,
+  -64,
+  127,
+  -64,
+  -64,
+  64,
+  -64,
+  0,
+  127,
+  0,
+  -127,
+  64,
+  -64
+};

+ 31 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/biases_data.h

@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_kernel_3x3_biases[5] =
+{
+  -2699,
+  0,
+  -2699,
+  0,
+  -5398
+};

+ 41 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/config_data.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#define DEPTHWISE_KERNEL_3X3_OUT_CH 5
+#define DEPTHWISE_KERNEL_3X3_IN_CH 5
+#define DEPTHWISE_KERNEL_3X3_CH_MULT 1  // (Only for depthwise conv)
+#define DEPTHWISE_KERNEL_3X3_INPUT_W 4
+#define DEPTHWISE_KERNEL_3X3_INPUT_H 5
+#define DEPTHWISE_KERNEL_3X3_FILTER_X 3
+#define DEPTHWISE_KERNEL_3X3_FILTER_Y 3
+#define DEPTHWISE_KERNEL_3X3_STRIDE_X 2
+#define DEPTHWISE_KERNEL_3X3_STRIDE_Y 2
+#define DEPTHWISE_KERNEL_3X3_PAD_X 0
+#define DEPTHWISE_KERNEL_3X3_PAD_Y 1
+#define DEPTHWISE_KERNEL_3X3_OUTPUT_W 2
+#define DEPTHWISE_KERNEL_3X3_OUTPUT_H 3
+#define DEPTHWISE_KERNEL_3X3_DST_SIZE 30
+#define DEPTHWISE_KERNEL_3X3_INPUT_SIZE 100
+#define DEPTHWISE_KERNEL_3X3_INPUT_OFFSET 0
+#define DEPTHWISE_KERNEL_3X3_OUTPUT_OFFSET -1
+#define DEPTHWISE_KERNEL_3X3_OUT_ACTIVATION_MIN -128
+#define DEPTHWISE_KERNEL_3X3_OUT_ACTIVATION_MAX 127
+#define DEPTHWISE_KERNEL_3X3_INPUT_BATCHES 1

+ 126 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/input_data.h

@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_kernel_3x3_input[100] =
+{
+  42,
+  -42,
+  -85,
+  42,
+  -85,
+  -42,
+  -85,
+  0,
+  -85,
+  42,
+  -85,
+  -42,
+  -42,
+  0,
+  42,
+  -85,
+  -42,
+  -85,
+  0,
+  -85,
+  -85,
+  -85,
+  0,
+  42,
+  42,
+  0,
+  -42,
+  -42,
+  -85,
+  -42,
+  42,
+  0,
+  -85,
+  -85,
+  -42,
+  0,
+  -85,
+  42,
+  -85,
+  -42,
+  -42,
+  -42,
+  -42,
+  -85,
+  0,
+  0,
+  42,
+  -42,
+  42,
+  -85,
+  -42,
+  42,
+  -42,
+  42,
+  -42,
+  -85,
+  -85,
+  42,
+  -42,
+  42,
+  0,
+  -85,
+  -42,
+  -42,
+  -85,
+  42,
+  -42,
+  42,
+  -85,
+  -85,
+  -42,
+  0,
+  -85,
+  42,
+  42,
+  42,
+  -85,
+  -85,
+  -42,
+  0,
+  42,
+  -85,
+  42,
+  42,
+  -85,
+  42,
+  -42,
+  -42,
+  0,
+  42,
+  -85,
+  -42,
+  -42,
+  -42,
+  0,
+  0,
+  42,
+  42,
+  -85,
+  42
+};

+ 31 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/output_mult_data.h

@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_kernel_3x3_output_mult[5] =
+{
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280,
+  1642543280
+};

+ 56 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/output_ref_data.h

@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_kernel_3x3_output_ref[30] =
+{
+  2,
+  6,
+  0,
+  3,
+  -1,
+  0,
+  0,
+  -3,
+  1,
+  -6,
+  2,
+  6,
+  4,
+  5,
+  -1,
+  0,
+  0,
+  -5,
+  8,
+  0,
+  -1,
+  6,
+  5,
+  3,
+  1,
+  4,
+  -2,
+  -1,
+  -1,
+  -3
+};

+ 31 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/output_shift_data.h

@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const int32_t depthwise_kernel_3x3_output_shift[5] =
+{
+  -11,
+  -11,
+  -11,
+  -11,
+  -11
+};

+ 27 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/test_data.h

@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+// Generated by generate_test_data.py
+#include "config_data.h"
+#include "output_ref_data.h"
+#include "output_shift_data.h"
+#include "output_mult_data.h"
+#include "biases_data.h"
+#include "weights_data.h"
+#include "input_data.h"

+ 71 - 0
Tests/UnitTest/TestCases/TestData/depthwise_kernel_3x3/weights_data.h

@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+// Generated by generate_test_data.py
+#include <stdint.h>
+
+const q7_t depthwise_kernel_3x3_weights[45] =
+{
+  -64,
+  -127,
+  0,
+  -127,
+  0,
+  64,
+  0,
+  -127,
+  -127,
+  -64,
+  0,
+  -64,
+  -127,
+  -64,
+  -127,
+  -127,
+  -64,
+  64,
+  0,
+  -127,
+  0,
+  -127,
+  -127,
+  0,
+  0,
+  -64,
+  64,
+  -127,
+  64,
+  0,
+  -127,
+  -127,
+  64,
+  0,
+  0,
+  -64,
+  64,
+  -127,
+  -64,
+  64,
+  0,
+  -64,
+  0,
+  -64,
+  64
+};

+ 47 - 0
Tests/UnitTest/TestCases/test_arm_depthwise_conv_3x3_s8/Unity/unity_test_arm_depthwise_conv_3x3_s8.c

@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "unity.h"
+#include "../test_arm_depthwise_conv_3x3_s8.c"
+
+/* This function is called from the autogenerated file.
+ * The name must be exactly like this
+ */
+void setUp(void)
+{
+  /* This is run before EACH TEST */
+}
+
+/* This function is called from the autogenerated file.
+ * The name must be exactly like this
+ */
+void tearDown(void)
+{
+
+}
+
+void test_depthwise_kernel_3x3_arm_depthwise_conv_3x3_s8(void)
+{
+  depthwise_kernel_3x3_arm_depthwise_conv_3x3_s8();
+}

+ 60 - 0
Tests/UnitTest/TestCases/test_arm_depthwise_conv_3x3_s8/test_arm_depthwise_conv_3x3_s8.c

@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <arm_nnfunctions.h>
+#include <stdlib.h>
+
+#include "../Utils/validate.h"
+#include "../TestData/depthwise_kernel_3x3/test_data.h"
+
+static const uint16_t dilation = 1;
+
+void depthwise_kernel_3x3_arm_depthwise_conv_3x3_s8(void)
+{
+  const arm_status expected = ARM_MATH_SUCCESS;
+  q7_t output[DEPTHWISE_KERNEL_3X3_DST_SIZE] = {0};
+
+  int16_t *bufferA = NULL;
+
+  arm_status result = arm_depthwise_conv_3x3_s8((int8_t *)depthwise_kernel_3x3_input,
+                                            DEPTHWISE_KERNEL_3X3_INPUT_W,
+                                            DEPTHWISE_KERNEL_3X3_INPUT_H,
+                                            DEPTHWISE_KERNEL_3X3_IN_CH,
+                                                (int8_t *)depthwise_kernel_3x3_weights,
+                                            DEPTHWISE_KERNEL_3X3_OUT_CH,
+                                            DEPTHWISE_KERNEL_3X3_PAD_X,
+                                            DEPTHWISE_KERNEL_3X3_PAD_Y,
+                                            DEPTHWISE_KERNEL_3X3_STRIDE_X,
+                                            DEPTHWISE_KERNEL_3X3_STRIDE_Y,
+                                            depthwise_kernel_3x3_biases,
+                                            (int8_t *)output,
+                                            depthwise_kernel_3x3_output_shift,
+                                            depthwise_kernel_3x3_output_mult,
+                                            DEPTHWISE_KERNEL_3X3_OUTPUT_W,
+                                            DEPTHWISE_KERNEL_3X3_OUTPUT_H,
+                                            DEPTHWISE_KERNEL_3X3_OUTPUT_OFFSET,
+                                            DEPTHWISE_KERNEL_3X3_INPUT_OFFSET,
+                                            DEPTHWISE_KERNEL_3X3_OUT_ACTIVATION_MIN,
+                                            DEPTHWISE_KERNEL_3X3_OUT_ACTIVATION_MAX,
+                                            dilation,
+                                            dilation,
+                                            bufferA);
+
+  TEST_ASSERT_EQUAL(expected, result);
+  TEST_ASSERT_TRUE(validate(output, depthwise_kernel_3x3_output_ref, DEPTHWISE_KERNEL_3X3_DST_SIZE));
+}

+ 5 - 0
Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8/Unity/unity_test_arm_depthwwise_conv_s8.c

@@ -50,3 +50,8 @@ void test_stride2pad1_arm_depthwise_conv_s8(void)
 {
   stride2pad1_arm_depthwise_conv_s8();
 }
+
+void test_depthwise_2_arm_depthwise_conv_s8(void)
+{
+  depthwise_2_arm_depthwise_conv_s8();
+}

+ 37 - 0
Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8/test_arm_depthwise_conv_s8.c

@@ -21,6 +21,7 @@
 #include "../Utils/validate.h"
 #include "../TestData/basic/test_data.h"
 #include "../TestData/stride2pad1/test_data.h"
+#include "../TestData/depthwise_2/test_data.h"
 
 
 // Not used
@@ -102,3 +103,39 @@ void stride2pad1_arm_depthwise_conv_s8(void)
   TEST_ASSERT_EQUAL(expected, result);
   TEST_ASSERT_TRUE(validate(output, stride2pad1_output_ref, STRIDE2PAD1_DST_SIZE));
 }
+
+void depthwise_2_arm_depthwise_conv_s8(void)
+{
+  const arm_status expected = ARM_MATH_SUCCESS;
+  q7_t output[DEPTHWISE_2_DST_SIZE] = {0};
+
+  arm_status result = arm_depthwise_conv_s8(depthwise_2_input,
+                                            DEPTHWISE_2_INPUT_W,
+                                            DEPTHWISE_2_INPUT_H,
+                                            DEPTHWISE_2_IN_CH,
+                                            depthwise_2_weights,
+                                            DEPTHWISE_2_OUT_CH,
+                                            DEPTHWISE_2_CH_MULT,
+                                            DEPTHWISE_2_FILTER_X,
+                                            DEPTHWISE_2_FILTER_Y,
+                                            DEPTHWISE_2_PAD_X,
+                                            DEPTHWISE_2_PAD_Y,
+                                            DEPTHWISE_2_STRIDE_X,
+                                            DEPTHWISE_2_STRIDE_Y,
+                                            depthwise_2_biases,
+                                            output,
+                                            depthwise_2_output_shift,
+                                            depthwise_2_output_mult,
+                                            DEPTHWISE_2_OUTPUT_W,
+                                            DEPTHWISE_2_OUTPUT_H,
+                                            DEPTHWISE_2_OUTPUT_OFFSET,
+                                            DEPTHWISE_2_INPUT_OFFSET,
+                                            DEPTHWISE_2_OUT_ACTIVATION_MIN,
+                                            DEPTHWISE_2_OUT_ACTIVATION_MAX,
+                                            dilation,
+                                            dilation,
+                                            bufferA);
+
+  TEST_ASSERT_EQUAL(expected, result);
+  TEST_ASSERT_TRUE(validate(output, depthwise_2_output_ref, DEPTHWISE_2_DST_SIZE));
+}

+ 5 - 0
Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8_opt/Unity/unity_test_arm_depthwise_conv_s8_opt.c

@@ -50,3 +50,8 @@ void test_stride2pad1_arm_depthwise_conv_s8_opt(void)
 {
   stride2pad1_arm_depthwise_conv_s8_opt();
 }
+
+void test_depthwise_eq_in_out_ch_arm_depthwise_conv_s8_opt(void)
+{
+  depthwise_eq_in_out_ch_arm_depthwise_conv_s8_opt();
+}

+ 45 - 6
Tests/UnitTest/TestCases/test_arm_depthwise_conv_s8_opt/test_arm_depthwise_conv_s8_opt.c

@@ -22,7 +22,10 @@
 #include "../Utils/validate.h"
 #include "../TestData/basic/test_data.h"
 #include "../TestData/stride2pad1/test_data.h"
+#include "../TestData/depthwise_2/test_data.h"
+#include "../TestData/depthwise_eq_in_out_ch/test_data.h"
 
+static const uint16_t dilation = 1;
 
 void basic_arm_depthwise_conv_s8_opt(void)
 {
@@ -32,9 +35,6 @@ void basic_arm_depthwise_conv_s8_opt(void)
   const int32_t buf_size = arm_depthwise_conv_s8_opt_get_buffer_size(BASIC_IN_CH, BASIC_FILTER_X, BASIC_FILTER_Y);
   q15_t *bufferA = (q15_t*)malloc(buf_size);
 
-  // Not used
-  const uint16_t dilation = 1;
-
   arm_status result = arm_depthwise_conv_s8_opt(basic_input,
                                                 BASIC_INPUT_W,
                                                 BASIC_INPUT_H,
@@ -73,9 +73,6 @@ void stride2pad1_arm_depthwise_conv_s8_opt(void)
   const int32_t buf_size = arm_depthwise_conv_s8_opt_get_buffer_size(BASIC_IN_CH, BASIC_FILTER_X, BASIC_FILTER_Y);
   q15_t *bufferA = (q15_t*)malloc(buf_size);
 
-  // Not used
-  const uint16_t dilation = 1;
-
   arm_status result = arm_depthwise_conv_s8_opt(stride2pad1_input,
                                                 STRIDE2PAD1_INPUT_W,
                                                 STRIDE2PAD1_INPUT_H,
@@ -105,3 +102,45 @@ void stride2pad1_arm_depthwise_conv_s8_opt(void)
   TEST_ASSERT_EQUAL(expected, result);
   TEST_ASSERT_TRUE(validate(output, stride2pad1_output_ref, STRIDE2PAD1_DST_SIZE));
 }
+
+void depthwise_eq_in_out_ch_arm_depthwise_conv_s8_opt(void)
+{
+  const arm_status expected = ARM_MATH_SUCCESS;
+  q7_t output[DEPTHWISE_EQ_IN_OUT_CH_DST_SIZE] = {0};
+
+  const int32_t buf_size = arm_depthwise_conv_s8_opt_get_buffer_size(DEPTHWISE_EQ_IN_OUT_CH_IN_CH,
+                                                                     DEPTHWISE_EQ_IN_OUT_CH_FILTER_X,
+                                                                     DEPTHWISE_EQ_IN_OUT_CH_FILTER_Y);
+  q15_t *bufferA = (q15_t*)malloc(buf_size);
+
+  arm_status result = arm_depthwise_conv_s8_opt(depthwise_eq_in_out_ch_input,
+                                                DEPTHWISE_EQ_IN_OUT_CH_INPUT_W,
+                                                DEPTHWISE_EQ_IN_OUT_CH_INPUT_H,
+                                                DEPTHWISE_EQ_IN_OUT_CH_IN_CH,
+                                                depthwise_eq_in_out_ch_weights,
+                                                DEPTHWISE_EQ_IN_OUT_CH_OUT_CH,
+                                                DEPTHWISE_EQ_IN_OUT_CH_FILTER_X,
+                                                DEPTHWISE_EQ_IN_OUT_CH_FILTER_Y,
+                                                DEPTHWISE_EQ_IN_OUT_CH_PAD_X,
+                                                DEPTHWISE_EQ_IN_OUT_CH_PAD_Y,
+                                                DEPTHWISE_EQ_IN_OUT_CH_STRIDE_X,
+                                                DEPTHWISE_EQ_IN_OUT_CH_STRIDE_Y,
+                                                depthwise_eq_in_out_ch_biases,
+                                                output,
+                                                depthwise_eq_in_out_ch_output_shift,
+                                                depthwise_eq_in_out_ch_output_mult,
+                                                DEPTHWISE_EQ_IN_OUT_CH_OUTPUT_W,
+                                                DEPTHWISE_EQ_IN_OUT_CH_OUTPUT_H,
+                                                DEPTHWISE_EQ_IN_OUT_CH_OUTPUT_OFFSET,
+                                                DEPTHWISE_EQ_IN_OUT_CH_INPUT_OFFSET,
+                                                DEPTHWISE_EQ_IN_OUT_CH_OUT_ACTIVATION_MIN,
+                                                DEPTHWISE_EQ_IN_OUT_CH_OUT_ACTIVATION_MAX,
+                                                dilation,
+                                                dilation,
+                                                bufferA);
+
+  free(bufferA);
+
+  TEST_ASSERT_EQUAL(expected, result);
+  TEST_ASSERT_TRUE(validate(output, depthwise_eq_in_out_ch_output_ref, DEPTHWISE_EQ_IN_OUT_CH_DST_SIZE));
+}

+ 109 - 26
Tests/UnitTest/generate_test_data.py

@@ -63,7 +63,8 @@ def parse_args():
     parser.add_argument('--regenerate-input', action='store_true', help="Regenerate and store new input.")
     parser.add_argument('--regenerate-biases', action='store_true', help="Regenerate and store new biases.")
     parser.add_argument('-a', '--regenerate-all', action='store_true', help="Regenerate and store all data.")
-    parser.add_argument('-t', '--type', type=str, default='conv', choices=['conv', 'avgpool', 'maxpool'],
+    parser.add_argument('-t', '--type', type=str, default='conv', choices=['conv', 'depthwise_conv', 'avgpool',
+                                                                           'maxpool'],
                         help='Type of test.')
 
     args = parser.parse_args()
@@ -97,6 +98,9 @@ class TestSettings(ABC):
         self.stride_x = stride_x
         self.stride_y = stride_y
         self.batches = batches
+        self.channel_multiplier = out_ch // in_ch
+        if out_ch % in_ch != 0:
+            raise RuntimeError("out channel ({}) is not multiple of in channel ({})".format(out_ch, in_ch))
 
         self.has_padding = pad
         self.test_type = args.type
@@ -247,6 +251,8 @@ class TestSettings(ABC):
             f.write("// Generated by {}\n".format(os.path.basename(__file__)))
             f.write("#define {}_OUT_CH {}\n".format(prefix, self.output_ch))
             f.write("#define {}_IN_CH {}\n".format(prefix, self.input_ch))
+            f.write("#define {}_CH_MULT {}  "
+                    "// (Only for depthwise conv)\n".format(prefix, self.channel_multiplier))
             f.write("#define {}_INPUT_W {}\n".format(prefix, self.x_input))
             f.write("#define {}_INPUT_H {}\n".format(prefix, self.y_input))
             f.write("#define {}_FILTER_X {}\n".format(prefix, self.filter_x))
@@ -329,12 +335,23 @@ class ConvSettings(TestSettings):
         super().__init__(args, in_ch, out_ch, x_in, y_in, w_x, w_y, stride_x, stride_y, pad, randmin, randmax,
                          outminrange, outmaxrange, batches)
 
+        if self.test_type == 'conv':
+            self.quantized_dimension = 0
+        elif self.test_type == 'depthwise_conv':
+            self.quantized_dimension = 3
+        else:
+            raise RuntimeError("Invalid test type {}".format(self.test_type))
+
     def quantize_bias(self, nparray):
         num_channels = self.output_ch
         quantized_values = []
+
         values = np.array(nparray)
 
         def quantize_float_to_int(value, scale):
+            if scale == 0:
+                print("WARNING: scale is 0")
+                scale = 0.0000001
             quantized = round(value / scale)
             if quantized > self.INT_MAX:
                 quantized = self.INT_MAX
@@ -347,20 +364,46 @@ class ConvSettings(TestSettings):
 
         return np.asarray(quantized_values)
 
-    def reshape_kernel(self, kernel):
+    def reshape_conv_kernel(self, kernel):
+        """
+        TFL & TFLu conv weight format: kOHWI
+        Tensorflow conv weight format: kHWIO
+        """
         kernel = tf.reshape(kernel, [self.output_ch, self.filter_y, self.filter_x, self.input_ch])
         kernel = tf.transpose(kernel, (1, 2, 0, 3))
         kernel = tf.transpose(kernel, (0, 1, 3, 2))
         return kernel
 
+    def reshape_depthwise_conv_kernel(self, kernel):
+        """
+        TFL & TFLu depthwise conv weight format: k1HWO
+        Tensorflow depthwise conv weight format: kHWIM
+        """
+        kernel = tf.reshape(kernel, [1, self.filter_y, self.filter_x, self.output_ch])
+        kernel = tf.transpose(kernel, (1, 0, 2, 3))
+        kernel = tf.transpose(kernel, (0, 2, 1, 3))
+        kernel = tf.reshape(kernel, [self.filter_y, self.filter_x, self.input_ch, self.channel_multiplier])
+        return kernel
+
     def quantize_filter(self, nparray):
-        quantized_values = []
         channel_count = self.output_ch
-        input_size = self.filter_y * self.filter_x * self.input_ch * self.output_ch
+
+        if self.quantized_dimension == 0:
+            input_size = self.filter_y * self.filter_x * self.input_ch * self.output_ch
+        elif self.quantized_dimension == 3:
+            input_size = self.filter_y * self.filter_x * self.input_ch * self.channel_multiplier
+
         per_channel_size = input_size // channel_count
+
+        if self.quantized_dimension == 0:
+            stride = 1
+            channel_stride = per_channel_size
+        elif self.quantized_dimension == 3:
+            stride = channel_count
+            channel_stride = 1
+
         values = np.array(nparray)
-        stride = 1
-        channel_stride = per_channel_size
+        quantized_values = values.copy()
 
         for channel in range(channel_count):
             fmin = 0
@@ -378,7 +421,7 @@ class ConvSettings(TestSettings):
 
                 # Clamp
                 quantized_value = min(127, max(-127, quantized_value))
-                quantized_values.append(quantized_value)
+                quantized_values[chs] = quantized_value
 
         return np.asarray(quantized_values)
 
@@ -405,7 +448,7 @@ class ConvSettings(TestSettings):
         self.generate_c_array("output_mult", per_channel_multiplier, datatype='int32_t')
         self.generate_c_array("output_shift", per_channel_shift, datatype='int32_t')
 
-    def convolution(self, indata, weights, bias=None):
+    def conv2d(self, indata, weights, bias=None):
         indata = tf.cast(indata, dtype=tf.dtypes.float32)
         weights = tf.cast(weights, dtype=tf.dtypes.float32)
         bias = tf.cast(bias, dtype=tf.dtypes.float32)
@@ -421,6 +464,25 @@ class ConvSettings(TestSettings):
 
         return out
 
+    def depthwise_conv2d(self, indata, weights, bias=None):
+        indata = tf.cast(indata, dtype=tf.dtypes.float32)
+        weights = tf.cast(weights, dtype=tf.dtypes.float32)
+        bias = tf.cast(bias, dtype=tf.dtypes.float32)
+
+        out = tf.nn.depthwise_conv2d(indata,
+                                     weights,
+                                     strides=[1, self.stride_y, self.stride_x, 1],
+                                     padding=self.padding)
+
+        if tf.TensorShape([self.batches, self.y_output, self.x_output, self.output_ch]) \
+             .as_list() != out.shape.as_list():
+            raise RuntimeError("Shape mismatch, regenerate data?")
+
+        out = tf.nn.bias_add(out, bias)
+        out = tf.clip_by_value(out, self.minrange, self.maxrange)
+
+        return out
+
     def generate_data(self, input_data=None, weights=None, biases=None):
         # Tensorflow Lite has a different kernel format compared to Tensorflow
         reshaped_weights = None
@@ -432,13 +494,22 @@ class ConvSettings(TestSettings):
             input_data = self.get_randomized_data([self.batches, self.y_input, self.x_input, self.input_ch],
                                                   self.inputs_table_file,
                                                   regenerate=self.regenerate_new_input)
+        if self.test_type == 'conv':
+            out_channel = self.output_ch
+        elif self.test_type == 'depthwise_conv':
+            out_channel = self.channel_multiplier
+
         if weights is not None:
-            weights = tf.reshape(weights, [self.filter_y, self.filter_x, self.input_ch, self.output_ch])
+            weights = tf.reshape(weights, [self.filter_y, self.filter_x, self.input_ch, out_channel])
         else:
-            weights = self.get_randomized_data([self.filter_y, self.filter_x, self.input_ch, self.output_ch],
+            weights = self.get_randomized_data([self.filter_y, self.filter_x, self.input_ch, out_channel],
                                                self.kernel_table_file,
                                                regenerate=self.regenerate_new_weights)
-        reshaped_weights = self.reshape_kernel(weights)
+        if self.test_type == 'conv':
+            reshaped_weights = self.reshape_conv_kernel(weights)
+        elif self.test_type == 'depthwise_conv':
+            reshaped_weights = self.reshape_depthwise_conv_kernel(weights)
+
         if biases is not None:
             biases = tf.reshape(biases, [self.output_ch])
         else:
@@ -446,8 +517,11 @@ class ConvSettings(TestSettings):
                                               self.bias_table_file,
                                               regenerate=self.regenerate_new_bias)
 
-        # Generate conv reference
-        conv = self.convolution(input_data, reshaped_weights, biases)
+        # Generate reference
+        if self.test_type == 'conv':
+            conv = self.conv2d(input_data, reshaped_weights, biases)
+        elif self.test_type == 'depthwise_conv':
+            conv = self.depthwise_conv2d(input_data, reshaped_weights, biases)
 
         # Quantize and write to C headers
         self.generate_c_array("input", self.convert_tensor(input_data, self.quantize_input))
@@ -513,22 +587,24 @@ if __name__ == '__main__':
 
     args = parse_args()
 
-    if args.type == 'conv':
-        generator = ConvSettings(args, in_ch=4, out_ch=17, x_in=15, y_in=15, w_x=1, w_y=1, stride_x=1, stride_y=1,
-                                 pad=False, randmin=1, randmax=4, outminrange=-126, outmaxrange=127)
-        #conv_3
+    if args.type == 'conv' or args.type == 'depthwise_conv':
+        # kernel1x1
+        # generator = ConvSettings(args, in_ch=4, out_ch=17, x_in=15, y_in=15, w_x=1, w_y=1, stride_x=1, stride_y=1,
+        #                         pad=False, randmin=1, randmax=4, outminrange=-126, outmaxrange=127)
+
+        # conv_3
         # generator = ConvSettings(args, in_ch=3, out_ch=1, x_in=10, y_in=49, w_x=4, w_y=10, stride_x=1, stride_y=2,
         #                          pad=True, randmin=-2, randmax=2, outminrange=-127, outmaxrange=127)
 
-        #conv_1_x_n_1
+        # conv_1_x_n_1
         # generator = ConvSettings(args, in_ch=3, out_ch=3, x_in=5, y_in=5, w_x=2, w_y=1, stride_x=2, stride_y=1,
         #                          pad=False, randmin=-2, randmax=2, outminrange=-127, outmaxrange=127, batches=2)
 
-        #conv_1_x_n_2
+        # conv_1_x_n_2
         # generator = ConvSettings(args, in_ch=3, out_ch=1, x_in=11, y_in=11, w_x=11, w_y=1, stride_x=1, stride_y=1,
         #                          pad=True, randmin=-2, randmax=2, outminrange=-127, outmaxrange=127)
 
-        #conv_1_x_n_3
+        # conv_1_x_n_3
         # generator = ConvSettings(args, in_ch=1, out_ch=3, x_in=11, y_in=11, w_x=1, w_y=11, stride_x=1, stride_y=1,
         #                          pad=True, randmin=-2, randmax=2, outminrange=-127, outmaxrange=127)
 
@@ -536,16 +612,23 @@ if __name__ == '__main__':
         # generator = ConvSettings(args, in_ch=2, out_ch=4, x_in=6, y_in=3, w_x=3, w_y=3, stride_x=1, stride_y=1,
         #                        pad=True, randmin=-2, randmax=2, outminrange=-126, outmaxrange=127)
 
-        #conv_4 batches > 2
+        # conv_4 batches > 2
         # generator = ConvSettings(args, in_ch=3, out_ch=3, x_in=5, y_in=5, w_x=2, w_y=3, stride_x=2, stride_y=2,
         #                         pad=False, randmin=-2, randmax=2, outminrange=-127, outmaxrange=127, batches=3)
 
+        # depthwise_2
+        # generator = ConvSettings(args, in_ch=3, out_ch=9, x_in=6, y_in=5, w_x=3, w_y=4, stride_x=2, stride_y=2,
+        #                         pad=True, randmin=-2, randmax=2, outminrange=-126, outmaxrange=127)
 
+        # depthwise_kernel_3x3
+        # generator = ConvSettings(args, in_ch=5, out_ch=5, x_in=4, y_in=5, w_x=3, w_y=3, stride_x=2, stride_y=2,
+        #                         pad=True, randmin=-2, randmax=2, outminrange=-126, outmaxrange=127)
+
+        # depthwise_eq_in_out_ch
+        generator = ConvSettings(args, in_ch=6, out_ch=6, x_in=4, y_in=5, w_x=2, w_y=3, stride_x=1, stride_y=1,
+                                 pad=True, randmin=-2, randmax=2, outminrange=-126, outmaxrange=127)
+
+        # depthwise_eq_in_out_ch
     elif args.type == 'avgpool' or args.type == 'maxpool':
         generator = PoolingSettings(args, channels=8, x_in=22, y_in=12, stride_x=9, stride_y=5, w_x=6, w_y=5, pad=True)
-
     generator.generate_data()
-
-
-
-

+ 37 - 23
Tests/UnitTest/unittest_targets.py

@@ -31,6 +31,7 @@ import threading
 import subprocess
 
 from os import path
+from termcolor import colored
 
 OUTPUT = "Output/"
 BASE_PATH = "../../"
@@ -187,7 +188,6 @@ def test_target_with_unity(target, args, main_test):
     timeout = 30
     inputQueue = queue.Queue()
     tests = copy.deepcopy(target["tests"])
-    result = []
 
     try:
         ser = serial.Serial(port, baudrate, timeout=timeout)
@@ -215,7 +215,6 @@ def test_target_with_unity(target, args, main_test):
             except IndexError:
                 pass
             if test in tests:
-                result.append("{}: {}".format(target["name"], test_result))
                 tests.remove(test)
                 target[test]["tested"] = True
                 if test_result == test + ':PASS':
@@ -227,10 +226,6 @@ def test_target_with_unity(target, args, main_test):
     serial_thread.join()
     ser.close()
 
-    print()
-    for res in result:
-        print(res)
-
 
 def print_summary(targets):
     """
@@ -243,6 +238,9 @@ def print_summary(targets):
     tested = 0
     expected = 0
     return_code = 3
+    verdict_pass = colored('[ PASSED ]', 'green')
+    verdict_fail = colored('[ FAILED ]', 'red')
+    verdict_error = colored('[ ERROR ]', 'red')
 
     print("-----------------------------------------------------------------------------------------------------------")
 
@@ -252,37 +250,45 @@ def print_summary(targets):
             expected += 1
             if target[test]["tested"]:
                 tested += 1
-            else:
-                print("ERROR: Test {} for target {} not found".format(test, target["name"]))
             if target[test]["pass"]:
                 passed += 1
             else:
                 failed += 1
 
     if tested != expected:
-        print("ERROR: Not all tests found!")
-        print("Expected: {} Actual: {}".format(expected, tested))
+        print("{} Not all tests found".format(verdict_error))
+        print("{} Expected: {} Actual: {}".format(verdict_error, expected, tested))
         return_code = 2
     elif tested == passed:
         return_code = 0
     else:
         return_code = 1
 
-    print("Summary: {} tests in total passed on {} targets ({})".
-          format(passed, len(targets), ', '.join([t['name'] for t in targets])))
-
-    # Print those that failed
-    if failed > 0:
-        print()
-        for target in targets:
-            for test in target["tests"]:
-                if not target[test]["pass"]:
-                    print("{}: {} failed".format(target["name"], test))
+    # print all test cases
+    sorted_tc = []
+    for target in targets:
+        for test in target["tests"]:
+            if not target[test]["tested"]:
+                tc_verdict = verdict_error
+            elif target[test]["pass"]:
+                tc_verdict = verdict_pass
+            else:
+                tc_verdict = verdict_fail
+            sorted_tc.append("{} {}: {}".format(tc_verdict, target["name"], test))
+    sorted_tc.sort()
+    for tc in sorted_tc:
+        print(tc)
 
+    total = 0
     if (passed > 0):
-        print("{:.0f}% tests passed, {} tests failed out of {}".format(passed/expected*100, failed, expected))
+        total = passed / expected
+    if (total == 1.0):
+        verdict = verdict_pass
     else:
-        print("0% tests passed, {} tests failed out of {}".format(failed, tested))
+        verdict = verdict_fail
+    print("{} Summary: {} tests in total passed on {} targets ({})".
+          format(verdict, passed, len(targets), ', '.join([t['name'] for t in targets])))
+    print("{} {:.0f}% tests passed, {} tests failed out of {}".format(verdict, total*100, failed, expected))
 
     return return_code
 
@@ -374,16 +380,22 @@ def parse_tests(targets, main_tests, specific_test=None):
     Generate test runners and parse it to know what to expect from the serial console
     Return True if successful
     """
+    test_found = False
     directory = 'TestCases'
     for dir in next(os.walk(directory))[1]:
         if re.search(r'test_arm', dir):
             if specific_test and dir != specific_test:
                 continue
+            test_found = True
             testpath = directory + '/' + dir + '/Unity/'
-            main_tests.append(testpath)
+            ut_test_file = None
             for content in os.listdir(testpath):
                 if re.search(r'unity_test_arm', content):
                     ut_test_file = content
+            if ut_test_file is None:
+                print("Warning: invalid path: ", testpath)
+                continue
+            main_tests.append(testpath)
             ut_test_file_runner = path.splitext(ut_test_file)[0] + '_runner' + path.splitext(ut_test_file)[1]
             test_code = testpath + ut_test_file
             test_runner_path = testpath + 'TestRunner/'
@@ -399,6 +411,8 @@ def parse_tests(targets, main_tests, specific_test=None):
             test_found = parse_test(test_runner, targets)
             if not test_found:
                 return False
+    if not test_found:
+        return False
     return True