Browse Source

APP_Framework/Framework/:update knowing framework

1.fix some Kconfig file
2.add tensorflow-lite-for-mcu in knowing file
3.add mnist application,note the application cannot be used with RAM less than 500K.
4.the version need to separate application and OS(rtt),later by using add transform layer to solve it.
pull/1/head
chunyexixiaoyu 1 year ago
parent
commit
38d2cb3c85
  1. 6
      APP_Framework/Applications/knowing_app/Kconfig
  2. 14
      APP_Framework/Applications/knowing_app/SConscript
  3. 2
      APP_Framework/Applications/knowing_app/mnist/.gitignore
  4. BIN
      APP_Framework/Applications/knowing_app/mnist/K210 mnist .png
  5. 4
      APP_Framework/Applications/knowing_app/mnist/Kconfig
  6. 23
      APP_Framework/Applications/knowing_app/mnist/README.md
  7. 9
      APP_Framework/Applications/knowing_app/mnist/SConscript
  8. 31
      APP_Framework/Applications/knowing_app/mnist/digit.h
  9. 94
      APP_Framework/Applications/knowing_app/mnist/main.cpp
  10. 31409
      APP_Framework/Applications/knowing_app/mnist/model.h
  11. 36
      APP_Framework/Applications/knowing_app/mnist/tools/mnist-c-digit.py
  12. 23
      APP_Framework/Applications/knowing_app/mnist/tools/mnist-c-model.py
  13. 40
      APP_Framework/Applications/knowing_app/mnist/tools/mnist-inference.py
  14. 109
      APP_Framework/Applications/knowing_app/mnist/tools/mnist-train.py
  15. 2
      APP_Framework/Framework/knowing/Kconfig
  16. 14
      APP_Framework/Framework/knowing/SConscript
  17. 24
      APP_Framework/Framework/knowing/tensorflow-lite/Kconfig
  18. 207
      APP_Framework/Framework/knowing/tensorflow-lite/SConscript
  19. 1
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/.gitignore
  20. 203
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/README.md
  21. 2171
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/patch/cmsis_gcc.h
  22. 203
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/LICENSE
  23. 57
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/Makefile
  24. 29
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/README_MAKE.md
  25. 139
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/core/public/version.h
  26. 484
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/c/builtin_op_data.h
  27. 92
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/c/c_api_types.h
  28. 236
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/c/common.c
  29. 913
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/c/common.h
  30. 38
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/error_reporter.cc
  31. 59
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/error_reporter.h
  32. 1945
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/flatbuffer_conversions.cc
  33. 301
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/flatbuffer_conversions.h
  34. 67
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/op_resolver.cc
  35. 60
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/op_resolver.h
  36. 194
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/profiler.h
  37. 50
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/tensor_utils.cc
  38. 28
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/tensor_utils.h
  39. 1037
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/common.h
  40. 112
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/compatibility.h
  41. 40
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/cppmath.h
  42. 35
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/max.h
  43. 35
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/min.h
  44. 40
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/optimized/neon_check.h
  45. 122
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/portable_tensor.h
  46. 395
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/quantization_util.cc
  47. 292
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/quantization_util.h
  48. 446
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/add.h
  49. 68
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/arg_min_max.h
  50. 80
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/binary_function.h
  51. 37
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/ceil.h
  52. 280
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/comparisons.h
  53. 139
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/concatenation.h
  54. 264
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/conv.h
  55. 100
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h
  56. 297
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h
  57. 78
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/dequantize.h
  58. 39
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/floor.h
  59. 320
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/fully_connected.h
  60. 166
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/hard_swish.h
  61. 144
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/add.h
  62. 221
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/conv.h
  63. 289
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h
  64. 108
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h
  65. 65
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h
  66. 106
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h
  67. 77
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h
  68. 131
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/mul.h
  69. 258
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h
  70. 110
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h
  71. 221
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h
  72. 90
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/l2normalization.h
  73. 132
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/logistic.h
  74. 64
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/maximum_minimum.h
  75. 166
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/mul.h
  76. 37
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/neg.h
  77. 162
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/pad.h
  78. 297
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/pooling.h
  79. 109
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/prelu.h
  80. 138
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h
  81. 55
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/quantize.h
  82. 412
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/reduce.h
  83. 68
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/requantize.h
  84. 101
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h
  85. 51
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/round.h
  86. 232
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/softmax.h
  87. 121
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/strided_slice.h
  88. 512
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/sub.h
  89. 129
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/tanh.h
  90. 217
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/reference/transpose_conv.h
  91. 211
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/strided_slice_logic.h
  92. 47
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/tensor_ctypes.h
  93. 1169
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/types.h
  94. 480
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/kernel_util.cc
  95. 293
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/kernel_util.h
  96. 83
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/op_macros.h
  97. 80
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/padding.h
  98. 84
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/micro/all_ops_resolver.cc
  99. 38
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/micro/all_ops_resolver.h
  100. 2845
      APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/micro/benchmarks/keyword_scrambled_model_data.cc

6
APP_Framework/Applications/knowing_app/Kconfig

@ -1,7 +1,3 @@
menu "knowing app"
menuconfig APPLICATION_KNOWING
bool "Using knowing apps"
default n
source "$APP_DIR/Applications/knowing_app/mnist/Kconfig"
endmenu

14
APP_Framework/Applications/knowing_app/SConscript

@ -0,0 +1,14 @@
import os
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

2
APP_Framework/Applications/knowing_app/mnist/.gitignore

@ -0,0 +1,2 @@
*.h5
*.tflite

BIN
APP_Framework/Applications/knowing_app/mnist/K210 mnist .png

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

4
APP_Framework/Applications/knowing_app/mnist/Kconfig

@ -0,0 +1,4 @@
config APP_MNIST
bool "enable apps/mnist"
depends on USING_TENSORFLOWLITEMICRO
default n

23
APP_Framework/Applications/knowing_app/mnist/README.md

@ -0,0 +1,23 @@
# MNIST 说明
要使用本例程,MCU RAM必须至少500K左右,所以本例程目前在K210上面验证过,stm32f407 目前在rtt上原则上只能采取dlmodule加载的方式。
![K210 mnist ](E:\XIUOS_FRAMEWORK\xiuos\APP_Framework\Applications\knowing_app\mnist\K210 mnist .png)
## 使用
tools/mnist-train.py 训练生成 mnist 模型。
tools/mnist-inference.py 使用 mnist 模型进行推理。
tools/mnist-c-model.py 将 mnist 模型转换成 C 的数组保存在 model.h 中。
tools/mnist-c-digit.py 将 mnist 数据集中的某个数字转成数组保存在 digit.h 中。
## 参考资料
https://tensorflow.google.cn/lite/performance/post_training_quantization
https://tensorflow.google.cn/lite/performance/post_training_integer_quant
https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/lite/micro/examples/hello_world/train/train_hello_world_model.ipynb

9
APP_Framework/Applications/knowing_app/mnist/SConscript

@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd]
group = DefineGroup('Applications', src, depend = ['APP_MNIST'], LOCAL_CPPPATH = CPPPATH)
Return('group')

31
APP_Framework/Applications/knowing_app/mnist/digit.h

@ -0,0 +1,31 @@
const float mnist_digit[] = {
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.33, 0.73, 0.62, 0.59, 0.24, 0.14, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.87, 1.00, 1.00, 1.00, 1.00, 0.95, 0.78, 0.78, 0.78, 0.78, 0.78, 0.78, 0.78, 0.78, 0.67, 0.20, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.26, 0.45, 0.28, 0.45, 0.64, 0.89, 1.00, 0.88, 1.00, 1.00, 1.00, 0.98, 0.90, 1.00, 1.00, 0.55, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.07, 0.26, 0.05, 0.26, 0.26, 0.26, 0.23, 0.08, 0.93, 1.00, 0.42, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.33, 0.99, 0.82, 0.07, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.09, 0.91, 1.00, 0.33, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.51, 1.00, 0.93, 0.17, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.23, 0.98, 1.00, 0.24, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.52, 1.00, 0.73, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.04, 0.80, 0.97, 0.23, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.49, 1.00, 0.71, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.29, 0.98, 0.94, 0.22, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.07, 0.87, 1.00, 0.65, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.01, 0.80, 1.00, 0.86, 0.14, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.15, 1.00, 1.00, 0.30, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.12, 0.88, 1.00, 0.45, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.52, 1.00, 1.00, 0.20, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.24, 0.95, 1.00, 1.00, 0.20, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.47, 1.00, 1.00, 0.86, 0.16, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.47, 1.00, 0.81, 0.07, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
};
const int mnist_label = 7;

94
APP_Framework/Applications/knowing_app/mnist/main.cpp

@ -0,0 +1,94 @@
#include <rtthread.h>
#include <stdio.h>
#include "tensorflow/lite/micro/all_ops_resolver.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/version.h"
#include "digit.h"
#include "model.h"
namespace {
tflite::ErrorReporter* error_reporter = nullptr;
const tflite::Model* model = nullptr;
tflite::MicroInterpreter* interpreter = nullptr;
TfLiteTensor* input = nullptr;
TfLiteTensor* output = nullptr;
constexpr int kTensorArenaSize = 110 * 1024;
uint8_t *tensor_arena = nullptr;
//uint8_t tensor_arena[kTensorArenaSize];
}
extern "C" void mnist_app() {
tflite::MicroErrorReporter micro_error_reporter;
error_reporter = &micro_error_reporter;
model = tflite::GetModel(mnist_model);
if (model->version() != TFLITE_SCHEMA_VERSION) {
TF_LITE_REPORT_ERROR(error_reporter,
"Model provided is schema version %d not equal "
"to supported version %d.",
model->version(), TFLITE_SCHEMA_VERSION);
return;
}
tensor_arena = (uint8_t *)rt_malloc(kTensorArenaSize);
if (tensor_arena == nullptr) {
TF_LITE_REPORT_ERROR(error_reporter, "malloc for tensor_arena failed");
return;
}
tflite::AllOpsResolver resolver;
tflite::MicroInterpreter static_interpreter(
model, resolver, tensor_arena, kTensorArenaSize, error_reporter);
interpreter = &static_interpreter;
// Allocate memory from the tensor_arena for the model's tensors.
TfLiteStatus allocate_status = interpreter->AllocateTensors();
if (allocate_status != kTfLiteOk) {
TF_LITE_REPORT_ERROR(error_reporter, "AllocateTensors() failed");
return;
}
input = interpreter->input(0);
output = interpreter->output(0);
printf("------- Input Digit -------\n");
for (int i = 0; i < 28; i++) {
for (int j = 0; j < 28; j++) {
if (mnist_digit[i*28+j] > 0.3)
printf("#");
else
printf(".");
}
printf("\n");
}
for (int i = 0; i < 28*28; i++) {
input->data.f[i] = mnist_digit[i];
}
TfLiteStatus invoke_status = interpreter->Invoke();
if (invoke_status != kTfLiteOk) {
TF_LITE_REPORT_ERROR(error_reporter, "Invoke failed on x_val\n");
return;
}
// Read the predicted y value from the model's output tensor
float max = 0.0;
int index;
for (int i = 0; i < 10; i++) {
if(output->data.f[i]>max){
max = output->data.f[i];
index = i;
}
}
printf("------- Output Result -------\n");
printf("result is %d\n", index);
}
extern "C" {
MSH_CMD_EXPORT(mnist_app, run mnist app);
}

31409
APP_Framework/Applications/knowing_app/mnist/model.h

File diff suppressed because it is too large

36
APP_Framework/Applications/knowing_app/mnist/tools/mnist-c-digit.py

@ -0,0 +1,36 @@
#!/usr/bin/env python3
import tensorflow as tf
print("TensorFlow version %s" % (tf.__version__))
def show(image):
for i in range(28):
for j in range(28):
if image[i][j] > 0.3:
print('#', end = '')
else:
print('.', end = '')
print()
digit_file_path = 'digit.h'
digit_content = '''const float mnist_digit[] = {
%s
};
const int mnist_label = %d;
'''
if __name__ == '__main__':
mnist = tf.keras.datasets.mnist
(_, _), (test_images, test_labels) = mnist.load_data()
index = 0
shape = 28
image = test_images[index].astype('float32')/255
label = test_labels[index]
print('label: %d' % label)
#show(image)
digit_data = (',\n ').join([ (', ').join([ '%.2f' % image[row][col] for col in range(shape)]) for row in range(shape)])
digit_file = open(digit_file_path, 'w')
digit_file.write(digit_content % (digit_data, label))
digit_file.close()

23
APP_Framework/Applications/knowing_app/mnist/tools/mnist-c-model.py

@ -0,0 +1,23 @@
#!/usr/bin/env python3
#tflite_file_path = 'mnist-default-quan.tflite'
tflite_file_path = 'mnist.tflite'
model_file_path = 'model.h'
tflite_file = open(tflite_file_path, 'rb')
tflite_data = tflite_file.read()
tflite_file.close()
tflite_array = [ '0x%02x' % byte for byte in tflite_data ]
model_content = '''unsigned char mnist_model[] = {
%s
};
unsigned int mnist_model_len = %d;
'''
# 12 bytes in a line, the same with xxd
bytes_of_line = 12
model_data = (',\n ').join([ (', ').join(tflite_array[i:i+bytes_of_line]) for i in range(0, len(tflite_array), bytes_of_line) ])
model_file = open(model_file_path, 'w')
model_file.write(model_content % (model_data, len(tflite_array)))
model_file.close()

40
APP_Framework/Applications/knowing_app/mnist/tools/mnist-inference.py

@ -0,0 +1,40 @@
#!/usr/bin/env python3
import tensorflow as tf
print("TensorFlow version %s" % (tf.__version__))
MODEL_NAME_H5 = 'mnist.h5'
MODEL_NAME_TFLITE = 'mnist.tflite'
DEFAULT_QUAN_MODEL_NAME_TFLITE = 'mnist-default-quan.tflite'
FULL_QUAN_MODEL_NAME_TFLITE = 'mnist-full-quan.tflite'
def show(image):
for i in range(28):
for j in range(28):
if image[i][j][0] > 0.3:
print('#', end = '')
else:
print(' ', end = '')
print()
if __name__ == '__main__':
mnist = tf.keras.datasets.mnist
(_, _), (test_images, test_labels) = mnist.load_data()
test_images = test_images.reshape(10000, 28, 28, 1)
index = 0
input_image = test_images[index].astype('float32')/255
target_label = test_labels[index]
interpreter = tf.lite.Interpreter(model_path = DEFAULT_QUAN_MODEL_NAME_TFLITE)
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()[0]
output_details = interpreter.get_output_details()[0]
interpreter.set_tensor(input_details['index'], [input_image])
interpreter.invoke()
output = interpreter.get_tensor(output_details['index'])[0]
show(input_image)
print('target label: %d, predict label: %d' % (target_label, output.argmax()))

109
APP_Framework/Applications/knowing_app/mnist/tools/mnist-train.py

@ -0,0 +1,109 @@
#!/usr/bin/env python3
import os
import tensorflow as tf
print("TensorFlow version %s" % (tf.__version__))
MODEL_NAME_H5 = 'mnist.h5'
MODEL_NAME_TFLITE = 'mnist.tflite'
DEFAULT_QUAN_MODEL_NAME_TFLITE = 'mnist-default-quan.tflite'
FULL_QUAN_MODEL_NAME_TFLITE = 'mnist-full-quan.tflite'
def build_model(model_name):
print('\n>>> load mnist dataset')
mnist = tf.keras.datasets.mnist
(train_images, train_labels),(test_images, test_labels) = mnist.load_data()
print("train images shape: ", train_images.shape)
print("train labels shape: ", train_labels.shape)
print("test images shape: ", test_images.shape)
print("test labels shape: ", test_labels.shape)
# transform label to categorical, like: 2 -> [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
print('\n>>> transform label to categorical')
train_labels = tf.keras.utils.to_categorical(train_labels)
test_labels = tf.keras.utils.to_categorical(test_labels)
print("train labels shape: ", train_labels.shape)
print("test labels shape: ", test_labels.shape)
# transform color like: [0, 255] -> 0.xxx
print('\n>>> transform image color into float32')
train_images = train_images.astype('float32') / 255
test_images = test_images.astype('float32') / 255
# reshape image like: (60000, 28, 28) -> (60000, 28, 28, 1)
print('\n>>> reshape image with color channel')
train_images = train_images.reshape((60000, 28, 28, 1))
test_images = test_images.reshape((10000, 28, 28, 1))
print("train images shape: ", train_images.shape)
print("test images shape: ", test_images.shape)
print('\n>>> build model')
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(32, (3, 3), activation=tf.nn.relu, input_shape=(28, 28, 1)),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(64, (3, 3), activation=tf.nn.relu),
tf.keras.layers.MaxPooling2D((2, 2)),
tf.keras.layers.Conv2D(64, (3, 3), activation=tf.nn.relu),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(64, activation=tf.nn.relu),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='rmsprop',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.summary()
print('\n>>> train the model')
early_stopping = tf.keras.callbacks.EarlyStopping(
monitor='loss', min_delta=0.0005, patience=3, verbose=1, mode='auto',
baseline=None, restore_best_weights=True
)
model.fit(train_images, train_labels, epochs=100, batch_size=64, callbacks=[early_stopping])
print('\n>>> evaluate the model')
test_loss, test_acc = model.evaluate(test_images, test_labels)
print("lost: %f, accuracy: %f" % (test_loss, test_acc))
print('\n>>> save the keras model as %s' % model_name)
model.save(model_name)
if __name__ == '__main__':
if not os.path.exists(MODEL_NAME_H5):
build_model(MODEL_NAME_H5)
if not os.path.exists(MODEL_NAME_TFLITE):
print('\n>>> save the tflite model as %s' % MODEL_NAME_TFLITE)
converter = tf.lite.TFLiteConverter.from_keras_model(tf.keras.models.load_model(MODEL_NAME_H5))
tflite_model = converter.convert()
with open(MODEL_NAME_TFLITE, "wb") as f:
f.write(tflite_model)
if not os.path.exists(DEFAULT_QUAN_MODEL_NAME_TFLITE):
print('\n>>> save the default quantized model as %s' % DEFAULT_QUAN_MODEL_NAME_TFLITE)
converter = tf.lite.TFLiteConverter.from_keras_model(tf.keras.models.load_model(MODEL_NAME_H5))
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_model = converter.convert()
with open(DEFAULT_QUAN_MODEL_NAME_TFLITE, "wb") as f:
f.write(tflite_model)
if not os.path.exists(FULL_QUAN_MODEL_NAME_TFLITE):
mnist = tf.keras.datasets.mnist
(train_images, _), (_, _) = mnist.load_data()
train_images = train_images.astype('float32') / 255
train_images = train_images.reshape((60000, 28, 28, 1))
def representative_data_gen():
for input_value in tf.data.Dataset.from_tensor_slices(train_images).batch(1).take(100):
yield [input_value]
print('\n>>> save the full quantized model as %s' % DEFAULT_QUAN_MODEL_NAME_TFLITE)
converter = tf.lite.TFLiteConverter.from_keras_model(tf.keras.models.load_model(MODEL_NAME_H5))
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_data_gen
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.uint8
converter.inference_output_type = tf.uint8
tflite_model = converter.convert()
with open(FULL_QUAN_MODEL_NAME_TFLITE, "wb") as f:
f.write(tflite_model)

2
APP_Framework/Framework/knowing/Kconfig

@ -3,5 +3,5 @@ menuconfig SUPPORT_KNOWING_FRAMEWORK
default y
if SUPPORT_KNOWING_FRAMEWORK
source "$APP_DIR/Framework/knowing/tensorflow-lite/Kconfig"
endif

14
APP_Framework/Framework/knowing/SConscript

@ -0,0 +1,14 @@
import os
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

24
APP_Framework/Framework/knowing/tensorflow-lite/Kconfig

@ -0,0 +1,24 @@
menuconfig USING_TENSORFLOWLITEMICRO
bool "Tensorflow Lite for Micro"
select RT_USING_CPLUSPLUS
default n
if USING_TENSORFLOWLITEMICRO
choice
prompt "Select Tensorflow Lite Operators Type"
default USING_TENSORFLOWLITEMICRO_NORMAL
config USING_TENSORFLOWLITEMICRO_NORMAL
bool "Using Tensorflow Lite normal operations"
config USING_TENSORFLOWLITEMICRO_CMSISNN
bool "Using Tensorflow Lite CMSIS NN operations"
endchoice
config USING_TENSORFLOWLITEMICRO_DEMOAPP
bool "Using tensorflow lite for micro demo app"
default n
endif

207
APP_Framework/Framework/knowing/tensorflow-lite/SConscript

@ -0,0 +1,207 @@
from building import *
import os
cwd = GetCurrentDir()
common = Split('''
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/all_ops_resolver.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/debug_log.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/memory_helpers.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/micro_allocator.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/micro_error_reporter.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/micro_interpreter.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/micro_profiler.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/micro_string.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/micro_time.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/micro_utils.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/recording_micro_allocator.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/recording_simple_memory_allocator.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/simple_memory_allocator.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/test_helpers.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/benchmarks/keyword_scrambled_model_data.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/memory_planner/greedy_memory_planner.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/memory_planner/linear_memory_planner.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/testing/test_conv_model.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/c/common.c
tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/error_reporter.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/flatbuffer_conversions.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/op_resolver.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/core/api/tensor_utils.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/internal/quantization_util.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/kernels/kernel_util.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/schema/schema_utils.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/activations.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/arg_min_max.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/ceil.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/circular_buffer.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/comparisons.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/concatenation.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/conv_test_common.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/dequantize.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/detection_postprocess.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/elementwise.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/ethosu.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/flexbuffers_generated_data.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/floor.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/hard_swish.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/kernel_runner.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/kernel_util.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/l2norm.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/logical.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/logistic.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/maximum_minimum.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/neg.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/pack.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/pad.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/prelu.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/quantize.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/quantize_common.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/reduce.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/reshape.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/resize_nearest_neighbor.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/round.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/shape.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/split.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/split_v.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/strided_slice.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/sub.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/svdf_common.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/tanh.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/transpose_conv.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/unpack.cc
''')
app = Split('''
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/examples/hello_world/main.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/examples/hello_world/main_functions.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/examples/hello_world/model.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/examples/hello_world/output_handler.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/examples/hello_world/constants.cc
''')
normal_ops = Split('''
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/add.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/conv.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/depthwise_conv.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/fully_connected.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/mul.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/pooling.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/softmax.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/normal/svdf.cc
''')
cmsis_ops = Split('''
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/add.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/conv.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/depthwise_conv.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/fully_connected.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/mul.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/pooling.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/softmax.cc
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/kernels/cmsis-nn/svdf.cc
''')
cmsis = Split('''
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_nn_activations_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_nn_activations_q7.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_relu6_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_relu_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_relu_q7.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/BasicMathFunctions/arm_elementwise_add_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/BasicMathFunctions/arm_elementwise_mul_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_w.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_x.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_y.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_z.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_1_x_n_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_1x1_HWC_q7_fast_nonsquare.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_1x1_s8_fast.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q15_basic.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q15_fast.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q15_fast_nonsquare.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_RGB.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_basic.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_basic_nonsquare.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_fast.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_fast_nonsquare.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_wrapper_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_3x3_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_s8_opt.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_u8_basic_ver1.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_wrapper_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_separable_conv_HWC_q7.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_separable_conv_HWC_q7_nonsquare.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_depthwise_conv_s8_core.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_q7_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_q7_q15_reordered.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_s8_s16.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_s8_s16_reordered.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_mat_q7_vec_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_mat_q7_vec_q15_opt.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q15_opt.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q7.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q7_opt.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_accumulate_q7_to_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_add_q7.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_depthwise_conv_nt_t_padded_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_depthwise_conv_nt_t_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mul_core_1x_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mult_nt_t_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mult_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mult_q7.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_vec_mat_mult_t_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nntables.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_no_shift.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_with_offset.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_with_offset.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/PoolingFunctions/arm_avgpool_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/PoolingFunctions/arm_max_pool_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/PoolingFunctions/arm_pool_q7_HWC.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ReshapeFunctions/arm_reshape_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SVDFunctions/arm_svdf_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_q15.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_q7.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_s8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_u8.c
tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_with_batch_q7.c
''')
CPPPATH = [
os.path.join(cwd, 'tensorflow-lite-for-mcu/source'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/patch'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/source/third_party/gemmlowp'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/source/third_party/flatbuffers/include'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/source/third_party/ruy'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/DSP/Include'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Include'),
os.path.join(cwd, 'tensorflow-lite-for-mcu/source/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/Core/Include'),
]
# embedded C++ std don't have some math functions, use global math functions instead
CPPDEFINES = ['TF_LITE_USE_GLOBAL_CMATH_FUNCTIONS', 'TF_LITE_USE_GLOBAL_MAX', 'TF_LITE_USE_GLOBAL_MIN']
src = []
if GetDepend(['USING_TENSORFLOWLITEMICRO_NORMAL']):
src += common + normal_ops
elif GetDepend(['USING_TENSORFLOWLITEMICRO_CMSISNN']):
CPPDEFINES += ['CMSIS_NN']
src += common + cmsis_ops + cmsis
if GetDepend(['USING_TENSORFLOWLITEMICRO_DEMOAPP']):
src += app
# building scripts don't support building LIBRARY with LOCAL FLAGS(like LOCAL_CPPDEFINES) currently
# so LIBRARY use GLOBAL FLAGS(like CPPDEFINES)
#group = DefineGroup('tensorflow-lite-for-mcu', src, depend = ['USING_TENSORFLOWLITEMICRO'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBRARY = True)
# static library link order matters, apps/mnist/main.o should be placed before libtensorflow.a, we should fix this later
group = DefineGroup('tensorflow-lite-for-mcu', src, depend = ['USING_TENSORFLOWLITEMICRO'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
Return('group')

1
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/.gitignore

@ -0,0 +1 @@
*.o

203
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/README.md

@ -0,0 +1,203 @@
# Tensorflow Lite for MCU
## 仓库说明
该仓库是由 tensorflow 仓库生成:
```
# 生成源码项目
# 不指定 'hello_world' 则生成 hello_world/image_recognition/micro_speech/... 等多个项目
# 不指定 'make' 则生成 arduino、esp-idf、keil、make、mbed 等多个工程
# 生成结果在 tensorflow/tensorflow/lite/micro/tools/make/gen/osx_x86_64/prj/hello_world/make
# 以下指令生成 hello_world 的源码项目,其中算子使用常规算子
make -f tensorflow/lite/micro/tools/make/Makefile generate_hello_world_make_project
# 以下指令生成 针对 arm cortex-m 平台使用 cmsis 算子优化的源码项目,详见 tensorflow 仓库的 tensorflow/tensorflow/lite/micro/kernels/cmsis-nn/README.md
make -f tensorflow/lite/micro/tools/make/Makefile TAGS=cmsis-nn generate_hello_world_make_project
```
当前使用的 tensorflow 版本为:`e30e1d1aedb` (2021-01-07)。
我们在其他平台使用常规算子,在 cortex-m 平台使用 cmsis 优化算子,需要将上述生成的两个源码项目整合起来,具体代码如何融合,见本文最后文件列表。
## 问题说明
### 问题一:缺少头文件路径
tensorflow生成的源码项目中的 makefile 的头文件路径是不全的,需要添加以下头文件路径:
```
/tensorflow/lite/micro/tools/make/downloads/cmsis
/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/DSP/Include
/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Include
/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/Core/Include
```
### 问题二:cmsis 缺少头文件
tensorflow生成的项目缺少 cmsis_gcc.h 头文件,我们将该文件放在了 patch/cmsis_gcc.h。
## 文件列表
```
# 共有文件
tensorflow/lite/micro/all_ops_resolver.cc
tensorflow/lite/micro/debug_log.cc
tensorflow/lite/micro/memory_helpers.cc
tensorflow/lite/micro/micro_allocator.cc
tensorflow/lite/micro/micro_error_reporter.cc
tensorflow/lite/micro/micro_interpreter.cc
tensorflow/lite/micro/micro_profiler.cc
tensorflow/lite/micro/micro_string.cc
tensorflow/lite/micro/micro_time.cc
tensorflow/lite/micro/micro_utils.cc
tensorflow/lite/micro/recording_micro_allocator.cc
tensorflow/lite/micro/recording_simple_memory_allocator.cc
tensorflow/lite/micro/simple_memory_allocator.cc
tensorflow/lite/micro/test_helpers.cc
tensorflow/lite/micro/benchmarks/keyword_scrambled_model_data.cc
tensorflow/lite/micro/memory_planner/greedy_memory_planner.cc
tensorflow/lite/micro/memory_planner/linear_memory_planner.cc
tensorflow/lite/micro/testing/test_conv_model.cc
tensorflow/lite/c/common.c
tensorflow/lite/core/api/error_reporter.cc
tensorflow/lite/core/api/flatbuffer_conversions.cc
tensorflow/lite/core/api/op_resolver.cc
tensorflow/lite/core/api/tensor_utils.cc
tensorflow/lite/kernels/internal/quantization_util.cc
tensorflow/lite/kernels/kernel_util.cc
tensorflow/lite/schema/schema_utils.cc
tensorflow/lite/micro/kernels/activations.cc
tensorflow/lite/micro/kernels/arg_min_max.cc
tensorflow/lite/micro/kernels/ceil.cc
tensorflow/lite/micro/kernels/circular_buffer.cc
tensorflow/lite/micro/kernels/comparisons.cc
tensorflow/lite/micro/kernels/concatenation.cc
tensorflow/lite/micro/kernels/conv_test_common.cc
tensorflow/lite/micro/kernels/dequantize.cc
tensorflow/lite/micro/kernels/detection_postprocess.cc
tensorflow/lite/micro/kernels/elementwise.cc
tensorflow/lite/micro/kernels/ethosu.cc
tensorflow/lite/micro/kernels/flexbuffers_generated_data.cc
tensorflow/lite/micro/kernels/floor.cc
tensorflow/lite/micro/kernels/hard_swish.cc
tensorflow/lite/micro/kernels/kernel_runner.cc
tensorflow/lite/micro/kernels/kernel_util.cc
tensorflow/lite/micro/kernels/l2norm.cc
tensorflow/lite/micro/kernels/logical.cc
tensorflow/lite/micro/kernels/logistic.cc
tensorflow/lite/micro/kernels/maximum_minimum.cc
tensorflow/lite/micro/kernels/neg.cc
tensorflow/lite/micro/kernels/pack.cc
tensorflow/lite/micro/kernels/pad.cc
tensorflow/lite/micro/kernels/prelu.cc
tensorflow/lite/micro/kernels/quantize.cc
tensorflow/lite/micro/kernels/quantize_common.cc
tensorflow/lite/micro/kernels/reduce.cc
tensorflow/lite/micro/kernels/reshape.cc
tensorflow/lite/micro/kernels/resize_nearest_neighbor.cc
tensorflow/lite/micro/kernels/round.cc
tensorflow/lite/micro/kernels/shape.cc
tensorflow/lite/micro/kernels/split.cc
tensorflow/lite/micro/kernels/split_v.cc
tensorflow/lite/micro/kernels/strided_slice.cc
tensorflow/lite/micro/kernels/sub.cc
tensorflow/lite/micro/kernels/svdf_common.cc
tensorflow/lite/micro/kernels/tanh.cc
tensorflow/lite/micro/kernels/transpose_conv.cc
tensorflow/lite/micro/kernels/unpack.cc
tensorflow/lite/micro/examples/hello_world/main.cc
tensorflow/lite/micro/examples/hello_world/main_functions.cc
tensorflow/lite/micro/examples/hello_world/model.cc
tensorflow/lite/micro/examples/hello_world/output_handler.cc
tensorflow/lite/micro/examples/hello_world/constants.cc
# 常规算子,将这些文件移入 tensorflow/lite/micro/kernels/normal 中
tensorflow/lite/micro/kernels/add.cc
tensorflow/lite/micro/kernels/conv.cc
tensorflow/lite/micro/kernels/depthwise_conv.cc
tensorflow/lite/micro/kernels/fully_connected.cc
tensorflow/lite/micro/kernels/mul.cc
tensorflow/lite/micro/kernels/pooling.cc
tensorflow/lite/micro/kernels/softmax.cc
tensorflow/lite/micro/kernels/svdf.cc
# cmsis 优化算子
tensorflow/lite/micro/kernels/cmsis-nn/add.cc
tensorflow/lite/micro/kernels/cmsis-nn/conv.cc
tensorflow/lite/micro/kernels/cmsis-nn/depthwise_conv.cc
tensorflow/lite/micro/kernels/cmsis-nn/fully_connected.cc
tensorflow/lite/micro/kernels/cmsis-nn/mul.cc
tensorflow/lite/micro/kernels/cmsis-nn/pooling.cc
tensorflow/lite/micro/kernels/cmsis-nn/softmax.cc
tensorflow/lite/micro/kernels/cmsis-nn/svdf.cc
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_nn_activations_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_nn_activations_q7.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_relu6_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_relu_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ActivationFunctions/arm_relu_q7.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/BasicMathFunctions/arm_elementwise_add_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/BasicMathFunctions/arm_elementwise_mul_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_w.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_x.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_y.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConcatenationFunctions/arm_concatenation_s8_z.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_1_x_n_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_1x1_HWC_q7_fast_nonsquare.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_1x1_s8_fast.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q15_basic.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q15_fast.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q15_fast_nonsquare.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_RGB.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_basic.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_basic_nonsquare.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_fast.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_HWC_q7_fast_nonsquare.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_wrapper_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_3x3_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_s8_opt.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_u8_basic_ver1.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_conv_wrapper_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_separable_conv_HWC_q7.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_depthwise_separable_conv_HWC_q7_nonsquare.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_depthwise_conv_s8_core.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_q7_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_q7_q15_reordered.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_s8_s16.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_s8_s16_reordered.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_mat_q7_vec_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_mat_q7_vec_q15_opt.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q15_opt.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q7.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_q7_opt.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/FullyConnectedFunctions/arm_fully_connected_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_accumulate_q7_to_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_add_q7.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_depthwise_conv_nt_t_padded_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_depthwise_conv_nt_t_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mul_core_1x_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mul_core_4x_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mult_nt_t_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mult_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mult_q7.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_vec_mat_mult_t_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nntables.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_no_shift.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_with_offset.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_with_offset.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/PoolingFunctions/arm_avgpool_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/PoolingFunctions/arm_max_pool_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/PoolingFunctions/arm_pool_q7_HWC.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ReshapeFunctions/arm_reshape_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SVDFunctions/arm_svdf_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_q15.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_q7.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_s8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_u8.c
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_with_batch_q7.c
```

2171
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/patch/cmsis_gcc.h

File diff suppressed because it is too large

203
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/LICENSE

@ -0,0 +1,203 @@
Copyright 2019 The TensorFlow Authors. All rights reserved.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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
http://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.

57
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/Makefile

File diff suppressed because one or more lines are too long

29
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/README_MAKE.md

@ -0,0 +1,29 @@
# TensorFlow Lite Micro Make Project
This folder has been autogenerated by TensorFlow, and contains source, header,
and project files needed to build a single TensorFlow Lite Micro target using
the make tool.
## Usage
To build this, run:
```
make
```
This should attempt to build the target locally on your platform, using the
standard Makefile variables like CFLAGS, CC, CXX, and so on.
## Project Generation
See
[tensorflow/lite/micro](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/micro)
for details on how projects like this can be generated from the main source
tree.
## License
TensorFlow's code is covered by the Apache2 License included in the repository,
and third party dependencies are covered by their respective licenses, in the
third_party folder of this package.

139
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/core/public/version.h

@ -0,0 +1,139 @@
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
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
http://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.
==============================================================================*/
#ifndef TENSORFLOW_CORE_PUBLIC_VERSION_H_
#define TENSORFLOW_CORE_PUBLIC_VERSION_H_
// TensorFlow uses semantic versioning, see http://semver.org/.
// Also update tensorflow/tensorflow.bzl and
// tensorflow/tools/pip_package/setup.py
#define TF_MAJOR_VERSION 2
#define TF_MINOR_VERSION 5
#define TF_PATCH_VERSION 0
// TF_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1",
// "-beta", "-rc", "-rc.1")
#define TF_VERSION_SUFFIX ""
#define TF_STR_HELPER(x) #x
#define TF_STR(x) TF_STR_HELPER(x)
// e.g. "0.5.0" or "0.6.0-alpha".
#define TF_VERSION_STRING \
(TF_STR(TF_MAJOR_VERSION) "." TF_STR(TF_MINOR_VERSION) "." TF_STR( \
TF_PATCH_VERSION) TF_VERSION_SUFFIX)
// GraphDef compatibility versions (the versions field in graph.proto).
//
// Each graph has producer and min_consumer versions, and each
// consumer has its own version and a min_producer. In addition, graphs can
// mark specific consumer versions as bad (to prevent bugs from executing).
// A consumer will execute a graph if the consumer's version is at least the
// graph's min_consumer, the graph's producer version is at least the consumer's
// min_producer, and the consumer version isn't specifically disallowed by the
// graph.
//
// By default, newly created graphs have producer version TF_GRAPH_DEF_VERSION
// min_consumer TF_GRAPH_DEF_MIN_CONSUMER, and no other bad consumer versions.
//
// Version history:
//
// 0. Graphs created before GraphDef versioning
// 1. First real version (2dec2015)
// 2. adjust_contrast only takes float, doesn't perform clamping (11dec2015)
// 3. Remove TileGrad, since it was equivalent to reduce_sum (30dec2015)
// 4. When support for this version is removed, we can safely make AttrValue
// parsing more strict with respect to empty list values (see
// 111635679, 7jan2016).
// 5. Graphs are wholly-validated during Session::Create() (7jan2016).
// 6. TensorFlow is scalar strict within Google (27jan2016).
// 7. Remove TopK in favor of TopKV2 (5feb2016).
// 8. Replace RandomCrop from C++ with pure Python (5feb2016).
// 9. Deprecate batch_norm_with_global_normalization (16feb2016).
// 10. Deprecate conv3d_backprop_{filter,input} (10jun2016).
// 11. Deprecate {batch}_self_adjoint_eig (3aug2016).
// 12. Graph consumers understand the node_def field of FunctionDef (22aug2016).
// 13. Deprecate multiple batch linear algebra ops (9sep2016).
// 14. Deprecate batch_matrix_* ops. (10sep2016).
// 15. Deprecate batch_fft_* ops. (14sep2016).
// 16. Deprecate tensor_array (v1) ops in favor of v2 (10nov2016).
// 17. Deprecate inv (11nov2016).
// 17. Expose reverse_v2 (10nov2016)
// 18. Add VariableV2 (30nov2016)
// 19. Deprecated ops created by models moved out of core SkipGram, NegTrain.
// (08dec2016)
// 20. Catch all version 1.0 changes to Python API generation. SplitV is now
// used for tf.split, ReverseV2 is now used by tf.reverse, ConcatV2 is
// now used by tf.concat. Graphs use flooring
// division and mod semantics. TensorArrayV3. (12dec2016)
// Also considered the version for when it is required for reduction
// ops' indices to be scalar or vector, and not higher rank.
// Some earlier graph def versions allowed this.
// 21. Dropped FunctionDef.Node support, switched to node_def introduced
// in version 12. (11jan2017)
// 22. Placeholder now can specify and enforce scalar and partial
// shapes, particularly when restoring a graph from GraphDef
// produced at version 22 or later. (04/10/2016)
// 23. Remove NonMaxSuppression in favor of NonMaxSuppressionV2.
// 24. Deprecate lookup ops (v1) ops in favor of v2 (30may2017)
// 25. Deprecate stack (v1) ops in favor of v2 (2017/6/15).
// 25. Deprecate RandomPoisson (v1) ops in favor of v2 (2017/10/25).
// 26. Add a bool 'stripped_default_attrs' to MetaInfoDef indicating
// whether default-valued attrs have been stripped from the nodes in the
// GraphDef. (7dec2017)
// 27. Deprecate TensorArray ops v2 in favor of v3 and deprecated io_ops
// deprecated in favor of V2 ops. (2018/01/23)
// 28. Deprecate MatrixExponential op in favor of Python implementation.
// (2018/08/21).
// (2019/02/15). Added `control_ret` field to FunctionDef proto, and
// `control_output` field to OpDef proto.
// 29. Deprecate StatefulStandardNormal op in favor of StatefulStandardNormalV2.
// (2019/03/25).
// (2019/04/17). Added `arg_attr` field to FunctionDefProto.
// 30. (2019/05/09) First date based GraphDef version. GraphDef
// versions advance by 1 each day after this point.
#define TF_GRAPH_DEF_VERSION_MIN_PRODUCER 0
#define TF_GRAPH_DEF_VERSION_MIN_CONSUMER 0
#define TF_GRAPH_DEF_VERSION 639 // Updated: 2021/1/7
// Checkpoint compatibility versions (the versions field in SavedSliceMeta).
//
// The checkpoint versions have the same semantics as GraphDef versions, but the
// numbering scheme is separate. We have no plans to ever deprecate checkpoint
// versions, but it's good to have this in place in case we ever need to.
//
// Version history:
//
// 0. Checkpoints saved before checkpoint versioning.
// 1. First real version (10feb2015).
#define TF_CHECKPOINT_VERSION_MIN_PRODUCER 0
#define TF_CHECKPOINT_VERSION_MIN_CONSUMER 0
#define TF_CHECKPOINT_VERSION 1
/// Version query functions (defined in generated version_info.cc)
// Host compiler version (declared elsewhere to be __VERSION__)
extern const char* tf_compiler_version();
// The git commit designator when tensorflow was built
// If no git repository, this will be "internal".
extern const char* tf_git_version();
// Value of the _GLIBCXX_USE_CXX11_ABI flag, or 0 if it's not set.
extern int tf_cxx11_abi_flag();
// Returns 1 if build is monolithic, or 0 otherwise.
extern int tf_monolithic_build();
#endif // TENSORFLOW_CORE_PUBLIC_VERSION_H_

484
APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/c/builtin_op_data.h

@ -0,0 +1,484 @@
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
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
http://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.
==============================================================================*/
#ifndef TENSORFLOW_LITE_C_BUILTIN_OP_DATA_H_
#define TENSORFLOW_LITE_C_BUILTIN_OP_DATA_H_
#include <stdint.h>
#include "tensorflow/lite/c/common.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// TfLiteReshapeParams can't have dynamic data so we fix the maximum possible
// number of dimensions.
#define TFLITE_RESHAPE_PARAMS_MAX_DIMENSION_COUNT 8
// TODO(aselle): Consider using "if this then that" for testing.
// Useful placeholder to put in otherwise empty structs to avoid size warnings.
typedef struct {
char dummy;
} EmptyStructPlaceholder;
// IMPORTANT: All new members of structs must be added at the end to ensure
// backwards compatibility.
// Possible padding types (for convolutions)
typedef enum {
kTfLitePaddingUnknown = 0,
kTfLitePaddingSame,
kTfLitePaddingValid,
} TfLitePadding;
typedef enum {
kTfLiteMirrorPaddingUnknown = 0,
kTfLiteMirrorPaddingReflect,
kTfLiteMirrorPaddingSymmetric,
} TfLiteMirrorPaddingMode;
// TODO(b/130259536): We should move this out of builtin_op_data.
typedef struct {
int width;
int height;
int width_offset;
int height_offset;
} TfLitePaddingValues;
typedef struct {
TfLiteMirrorPaddingMode mode;
} TfLiteMirrorPaddingParams;
// Possible fused activation functions.
// TODO(aselle): rename to TfLiteActivation
typedef enum {
kTfLiteActNone = 0,
kTfLiteActRelu,
kTfLiteActReluN1To1, // min(max(-1, x), 1)
kTfLiteActRelu6, // min(max(0, x), 6)
kTfLiteActTanh,
kTfLiteActSignBit,
kTfLiteActSigmoid,
} TfLiteFusedActivation;
typedef struct {
// Parameters for CONV_2D version 1.
TfLitePadding padding;
int stride_width;
int stride_height;
TfLiteFusedActivation activation;
// Parameters for CONV_2D version 2.
// Note: Version 2 supports dilation values not equal to 1.
int dilation_width_factor;
int dilation_height_factor;
} TfLiteConvParams;