{"id":96004,"date":"2026-08-27T10:16:29","date_gmt":"2026-08-27T02:16:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/96004.html"},"modified":"2026-08-27T10:16:29","modified_gmt":"2026-08-27T02:16:29","slug":"%e8%bd%bb%e6%9d%be%e5%ad%a6%e4%b9%a0tflm_day8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/96004.html","title":{"rendered":"\u8f7b\u677e\u5b66\u4e60TFLM_day8"},"content":{"rendered":"<p>\u6458\u8981&#xff1a;\u672c\u6587\u628a\u524d 7 \u5929\u5b66\u5230\u7684 TFLM \u77e5\u8bc6\u6574\u7406\u6210\u4e00\u4efd\u53ef\u6267\u884c\u7684\u5de5\u7a0b\u8ba1\u5212&#xff0c;\u6307\u5bfc\u5982\u4f55\u8ba9\u4e00\u9897\u65b0\u7684 MCU\u3001DSP\u3001NPU \u6216 AI accelerator \u7a33\u5b9a\u8fd0\u884c TFLM \u5e76\u9010\u6b65\u83b7\u5f97\u53ef\u91cf\u5316\u7684\u6027\u80fd\u6536\u76ca\u3002\u6838\u5fc3\u539f\u5219\u662f\u300c\u5148\u8dd1\u901a reference&#xff0c;\u518d\u63a5\u5165\u4f18\u5316&#xff0c;\u6700\u540e\u7528\u6a21\u578b\u548c benchmark \u8bc1\u660e\u6536\u76ca\u300d\u3002\u6587\u7ae0\u6309 8 \u4e2a\u9636\u6bb5\u5c55\u5f00&#xff1a;\u4ece\u9700\u6c42\u4e0e baseline\u3001\u5e73\u53f0 bring-up\u3001reference \u6a21\u578b\u95ed\u73af\u3001NN library \u8fb9\u754c&#xff0c;\u5230\u7b2c\u4e00\u4e2a optimized kernel\u3001\u6269\u5c55\u70ed\u70b9 op\u3001\u5185\u5b58\u4e0e\u7a33\u5b9a\u6027&#xff0c;\u518d\u5230 CI \u4e0e\u7248\u672c\u7ef4\u62a4&#xff0c;\u5e76\u4e3a\u6bcf\u4e2a\u9636\u6bb5\u7ed9\u51fa\u76ee\u6807\u3001\u5de5\u4f5c\u9879\u3001\u4ea4\u4ed8\u7269\u548c\u5b8c\u6210\u6761\u4ef6&#xff0c;\u6700\u540e\u8865\u5145\u89d2\u8272\u5206\u5de5\u3001\u98ce\u9669\u5e94\u5bf9\u3001\u9a8c\u6536\u6807\u51c6\u4e0e\u6700\u5c0f\u53ef\u6267\u884c\u8def\u7ebf\u56fe\u3002<\/p>\n<h2>\u8f7b\u677e\u5b66\u4e60 TFLM Day 8&#xff1a;AI \u82af\u7247\u63a5\u5165 TFLM \u7684\u5de5\u7a0b\u8ba1\u5212<\/h2>\n<p>Day 1 \u5230 Day 7&#xff0c;\u6211\u4eec\u4f9d\u6b21\u5b66\u4e60\u4e86 TFLM \u7684\u8fd0\u884c\u65f6\u3001\u8c03\u7528\u94fe\u3001\u5185\u5b58\u3001kernel\u3001\u540e\u7aef\u76ee\u5f55\u3001\u6a21\u578b op \u5206\u6790&#xff0c;\u4ee5\u53ca\u628a .tflite \u6a21\u578b\u63a5\u5165\u793a\u4f8b\u3002<\/p>\n<p>\u4eca\u5929\u628a\u8fd9\u4e9b\u77e5\u8bc6\u6574\u7406\u6210\u4e00\u4efd\u53ef\u4ee5\u6267\u884c\u7684\u5de5\u7a0b\u8ba1\u5212&#xff1a;<\/p>\n<p>\u5982\u4f55\u8ba9\u4e00\u9897\u65b0\u7684 MCU\u3001DSP\u3001NPU \u6216 AI accelerator \u7a33\u5b9a\u5730\u8fd0\u884c TFLM&#xff0c;\u5e76\u9010\u6b65\u83b7\u5f97\u53ef\u91cf\u5316\u7684\u6027\u80fd\u6536\u76ca&#xff1f;<\/p>\n<p>\u6838\u5fc3\u539f\u5219\u53ea\u6709\u4e00\u53e5\u8bdd&#xff1a;<\/p>\n<p>\u5148\u8dd1\u901a reference&#xff0c;\u518d\u63a5\u5165\u4f18\u5316&#xff0c;\u6700\u540e\u7528\u6a21\u578b\u548c benchmark \u8bc1\u660e\u6536\u76ca\u3002<\/p>\n<h3>1. \u9879\u76ee\u76ee\u6807\u548c\u8fb9\u754c<\/h3>\n<h4>1.1 \u6700\u7ec8\u76ee\u6807<\/h4>\n<p>\u5b8c\u6210\u540e&#xff0c;\u76ee\u6807\u5e73\u53f0\u5e94\u80fd\u591f&#xff1a;<\/p>\n<li>\u7f16\u8bd1 TFLM \u9759\u6001\u5e93\u548c\u76ee\u6807\u5e73\u53f0\u5e94\u7528\u3002<\/li>\n<li>\u52a0\u8f7d\u81f3\u5c11\u4e00\u4e2a .tflite \u6a21\u578b\u3002<\/li>\n<li>\u4f7f\u7528\u9759\u6001 tensor_arena \u5b8c\u6210 AllocateTensors()\u3002<\/li>\n<li>\u8c03\u7528 Invoke() \u83b7\u5f97\u6b63\u786e\u8f93\u51fa\u3002<\/li>\n<li>\u901a\u8fc7 UART\u3001RTT \u6216\u5e73\u53f0\u65e5\u5fd7\u89c2\u5bdf\u8fd0\u884c\u72b6\u6001\u3002<\/li>\n<li>\u6d4b\u91cf\u5355\u7b97\u5b50\u548c\u6574\u6a21\u578b latency\u3002<\/li>\n<li>\u6309\u9700\u5c06\u70ed\u70b9 op \u66ff\u6362\u4e3a\u82af\u7247\u4f18\u5316\u5b9e\u73b0\u3002<\/li>\n<li>\u5728 reference \u4e0e optimized \u4e4b\u95f4\u8fdb\u884c\u6b63\u786e\u6027\u548c\u6027\u80fd\u5bf9\u6bd4\u3002<\/li>\n<h4>1.2 \u4e0d\u5c5e\u4e8e\u7b2c\u4e00\u9636\u6bb5\u7684\u5185\u5bb9<\/h4>\n<p>\u4ee5\u4e0b\u5185\u5bb9\u4e0d\u8981\u4f5c\u4e3a\u9879\u76ee\u7b2c\u4e00\u6b65&#xff1a;<\/p>\n<ul>\n<li>\u4e00\u5f00\u59cb\u5c31\u652f\u6301\u6240\u6709 TFLM op\u3002<\/li>\n<li>\u4e00\u5f00\u59cb\u5c31\u5b9e\u73b0\u5b8c\u6574 graph compiler\u3002<\/li>\n<li>\u4e00\u5f00\u59cb\u5c31\u91cd\u5199 TFLM reference kernel\u3002<\/li>\n<li>\u6ca1\u6709 baseline \u5c31\u58f0\u79f0\u786c\u4ef6\u52a0\u901f\u6709\u6548\u3002<\/li>\n<li>\u53ea\u6d4b\u8bd5\u4e00\u4e2a\u8f93\u5165\u5c31\u5ba3\u5e03\u6a21\u578b\u517c\u5bb9\u3002<\/li>\n<\/ul>\n<p>TFLM \u7684 reference kernel \u662f\u6b63\u786e\u6027\u57fa\u7ebf\u3002\u82af\u7247\u4f18\u5316\u5e94\u653e\u5728\u76ee\u6807\u5e73\u53f0 kernel \u5b50\u76ee\u5f55\u4e2d&#xff0c;\u800c\u4e0d\u662f\u7834\u574f\u5171\u4eab\u7684 reference \u5b9e\u73b0\u3002<\/p>\n<h3>2. \u63a8\u8350\u7684\u603b\u4f53\u67b6\u6784<\/h3>\n<p>\u7528\u6237\u5e94\u7528<br \/>\n  |<br \/>\n  v<br \/>\nTFLM MicroInterpreter<br \/>\n  |<br \/>\n  v<br \/>\nMicroMutableOpResolver<br \/>\n  |<br \/>\n  v<br \/>\nyour_chip optimized kernels<br \/>\n  |<br \/>\n  v<br \/>\nyour_chip NN library \/ driver<br \/>\n  |<br \/>\n  v<br \/>\nNPU \/ DSP \/ AI accelerator<\/p>\n<p>\u5efa\u8bae\u628a\u5de5\u7a0b\u62c6\u6210\u4e09\u4e2a\u72ec\u7acb\u6a21\u5757&#xff1a;<\/p>\n<table>\n<tr>\u6a21\u5757\u4e3b\u8981\u804c\u8d23<\/tr>\n<tbody>\n<tr>\n<td>\u5e73\u53f0\u9002\u914d<\/td>\n<td>\u5de5\u5177\u94fe\u3001\u542f\u52a8\u3001\u65e5\u5fd7\u3001\u8ba1\u65f6\u3001\u7cfb\u7edf\u521d\u59cb\u5316\u3001\u94fe\u63a5\u811a\u672c\u3002<\/td>\n<\/tr>\n<tr>\n<td>TFLM \u540e\u7aef<\/td>\n<td>conv.cc\u3001fully_connected.cc \u7b49\u8584 wrapper\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u82af\u7247\u8f6f\u4ef6\u6808<\/td>\n<td>NN library\u3001driver\u3001firmware\u3001DMA\u3001cache \u548c\u786c\u4ef6\u547d\u4ee4\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>NN library \u4e0d\u5fc5\u5b8c\u5168\u9075\u5faa TFLM \u7684\u4ee3\u7801\u98ce\u683c&#xff0c;\u4e5f\u53ef\u4ee5\u72ec\u7acb\u53d1\u5e03\u548c\u6d4b\u8bd5\u3002TFLM wrapper \u53ea\u8d1f\u8d23 tensor\u3001shape\u3001\u91cf\u5316\u53c2\u6570\u548c\u72b6\u6001\u7801\u4e4b\u95f4\u7684\u8f6c\u6362\u3002<\/p>\n<h3>3. \u9879\u76ee\u9636\u6bb5\u603b\u89c8<\/h3>\n<p>\u9636\u6bb5 0 \u9700\u6c42\u548c\u57fa\u7ebf<br \/>\n   |<br \/>\n\u9636\u6bb5 1 \u5e73\u53f0 bring-up<br \/>\n   |<br \/>\n\u9636\u6bb5 2 reference \u6a21\u578b\u95ed\u73af<br \/>\n   |<br \/>\n\u9636\u6bb5 3 \u82af\u7247 NN library \u8fb9\u754c<br \/>\n   |<br \/>\n\u9636\u6bb5 4 \u7b2c\u4e00\u4e2a\u4f18\u5316 kernel<br \/>\n   |<br \/>\n\u9636\u6bb5 5 \u6269\u5c55\u70ed\u70b9 op<br \/>\n   |<br \/>\n\u9636\u6bb5 6 \u6027\u80fd\u3001\u5185\u5b58\u548c\u7a33\u5b9a\u6027<br \/>\n   |<br \/>\n\u9636\u6bb5 7 CI\u3001\u53d1\u5e03\u548c\u7248\u672c\u7ef4\u62a4<\/p>\n<p>\u6bcf\u4e2a\u9636\u6bb5\u90fd\u5fc5\u987b\u6709\u201c\u5b8c\u6210\u6761\u4ef6\u201d\u3002\u6ca1\u6709\u901a\u8fc7\u5f53\u524d\u9636\u6bb5\u7684\u9a8c\u8bc1&#xff0c;\u5c31\u4e0d\u8981\u628a\u95ee\u9898\u5e26\u5230\u4e0b\u4e00\u9636\u6bb5\u3002<\/p>\n<h3>4. \u9636\u6bb5 0&#xff1a;\u9700\u6c42\u3001\u6a21\u578b\u548c baseline<\/h3>\n<h4>\u76ee\u6807<\/h4>\n<p>\u786e\u5b9a\u82af\u7247\u3001\u8f6f\u4ef6\u73af\u5883\u3001\u76ee\u6807\u6a21\u578b\u548c\u53ef\u590d\u73b0\u7684 reference \u6570\u636e\u3002<\/p>\n<h4>\u5de5\u4f5c\u9879<\/h4>\n<li>\u786e\u5b9a\u76ee\u6807\u82af\u7247\u578b\u53f7\u3001\u6838\u5fc3\u3001\u65f6\u949f\u548c\u5185\u5b58\u5e03\u5c40\u3002<\/li>\n<li>\u786e\u8ba4 C&#043;&#043;17 \u5de5\u5177\u94fe\u3001SDK\u3001IDE \u548c\u94fe\u63a5\u5668\u7248\u672c\u3002<\/li>\n<li>\u9009\u62e9\u4e00\u5230\u4e09\u4e2a\u4ee3\u8868\u6027 .tflite \u6a21\u578b\u3002<\/li>\n<li>\u7528 Day 6 \u7684\u5de5\u5177\u627e\u51fa\u6bcf\u4e2a\u6a21\u578b\u7684\u552f\u4e00 op\u3002<\/li>\n<li>\u8bb0\u5f55\u6a21\u578b\u8f93\u5165\u3001\u8f93\u51fa\u3001\u7c7b\u578b\u3001shape \u548c\u91cf\u5316\u53c2\u6570\u3002<\/li>\n<li>\u5728 host \u4e0a\u4fdd\u5b58 reference \u8f93\u51fa\u548c\u6d4b\u8bd5\u8f93\u5165\u3002<\/li>\n<li>\u5b9a\u4e49 latency\u3001arena\u3001\u4ee3\u7801\u4f53\u79ef\u548c\u529f\u8017\u7684\u6d4b\u91cf\u65b9\u6cd5\u3002<\/li>\n<h4>\u4ea4\u4ed8\u7269<\/h4>\n<p>requirements.md<br \/>\nmodels\/<br \/>\n  model_a.tflite<br \/>\n  model_b.tflite<br \/>\nbaseline\/<br \/>\n  input_data.*<br \/>\n  reference_output.*<br \/>\nbenchmark_definition.md<\/p>\n<h4>\u5b8c\u6210\u6761\u4ef6<\/h4>\n<p>[ ] \u6bcf\u4e2a\u76ee\u6807\u6a21\u578b\u90fd\u6709\u660e\u786e\u8f93\u5165\u548c\u8f93\u51fa<br \/>\n[ ] \u6bcf\u4e2a\u6a21\u578b\u7684 op \u96c6\u5408\u5df2\u7ecf\u786e\u8ba4<br \/>\n[ ] host reference \u8f93\u51fa\u53ef\u4ee5\u91cd\u590d\u5f97\u5230<br \/>\n[ ] latency \u548c\u5185\u5b58\u7684\u6d4b\u91cf\u65b9\u6cd5\u5df2\u7ecf\u786e\u5b9a<\/p>\n<p>\u4e0d\u8981\u53ea\u9009\u62e9\u4e00\u4e2a\u201c\u6700\u5bb9\u6613\u8dd1\u201d\u7684\u6a21\u578b\u3002\u81f3\u5c11\u5e94\u5305\u542b\u4e00\u4e2a\u5c0f\u6a21\u578b\u7528\u4e8e bring-up&#xff0c;\u4ee5\u53ca\u4e00\u4e2a\u80fd\u4ee3\u8868\u5b9e\u9645\u4e1a\u52a1\u8d1f\u8f7d\u7684\u6a21\u578b\u7528\u4e8e\u6027\u80fd\u8bc4\u4f30\u3002<\/p>\n<h3>5. \u9636\u6bb5 1&#xff1a;\u5e73\u53f0 bring-up<\/h3>\n<p>TFLM \u5b98\u65b9\u5efa\u8bae\u5148\u4e0d\u63a5\u786c\u4ef6\u4f18\u5316&#xff0c;\u4f7f\u7528 reference kernel \u5efa\u7acb\u5e73\u53f0\u8fd0\u884c\u73af\u5883\u3002<\/p>\n<h4>\u76ee\u6807<\/h4>\n<p>\u8ba9 TFLM \u5728\u76ee\u6807\u82af\u7247\u4e0a\u5b8c\u6210\u6700\u5c0f\u793a\u4f8b\u8fd0\u884c\u3002<\/p>\n<h4>\u4e3b\u8981\u5de5\u4f5c<\/h4>\n<h5>5.1 \u5de5\u5177\u94fe\u548c\u94fe\u63a5<\/h5>\n<p>\u786e\u8ba4&#xff1a;<\/p>\n<ul>\n<li>\u7f16\u8bd1\u5668\u652f\u6301 C&#043;&#043;17\u3002<\/li>\n<li>include \u8def\u5f84\u548c\u5b8f\u5b9a\u4e49\u6b63\u786e\u3002<\/li>\n<li>\u94fe\u63a5\u811a\u672c\u80fd\u653e\u4e0b\u4ee3\u7801\u3001\u53ea\u8bfb\u6a21\u578b\u548c tensor arena\u3002<\/li>\n<li>C\/C&#043;&#043; ABI \u548c\u6d6e\u70b9 ABI \u8bbe\u7f6e\u4e00\u81f4\u3002<\/li>\n<li>\u6808\u3001\u5168\u5c40\u533a\u3001\u5806\u7b56\u7565\u7b26\u5408\u82af\u7247 SDK\u3002<\/li>\n<\/ul>\n<h5>5.2 \u5e73\u53f0\u6587\u4ef6<\/h5>\n<p>\u51c6\u5907\u76ee\u6807\u5e73\u53f0\u7248\u672c\u7684&#xff1a;<\/p>\n<p>tensorflow\/lite\/micro\/debug_log.cc<br \/>\ntensorflow\/lite\/micro\/micro_time.cc<br \/>\ntensorflow\/lite\/micro\/system_setup.cc<\/p>\n<p>\u5b83\u4eec\u5206\u522b\u8d1f\u8d23\u65e5\u5fd7\u8f93\u51fa\u3001\u65f6\u95f4\u6d4b\u91cf\u548c\u7cfb\u7edf\u521d\u59cb\u5316\u3002\u5b9e\u73b0\u53ef\u4ee5\u653e\u5728\u5e73\u53f0\u81ea\u5df1\u7684\u76ee\u5f55&#xff0c;\u53ea\u8981\u6700\u7ec8\u94fe\u63a5\u65f6\u80fd\u63d0\u4f9b\u5bf9\u5e94\u63a5\u53e3\u3002<\/p>\n<h5>5.3 \u9879\u76ee\u88c1\u526a<\/h5>\n<p>\u53ef\u4ee5\u4f7f\u7528\u9879\u76ee\u751f\u6210\u811a\u672c\u521b\u5efa\u53ea\u5305\u542b\u6240\u9700\u793a\u4f8b\u7684\u6e90\u7801\u6811&#xff1a;<\/p>\n<p>python3 tensorflow\/lite\/micro\/tools\/project_generation\/create_tflm_tree.py <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-e<\/span> hello_world <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-e<\/span> person_detection <span class=\"token punctuation\">\\\\<\/span><br \/>\n  \/tmp\/tflm-tree<\/p>\n<p>\u7136\u540e\u7528\u82af\u7247\u81ea\u5df1\u7684\u6784\u5efa\u7cfb\u7edf\u7f16\u8bd1 TFLM \u9759\u6001\u5e93&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>libtensorflow-microlite.a<\/p>\n<h4>\u4ea4\u4ed8\u7269<\/h4>\n<p>tensorflow\/lite\/micro\/your_chip\/<br \/>\n  README.md<br \/>\n  debug_log.cc<br \/>\n  micro_time.cc<br \/>\n  system_setup.cc<br \/>\nplatform_build\/<br \/>\n  toolchain file<br \/>\n  linker script<br \/>\n  startup code<\/p>\n<h4>\u5b8c\u6210\u6761\u4ef6<\/h4>\n<p>[ ] \u7f16\u8bd1\u901a\u8fc7<br \/>\n[ ] \u65e5\u5fd7\u53ef\u4ee5\u8f93\u51fa<br \/>\n[ ] \u8ba1\u65f6\u63a5\u53e3\u8fd4\u56de\u6709\u6548\u503c<br \/>\n[ ] \u7cfb\u7edf\u521d\u59cb\u5316\u5b8c\u6210<br \/>\n[ ] \u76ee\u6807\u677f\u80fd\u8fd0\u884c\u6700\u5c0f\u7a0b\u5e8f<\/p>\n<h3>6. \u9636\u6bb5 2&#xff1a;reference \u6a21\u578b\u95ed\u73af<\/h3>\n<h4>\u76ee\u6807<\/h4>\n<p>\u5728\u4e0d\u4f7f\u7528\u82af\u7247 optimized kernel \u7684\u60c5\u51b5\u4e0b&#xff0c;\u8ba9\u4e00\u4e2a\u771f\u5b9e\u6a21\u578b\u5b8c\u6210\u6b63\u786e\u63a8\u7406\u3002<\/p>\n<h4>\u63a8\u8350\u987a\u5e8f<\/h4>\n<p>hello_world<br \/>\n  -&gt; \u4e00\u4e2a\u5c0f\u578b int8 \u6a21\u578b<br \/>\n  -&gt; person_detection \u6216 micro_speech<br \/>\n  -&gt; \u5b9e\u9645\u4e1a\u52a1\u6a21\u578b<\/p>\n<h4>\u5de5\u4f5c\u9879<\/h4>\n<li>\u628a .tflite \u8f6c\u6210 C \u6570\u7ec4&#xff0c;\u6216\u7531\u6784\u5efa\u7cfb\u7edf\u751f\u6210\u6570\u7ec4\u3002<\/li>\n<li>\u5c06\u6a21\u578b .cc \u548c .h \u52a0\u5165\u76ee\u6807\u5de5\u7a0b\u3002<\/li>\n<li>\u6839\u636e\u6a21\u578b op \u521b\u5efa\u6700\u5c0f resolver\u3002<\/li>\n<li>\u5206\u914d\u9759\u6001 tensor arena\u3002<\/li>\n<li>\u68c0\u67e5\u6a21\u578b schema \u7248\u672c\u3002<\/li>\n<li>\u68c0\u67e5\u8f93\u5165 tensor \u7684 type\u3001shape \u548c bytes\u3002<\/li>\n<li>\u8fdb\u884c\u8f93\u5165\u9884\u5904\u7406\u548c\u91cf\u5316\u3002<\/li>\n<li>\u8c03\u7528 AllocateTensors()\u3002<\/li>\n<li>\u8c03\u7528 Invoke()\u3002<\/li>\n<li>\u5bf9\u8f93\u51fa\u8fdb\u884c\u53cd\u91cf\u5316\u5e76\u548c host reference \u6bd4\u8f83\u3002<\/li>\n<h4>\u5178\u578b\u4ee3\u7801\u7ed3\u6784<\/h4>\n<p><span class=\"token keyword\">const<\/span> tflite<span class=\"token double-colon punctuation\">::<\/span>Model<span class=\"token operator\">*<\/span> model <span class=\"token operator\">&#061;<\/span> tflite<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">GetModel<\/span><span class=\"token punctuation\">(<\/span>g_model_data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">TFLITE_CHECK_EQ<\/span><span class=\"token punctuation\">(<\/span>model<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">version<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> TFLITE_SCHEMA_VERSION<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">using<\/span> Resolver <span class=\"token operator\">&#061;<\/span> tflite<span class=\"token double-colon punctuation\">::<\/span>MicroMutableOpResolver<span class=\"token operator\">&lt;<\/span><span class=\"token number\">3<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token punctuation\">;<\/span><br \/>\nResolver resolver<span class=\"token punctuation\">;<\/span><br \/>\nresolver<span class=\"token punctuation\">.<\/span><span class=\"token function\">AddConv2D<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nresolver<span class=\"token punctuation\">.<\/span><span class=\"token function\">AddFullyConnected<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nresolver<span class=\"token punctuation\">.<\/span><span class=\"token function\">AddSoftmax<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">uint8_t<\/span> tensor_arena<span class=\"token punctuation\">[<\/span><span class=\"token number\">128<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\ntflite<span class=\"token double-colon punctuation\">::<\/span>MicroInterpreter <span class=\"token function\">interpreter<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    model<span class=\"token punctuation\">,<\/span> resolver<span class=\"token punctuation\">,<\/span> tensor_arena<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>tensor_arena<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token function\">TF_LITE_ENSURE_STATUS<\/span><span class=\"token punctuation\">(<\/span>interpreter<span class=\"token punctuation\">.<\/span><span class=\"token function\">AllocateTensors<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">TF_LITE_ENSURE_STATUS<\/span><span class=\"token punctuation\">(<\/span>interpreter<span class=\"token punctuation\">.<\/span><span class=\"token function\">Invoke<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u5b8c\u6574\u7684 main.cc \u793a\u4f8b&#xff0c;\u5c55\u793a\u4ece\u6a21\u578b\u6570\u636e\u52a0\u8f7d\u3001\u8f93\u5165\u9884\u5904\u7406\u3001\u8c03\u7528 AllocateTensors \u548c Invoke&#xff0c;\u5230\u8f93\u51fa\u53cd\u91cf\u5316\u5e76\u4e0e host reference \u6bd4\u8f83\u7684\u5b8c\u6574\u6d41\u7a0b&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ examples\/your_chip_model\/main.cc<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;tensorflow\/lite\/micro\/micro_interpreter.h&#034;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;tensorflow\/lite\/micro\/micro_mutable_op_resolver.h&#034;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;tensorflow\/lite\/micro\/system_setup.h&#034;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;tensorflow\/lite\/schema\/schema_generated.h&#034;<\/span><\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;model_data.h&#034;<\/span>        <span class=\"token comment\">\/\/ \u7531 .tflite \u8f6c\u6362\u751f\u6210\u7684\u6a21\u578b\u6570\u7ec4<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;input_adapter.h&#034;<\/span>     <span class=\"token comment\">\/\/ \u8f93\u5165\u9884\u5904\u7406&#xff1a;\u539f\u59cb\u6570\u636e -&gt; int8 \u91cf\u5316\u8f93\u5165<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;output_adapter.h&#034;<\/span>    <span class=\"token comment\">\/\/ \u8f93\u51fa\u89e3\u91ca&#xff1a;int8 \u8f93\u51fa -&gt; \u53cd\u91cf\u5316\u6d6e\u70b9\u503c<\/span><\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u9759\u6001 tensor arena&#xff1a;\u5927\u5c0f\u9700\u6839\u636e\u6a21\u578b\u5b9e\u9645\u9700\u6c42\u8c03\u6574<\/span><br \/>\n<span class=\"token keyword\">constexpr<\/span> <span class=\"token keyword\">int<\/span> kTensorArenaSize <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">128<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">uint8_t<\/span> tensor_arena<span class=\"token punctuation\">[<\/span>kTensorArenaSize<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u4ece host \u7aef\u4fdd\u5b58\u7684 reference \u8f93\u51fa&#xff08;\u6d6e\u70b9&#xff09;\u4e2d\u8bfb\u53d6\u671f\u671b\u503c<\/span><br \/>\n<span class=\"token keyword\">extern<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">float<\/span> kReferenceOutput<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u5b9a\u4e49\u5728 baseline\/reference_output.cc<\/span><br \/>\n<span class=\"token keyword\">extern<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span> kReferenceOutputSize<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u53cd\u91cf\u5316&#xff1a;int8 \u539f\u59cb\u503c -&gt; \u6d6e\u70b9\u771f\u5b9e\u503c<\/span><br \/>\n<span class=\"token keyword\">float<\/span> <span class=\"token function\">Dequantize<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int8_t<\/span> value<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">float<\/span> scale<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int32_t<\/span> zero_point<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">float<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>value<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span> zero_point<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">*<\/span> scale<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6bd4\u8f83\u76ee\u6807\u677f\u8f93\u51fa\u4e0e host reference \u8f93\u51fa<\/span><br \/>\n<span class=\"token keyword\">bool<\/span> <span class=\"token function\">CompareWithReference<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">float<\/span><span class=\"token operator\">*<\/span> actual<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> size<span class=\"token punctuation\">,<\/span><br \/>\n                          <span class=\"token keyword\">float<\/span> tolerance <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0.01f<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> size<span class=\"token punctuation\">;<\/span> <span class=\"token operator\">&#043;&#043;<\/span>i<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">float<\/span> diff <span class=\"token operator\">&#061;<\/span> actual<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#8211;<\/span> kReferenceOutput<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>diff <span class=\"token operator\">&lt;<\/span> <span class=\"token operator\">&#8211;<\/span>tolerance <span class=\"token operator\">||<\/span> diff <span class=\"token operator\">&gt;<\/span> tolerance<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token function\">MicroPrintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Mismatch at [%d]: actual&#061;%f ref&#061;%f&#034;<\/span><span class=\"token punctuation\">,<\/span> i<span class=\"token punctuation\">,<\/span> actual<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span><br \/>\n                  kReferenceOutput<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n      <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ 1. \u5e73\u53f0\u521d\u59cb\u5316&#xff1a;\u65e5\u5fd7\u3001\u8ba1\u65f6\u3001\u7cfb\u7edf\u65f6\u949f\u7b49<\/span><br \/>\n  tflite<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">InitializeTarget<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 2. \u52a0\u8f7d\u6a21\u578b&#xff1a;\u4ece C \u6570\u7ec4\u89e3\u6790 FlatBuffer<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> tflite<span class=\"token double-colon punctuation\">::<\/span>Model<span class=\"token operator\">*<\/span> model <span class=\"token operator\">&#061;<\/span> tflite<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">GetModel<\/span><span class=\"token punctuation\">(<\/span>g_model_data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token function\">TFLITE_CHECK_EQ<\/span><span class=\"token punctuation\">(<\/span>model<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">version<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> TFLITE_SCHEMA_VERSION<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 3. \u521b\u5efa\u6700\u5c0f resolver&#xff0c;\u53ea\u6ce8\u518c\u6a21\u578b\u5b9e\u9645\u7528\u5230\u7684 op<\/span><br \/>\n  <span class=\"token keyword\">using<\/span> Resolver <span class=\"token operator\">&#061;<\/span> tflite<span class=\"token double-colon punctuation\">::<\/span>MicroMutableOpResolver<span class=\"token operator\">&lt;<\/span><span class=\"token number\">3<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  Resolver resolver<span class=\"token punctuation\">;<\/span><br \/>\n  resolver<span class=\"token punctuation\">.<\/span><span class=\"token function\">AddConv2D<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  resolver<span class=\"token punctuation\">.<\/span><span class=\"token function\">AddFullyConnected<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  resolver<span class=\"token punctuation\">.<\/span><span class=\"token function\">AddSoftmax<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 4. \u6784\u5efa\u89e3\u91ca\u5668&#xff0c;\u7ed1\u5b9a\u9759\u6001 arena<\/span><br \/>\n  tflite<span class=\"token double-colon punctuation\">::<\/span>MicroInterpreter <span class=\"token function\">interpreter<\/span><span class=\"token punctuation\">(<\/span>model<span class=\"token punctuation\">,<\/span> resolver<span class=\"token punctuation\">,<\/span> tensor_arena<span class=\"token punctuation\">,<\/span><br \/>\n                                        kTensorArenaSize<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 5. \u5206\u914d tensor \u5185\u5b58&#xff1b;\u5931\u8d25\u901a\u5e38\u610f\u5473\u7740 arena \u592a\u5c0f<\/span><br \/>\n  TfLiteStatus allocate_status <span class=\"token operator\">&#061;<\/span> interpreter<span class=\"token punctuation\">.<\/span><span class=\"token function\">AllocateTensors<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>allocate_status <span class=\"token operator\">!&#061;<\/span> kTfLiteOk<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">MicroPrintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;AllocateTensors failed: arena too small?&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 6. \u83b7\u53d6\u8f93\u5165 tensor&#xff0c;\u8fdb\u884c\u9884\u5904\u7406\u548c\u91cf\u5316<\/span><br \/>\n  TfLiteTensor<span class=\"token operator\">*<\/span> input <span class=\"token operator\">&#061;<\/span> interpreter<span class=\"token punctuation\">.<\/span><span class=\"token function\">input<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token function\">TFLITE_CHECK_EQ<\/span><span class=\"token punctuation\">(<\/span>input<span class=\"token operator\">-&gt;<\/span>type<span class=\"token punctuation\">,<\/span> kTfLiteInt8<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u4ece input_adapter \u8bfb\u53d6\u539f\u59cb\u6570\u636e\u5e76\u91cf\u5316\u4e3a int8<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">float<\/span><span class=\"token operator\">*<\/span> raw_input <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">GetRawInput<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u539f\u59cb\u6d6e\u70b9\u8f93\u5165<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">float<\/span> input_scale <span class=\"token operator\">&#061;<\/span> input<span class=\"token operator\">-&gt;<\/span>params<span class=\"token punctuation\">.<\/span>scale<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int32_t<\/span> input_zero_point <span class=\"token operator\">&#061;<\/span> input<span class=\"token operator\">-&gt;<\/span>params<span class=\"token punctuation\">.<\/span>zero_point<span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> input<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">*<\/span> input<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">*<\/span><br \/>\n                          input<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n       <span class=\"token operator\">&#043;&#043;<\/span>i<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u91cf\u5316\u516c\u5f0f&#xff1a;q &#061; round(raw \/ scale) &#043; zero_point<\/span><br \/>\n    <span class=\"token keyword\">float<\/span> scaled <span class=\"token operator\">&#061;<\/span> raw_input<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">\/<\/span> input_scale<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int32_t<\/span> quantized <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">int32_t<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>scaled <span class=\"token operator\">&#043;<\/span> input_zero_point<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    input<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">.<\/span>int8<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">int8_t<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>quantized<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 7. \u6267\u884c\u63a8\u7406<\/span><br \/>\n  TfLiteStatus invoke_status <span class=\"token operator\">&#061;<\/span> interpreter<span class=\"token punctuation\">.<\/span><span class=\"token function\">Invoke<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>invoke_status <span class=\"token operator\">!&#061;<\/span> kTfLiteOk<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">MicroPrintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Invoke failed&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 8. \u83b7\u53d6\u8f93\u51fa tensor&#xff0c;\u53cd\u91cf\u5316\u5e76\u4e0e host reference \u6bd4\u8f83<\/span><br \/>\n  TfLiteTensor<span class=\"token operator\">*<\/span> output <span class=\"token operator\">&#061;<\/span> interpreter<span class=\"token punctuation\">.<\/span><span class=\"token function\">output<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token function\">TFLITE_CHECK_EQ<\/span><span class=\"token punctuation\">(<\/span>output<span class=\"token operator\">-&gt;<\/span>type<span class=\"token punctuation\">,<\/span> kTfLiteInt8<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">float<\/span> output_scale <span class=\"token operator\">&#061;<\/span> output<span class=\"token operator\">-&gt;<\/span>params<span class=\"token punctuation\">.<\/span>scale<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int32_t<\/span> output_zero_point <span class=\"token operator\">&#061;<\/span> output<span class=\"token operator\">-&gt;<\/span>params<span class=\"token punctuation\">.<\/span>zero_point<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span> output_size <span class=\"token operator\">&#061;<\/span> output<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">*<\/span> output<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">*<\/span><br \/>\n                          output<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u53cd\u91cf\u5316\u5230\u6d6e\u70b9\u6570\u7ec4<\/span><br \/>\n  <span class=\"token keyword\">float<\/span> actual_output<span class=\"token punctuation\">[<\/span><span class=\"token number\">64<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u5927\u5c0f\u9700\u6839\u636e\u6a21\u578b\u8f93\u51fa\u8c03\u6574<\/span><br \/>\n  <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> output_size<span class=\"token punctuation\">;<\/span> <span class=\"token operator\">&#043;&#043;<\/span>i<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    actual_output<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">Dequantize<\/span><span class=\"token punctuation\">(<\/span>output<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">.<\/span>int8<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> output_scale<span class=\"token punctuation\">,<\/span><br \/>\n                                  output_zero_point<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 9. \u4e0e host reference \u6bd4\u8f83&#xff0c;\u9a8c\u8bc1\u6b63\u786e\u6027<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span><span class=\"token function\">CompareWithReference<\/span><span class=\"token punctuation\">(<\/span>actual_output<span class=\"token punctuation\">,<\/span> output_size<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">MicroPrintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Output mismatch with host reference&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token function\">MicroPrintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Inference OK: output matches reference&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5173\u952e\u70b9\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\u6a21\u578b\u52a0\u8f7d&#xff1a;g_model_data \u7531 model_data.cc \u63d0\u4f9b&#xff0c;\u662f .tflite \u8f6c\u6362\u540e\u7684 C \u6570\u7ec4&#xff1b;GetModel \u89e3\u6790 FlatBuffer \u5e76\u6821\u9a8c schema \u7248\u672c\u3002<\/li>\n<li>\u8f93\u5165\u9884\u5904\u7406&#xff1a;\u539f\u59cb\u6d6e\u70b9\u8f93\u5165\u901a\u8fc7\u91cf\u5316\u516c\u5f0f q &#061; round(raw \/ scale) &#043; zero_point \u8f6c\u6210 int8&#xff0c;\u5199\u5165\u8f93\u5165 tensor\u3002<\/li>\n<li>\u5185\u5b58\u5206\u914d&#xff1a;AllocateTensors \u5728\u9759\u6001 tensor_arena \u4e0a\u5b8c\u6210\u6240\u6709 tensor \u5206\u914d&#xff0c;\u5931\u8d25\u901a\u5e38\u610f\u5473\u7740 arena \u592a\u5c0f&#xff0c;\u9700\u8981\u589e\u5927\u6216\u6539\u7528 RecordingMicroAllocator \u5206\u6790\u3002<\/li>\n<li>\u63a8\u7406\u6267\u884c&#xff1a;Invoke \u9a71\u52a8\u6574\u4e2a\u56fe\u6267\u884c&#xff1b;\u8fd4\u56de\u975e kTfLiteOk \u65f6\u5148\u68c0\u67e5\u6a21\u578b\u3001\u8f93\u5165\u548c arena&#xff0c;\u4e0d\u8981\u5f52\u56e0\u4e8e\u201c\u82af\u7247\u8fd8\u6ca1\u52a0\u901f\u201d\u3002<\/li>\n<li>\u8f93\u51fa\u9a8c\u8bc1&#xff1a;int8 \u8f93\u51fa\u901a\u8fc7 Dequantize \u8fd8\u539f\u4e3a\u6d6e\u70b9&#xff0c;\u518d\u4e0e host \u7aef\u4fdd\u5b58\u7684 kReferenceOutput \u9010\u5143\u7d20\u6bd4\u8f83&#xff0c;\u8bef\u5dee\u5728\u5bb9\u5dee\u5185\u624d\u7b97\u95ed\u73af\u6210\u529f\u3002<\/li>\n<\/ul>\n<h4>\u4ea4\u4ed8\u7269<\/h4>\n<p>examples\/your_chip_model\/<br \/>\n  model_data.cc<br \/>\n  model_data.h<br \/>\n  main.cc<br \/>\n  input_adapter.cc<br \/>\n  output_adapter.cc<br \/>\n  README.md<\/p>\n<h4>\u5b8c\u6210\u6761\u4ef6<\/h4>\n<p>[ ] target board \u4e0a AllocateTensors \u6210\u529f<br \/>\n[ ] target board \u4e0a Invoke \u6210\u529f<br \/>\n[ ] \u8f93\u51fa\u5728\u660e\u786e\u8bef\u5dee\u8303\u56f4\u5185<br \/>\n[ ] \u8fde\u7eed\u8fd0\u884c\u4e0d\u4f1a\u7834\u574f arena \u6216\u72b6\u6001<br \/>\n[ ] \u8bb0\u5f55\u4e86 peak arena \u4f7f\u7528\u91cf<\/p>\n<p>\u5982\u679c\u8fd9\u4e00\u9636\u6bb5\u5931\u8d25&#xff0c;\u5148\u4fee\u590d\u6a21\u578b\u3001\u8f93\u5165\u3001arena \u6216\u5e73\u53f0\u95ee\u9898&#xff0c;\u4e0d\u8981\u628a\u5931\u8d25\u5f52\u56e0\u4e8e\u201c\u82af\u7247\u8fd8\u6ca1\u6709\u52a0\u901f\u201d\u3002<\/p>\n<h3>7. \u9636\u6bb5 3&#xff1a;\u5efa\u7acb NN library \u8fb9\u754c<\/h3>\n<h4>\u76ee\u6807<\/h4>\n<p>\u8ba9\u786c\u4ef6\u5b9e\u73b0\u4e0e TFLM \u89e3\u8026&#xff0c;\u5f62\u6210\u53ef\u72ec\u7acb\u6d4b\u8bd5\u7684 NN library API\u3002<\/p>\n<h4>\u63a8\u8350\u76ee\u5f55<\/h4>\n<p>your_nnlib\/<br \/>\n  include\/<br \/>\n    your_nnlib.h<br \/>\n  src\/<br \/>\n    conv_int8.c<br \/>\n    depthwise_conv_int8.c<br \/>\n    fully_connected_int8.c<br \/>\n  tests\/<br \/>\n    conv_test.c<br \/>\n    fully_connected_test.c<\/p>\n<p>tensorflow\/lite\/micro\/kernels\/your_chip\/<br \/>\n  README.md<br \/>\n  your_chip_common.h<br \/>\n  your_chip_common.cc<br \/>\n  conv.cc<br \/>\n  fully_connected.cc<\/p>\n<h4>NN library API \u5e94\u660e\u786e<\/h4>\n<ul>\n<li>\u652f\u6301\u7684\u6570\u636e\u7c7b\u578b\u3002<\/li>\n<li>tensor layout\u3002<\/li>\n<li>padding \u548c stride \u8868\u793a\u6cd5\u3002<\/li>\n<li>activation \u8303\u56f4\u3002<\/li>\n<li>per-tensor\/per-channel quantization\u3002<\/li>\n<li>\u8f93\u5165\u8f93\u51fa alignment \u8981\u6c42\u3002<\/li>\n<li>scratch \u5927\u5c0f\u548c\u751f\u547d\u5468\u671f\u3002<\/li>\n<li>\u540c\u6b65\u6216\u5f02\u6b65\u6267\u884c\u65b9\u5f0f\u3002<\/li>\n<li>\u9519\u8bef\u7801\u548c\u8d85\u65f6\u884c\u4e3a\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982 wrapper \u4e0d\u5e94\u731c\u6d4b\u786c\u4ef6\u5e93\u7684\u91cf\u5316\u7ea6\u5b9a&#xff0c;\u800c\u5e94\u660e\u786e\u8f6c\u6362&#xff1a;<\/p>\n<p>TFLM zero_point \/ multiplier \/ shift<br \/>\n  -&gt; your_nnlib quantization parameters<\/p>\n<h4>\u5b8c\u6210\u6761\u4ef6<\/h4>\n<p>[ ] NN library \u53ef\u8131\u79bb TFLM \u5355\u72ec\u7f16\u8bd1<br \/>\n[ ] NN library \u6709\u72ec\u7acb\u8f93\u5165\u8f93\u51fa\u6d4b\u8bd5<br \/>\n[ ] API \u80fd\u8868\u8fbe\u76ee\u6807 kernel \u7684\u9650\u5236<br \/>\n[ ] TFLM wrapper \u4e0d\u9700\u8981\u66b4\u9732\u786c\u4ef6\u5bc4\u5b58\u5668\u7ec6\u8282<\/p>\n<h3>8. \u9636\u6bb5 4&#xff1a;\u5b9e\u73b0\u7b2c\u4e00\u4e2a optimized kernel<\/h3>\n<h4>\u76ee\u6807<\/h4>\n<p>\u9009\u62e9\u4e00\u4e2a\u9ad8\u6536\u76ca\u3001\u8fb9\u754c\u6e05\u6670\u7684 op&#xff0c;\u5b8c\u6210 reference \u5230\u786c\u4ef6\u5b9e\u73b0\u7684\u66ff\u6362\u3002<\/p>\n<p>\u4f18\u5148\u9009\u62e9&#xff1a;<\/p>\n<p>CONV_2D<br \/>\nDEPTHWISE_CONV_2D<br \/>\nFULLY_CONNECTED<\/p>\n<p>\u9009\u62e9\u4f9d\u636e\u5e94\u662f benchmark&#xff0c;\u800c\u4e0d\u662f\u7b97\u5b50\u540d\u79f0\u7684\u6d41\u884c\u7a0b\u5ea6\u3002<\/p>\n<h4>wrapper \u7684\u804c\u8d23<\/h4>\n<p>TFLM TfLiteEvalTensor<br \/>\n  |<br \/>\n  \u251c\u2500\u2500 \u68c0\u67e5 type \/ shape \/ quantization<br \/>\n  \u251c\u2500\u2500 \u8ba1\u7b97\u6216\u8bfb\u53d6 OpData<br \/>\n  \u251c\u2500\u2500 \u7533\u8bf7\u548c\u53d6\u5f97 scratch<br \/>\n  \u251c\u2500\u2500 \u8f6c\u6362 padding \/ stride \/ activation<br \/>\n  \u251c\u2500\u2500 \u8c03\u7528 your_nnlib<br \/>\n  \u2514\u2500\u2500 \u5c06\u9519\u8bef\u7801\u8f6c\u6210 TfLiteStatus<\/p>\n<p>Prepare \u8d1f\u8d23\u68c0\u67e5\u80fd\u529b\u548c\u7533\u8bf7\u8d44\u6e90&#xff0c;Eval \u6216 Invoke \u8d1f\u8d23\u63d0\u4ea4\u8ba1\u7b97\u3002\u4e0d\u8981\u5728\u6bcf\u6b21\u63a8\u7406\u4e2d\u91cd\u590d\u505a\u53ef\u4ee5\u63d0\u524d\u5b8c\u6210\u7684\u53c2\u6570\u8ba1\u7b97\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u5b8c\u6574\u7684 CONV_2D wrapper \u793a\u4f8b&#xff0c;\u5c55\u793a Prepare \u548c Eval \u7684\u9aa8\u67b6\u3001OpData \u7ed3\u6784\u5b9a\u4e49\u3001\u91cf\u5316\u53c2\u6570\u8f6c\u6362&#xff0c;\u4ee5\u53ca\u8c03\u7528 your_nnlib \u7684\u63a5\u53e3&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ tensorflow\/lite\/micro\/kernels\/your_chip\/conv.cc<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;tensorflow\/lite\/micro\/kernels\/your_chip\/your_chip_common.h&#034;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;your_nnlib.h&#034;<\/span>  <span class=\"token comment\">\/\/ \u82af\u7247 NN library \u5934\u6587\u4ef6<\/span><\/span><\/p>\n<p><span class=\"token keyword\">namespace<\/span> tflite <span class=\"token punctuation\">{<\/span><\/p>\n<p><span class=\"token comment\">\/\/ OpData&#xff1a;\u5728 Prepare \u9636\u6bb5\u8ba1\u7b97\u5e76\u6301\u4e45\u5316&#xff0c;\u907f\u514d\u6bcf\u6b21\u63a8\u7406\u91cd\u590d\u8ba1\u7b97<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">OpData<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u91cf\u5316\u53c2\u6570&#xff08;TFLM \u683c\u5f0f&#xff09;<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> output_multiplier<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">int<\/span> output_shift<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> output_zero_point<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> input_zero_point<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> filter_zero_point<span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u8f6c\u6362\u540e\u7684 your_nnlib \u91cf\u5316\u53c2\u6570<\/span><br \/>\n  your_nnlib_quant_params nn_quant<span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u5377\u79ef\u53c2\u6570<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> padding_h<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> padding_w<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> stride_h<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">int32_t<\/span> stride_w<span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ scratch buffer \u7d22\u5f15<\/span><br \/>\n  <span class=\"token keyword\">int<\/span> scratch_index<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5c06 TFLM \u91cf\u5316\u53c2\u6570\u8f6c\u6362\u4e3a your_nnlib \u683c\u5f0f<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">ConvertQuantParams<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> TfLiteAffineQuantization<span class=\"token operator\">*<\/span> quant<span class=\"token punctuation\">,<\/span><br \/>\n                               OpData<span class=\"token operator\">*<\/span> data<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u8bfb\u53d6 TFLM \u7684 multiplier \/ shift \/ zero_point<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>output_multiplier <span class=\"token operator\">&#061;<\/span> quant<span class=\"token operator\">-&gt;<\/span>multiplier<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>output_shift <span class=\"token operator\">&#061;<\/span> quant<span class=\"token operator\">-&gt;<\/span>shift<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>output_zero_point <span class=\"token operator\">&#061;<\/span> quant<span class=\"token operator\">-&gt;<\/span>zero_point<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u8f6c\u6362\u4e3a your_nnlib \u7684\u91cf\u5316\u53c2\u6570\u7ed3\u6784<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>nn_quant<span class=\"token punctuation\">.<\/span>multiplier <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>output_multiplier<span class=\"token punctuation\">;<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>nn_quant<span class=\"token punctuation\">.<\/span>shift <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>output_shift<span class=\"token punctuation\">;<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>nn_quant<span class=\"token punctuation\">.<\/span>zero_point <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>output_zero_point<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ Prepare&#xff1a;\u68c0\u67e5\u80fd\u529b\u3001\u8ba1\u7b97 OpData\u3001\u7533\u8bf7 scratch<\/span><br \/>\nTfLiteStatus <span class=\"token function\">ConvPrepare<\/span><span class=\"token punctuation\">(<\/span>TfLiteContext<span class=\"token operator\">*<\/span> context<span class=\"token punctuation\">,<\/span> TfLiteNode<span class=\"token operator\">*<\/span> node<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token function\">TF_LITE_ENSURE_EQ<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> <span class=\"token function\">NumInputs<\/span><span class=\"token punctuation\">(<\/span>node<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ input, filter, bias<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u68c0\u67e5\u662f\u5426\u652f\u6301 int8&#xff08;\u672c\u793a\u4f8b\u53ea\u652f\u6301 int8&#xff09;<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> TfLiteEvalTensor<span class=\"token operator\">*<\/span> input <span class=\"token operator\">&#061;<\/span><br \/>\n      tflite<span class=\"token double-colon punctuation\">::<\/span>micro<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">GetEvalInput<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> node<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token function\">TF_LITE_ENSURE_EQ<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> input<span class=\"token operator\">-&gt;<\/span>type<span class=\"token punctuation\">,<\/span> kTfLiteInt8<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u5206\u914d\u5e76\u521d\u59cb\u5316 OpData&#xff08;persistent&#xff0c;\u8de8 Invoke \u4fdd\u7559&#xff09;<\/span><br \/>\n  OpData<span class=\"token operator\">*<\/span> data <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">reinterpret_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span>OpData<span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span><br \/>\n      context<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">AllocatePersistentBuffer<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>OpData<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  node<span class=\"token operator\">-&gt;<\/span>user_data <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u8bfb\u53d6\u5377\u79ef\u53c2\u6570&#xff08;padding \/ stride&#xff09;<\/span><br \/>\n  <span class=\"token keyword\">auto<\/span><span class=\"token operator\">*<\/span> params <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">reinterpret_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span>TfLiteConvParams<span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>node<span class=\"token operator\">-&gt;<\/span>builtin_data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>stride_h <span class=\"token operator\">&#061;<\/span> params<span class=\"token operator\">-&gt;<\/span>stride_height<span class=\"token punctuation\">;<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>stride_w <span class=\"token operator\">&#061;<\/span> params<span class=\"token operator\">-&gt;<\/span>stride_width<span class=\"token punctuation\">;<\/span><br \/>\n  data<span class=\"token operator\">-&gt;<\/span>padding_h <span class=\"token operator\">&#061;<\/span> params<span class=\"token operator\">-&gt;<\/span>padding <span class=\"token operator\">&#061;&#061;<\/span> kTfLitePaddingSame <span class=\"token operator\">?<\/span> <span class=\"token number\">1<\/span> <span class=\"token operator\">:<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u8f6c\u6362\u91cf\u5316\u53c2\u6570<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">auto<\/span><span class=\"token operator\">*<\/span> quant <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">reinterpret_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span>TfLiteAffineQuantization<span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span><br \/>\n      input<span class=\"token operator\">-&gt;<\/span>quantization<span class=\"token punctuation\">.<\/span>params<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token function\">ConvertQuantParams<\/span><span class=\"token punctuation\">(<\/span>quant<span class=\"token punctuation\">,<\/span> data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u7533\u8bf7 scratch buffer&#xff08;\u4f8b\u5982\u7528\u4e8e DMA \u5bf9\u9f50\u7684\u4e2d\u95f4\u7f13\u51b2&#xff09;<\/span><br \/>\n  <span class=\"token function\">TF_LITE_ENSURE_STATUS<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">RequestScratchBufferInArena<\/span><span class=\"token punctuation\">(<\/span><br \/>\n      context<span class=\"token punctuation\">,<\/span> input<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">*<\/span> input<span class=\"token operator\">-&gt;<\/span>dims<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      <span class=\"token operator\">&amp;<\/span>data<span class=\"token operator\">-&gt;<\/span>scratch_index<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token keyword\">return<\/span> kTfLiteOk<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ Eval&#xff1a;\u63d0\u4ea4\u8ba1\u7b97\u5230 your_nnlib<\/span><br \/>\nTfLiteStatus <span class=\"token function\">ConvEval<\/span><span class=\"token punctuation\">(<\/span>TfLiteContext<span class=\"token operator\">*<\/span> context<span class=\"token punctuation\">,<\/span> TfLiteNode<span class=\"token operator\">*<\/span> node<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  OpData<span class=\"token operator\">*<\/span> data <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">reinterpret_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span>OpData<span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>node<span class=\"token operator\">-&gt;<\/span>user_data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u83b7\u53d6\u8f93\u5165\u8f93\u51fa tensor<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> TfLiteEvalTensor<span class=\"token operator\">*<\/span> input <span class=\"token operator\">&#061;<\/span><br \/>\n      tflite<span class=\"token double-colon punctuation\">::<\/span>micro<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">GetEvalInput<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> node<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> TfLiteEvalTensor<span class=\"token operator\">*<\/span> filter <span class=\"token operator\">&#061;<\/span><br \/>\n      tflite<span class=\"token double-colon punctuation\">::<\/span>micro<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">GetEvalInput<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> node<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  TfLiteEvalTensor<span class=\"token operator\">*<\/span> output <span class=\"token operator\">&#061;<\/span><br \/>\n      tflite<span class=\"token double-colon punctuation\">::<\/span>micro<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">GetEvalOutput<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> node<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u83b7\u53d6 scratch buffer<\/span><br \/>\n  <span class=\"token keyword\">void<\/span><span class=\"token operator\">*<\/span> scratch <span class=\"token operator\">&#061;<\/span> context<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">GetScratchBuffer<\/span><span class=\"token punctuation\">(<\/span>context<span class=\"token punctuation\">,<\/span> data<span class=\"token operator\">-&gt;<\/span>scratch_index<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u6784\u9020 your_nnlib \u7684\u8f93\u5165\u63cf\u8ff0<\/span><br \/>\n  your_nnlib_conv_params nn_params<span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>input <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int8_t<\/span><span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>input<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>filter <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int8_t<\/span><span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>filter<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>output <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">int8_t<\/span><span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>output<span class=\"token operator\">-&gt;<\/span>data<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>quant <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>nn_quant<span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>stride_h <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>stride_h<span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>stride_w <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>stride_w<span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>padding_h <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>padding_h<span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>padding_w <span class=\"token operator\">&#061;<\/span> data<span class=\"token operator\">-&gt;<\/span>padding_w<span class=\"token punctuation\">;<\/span><br \/>\n  nn_params<span class=\"token punctuation\">.<\/span>scratch <span class=\"token operator\">&#061;<\/span> scratch<span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u8c03\u7528\u82af\u7247 NN library&#xff0c;\u5e76\u8f6c\u6362\u9519\u8bef\u7801<\/span><br \/>\n  <span class=\"token keyword\">int<\/span> ret <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">your_nnlib_conv2d_int8<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>nn_params<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>ret <span class=\"token operator\">!&#061;<\/span> YOUR_NNLIB_OK<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> kTfLiteError<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u9519\u8bef\u7801\u8f6c\u6210 TfLiteStatus<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token keyword\">return<\/span> kTfLiteOk<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6ce8\u518c\u5230 TFLM kernel \u6ce8\u518c\u8868<\/span><br \/>\nTFLMRegistration <span class=\"token function\">Register_CONV_2D<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> tflite<span class=\"token double-colon punctuation\">::<\/span>micro<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">RegisterOp<\/span><span class=\"token punctuation\">(<\/span>ConvInit<span class=\"token punctuation\">,<\/span> ConvPrepare<span class=\"token punctuation\">,<\/span> ConvEval<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token punctuation\">}<\/span>  <span class=\"token comment\">\/\/ namespace tflite<\/span><\/p>\n<p>\u5173\u952e\u70b9\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>Prepare \u53ea\u505a\u4e00\u6b21&#xff1a;\u68c0\u67e5 type\/shape\u3001\u8ba1\u7b97 OpData\u3001\u7533\u8bf7 scratch&#xff0c;\u907f\u514d\u5728\u6bcf\u6b21 Eval \u4e2d\u91cd\u590d\u8ba1\u7b97\u91cf\u5316\u53c2\u6570\u3002<\/li>\n<li>OpData \u4f7f\u7528 AllocatePersistentBuffer \u5206\u914d&#xff0c;\u8de8\u591a\u6b21 Invoke \u4fdd\u7559\u3002<\/li>\n<li>\u91cf\u5316\u53c2\u6570\u5728 Prepare \u4e2d\u4ece TFLM \u683c\u5f0f\u8f6c\u6362\u4e3a your_nnlib \u683c\u5f0f&#xff0c;Eval \u76f4\u63a5\u4f7f\u7528\u3002<\/li>\n<li>Eval \u53ea\u8d1f\u8d23\u628a tensor \u6307\u9488\u3001\u91cf\u5316\u53c2\u6570\u548c\u5377\u79ef\u53c2\u6570\u6253\u5305\u4f20\u7ed9 your_nnlib&#xff0c;\u5e76\u628a\u9519\u8bef\u7801\u8f6c\u6210 TfLiteStatus\u3002<\/li>\n<li>\u4e0d\u652f\u6301\u7684\u7ec4\u5408&#xff08;\u5982 float32&#xff09;\u5728 Prepare \u4e2d\u901a\u8fc7 TF_LITE_ENSURE_EQ \u660e\u786e\u62d2\u7edd&#xff0c;\u907f\u514d\u9759\u9ed8\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<h4>fallback \u7b56\u7565<\/h4>\n<p>\u5bf9\u4e0d\u652f\u6301\u7684\u7ec4\u5408\u5fc5\u987b\u660e\u786e\u5904\u7406&#xff1a;<\/p>\n<p>\u652f\u6301 -&gt; \u8c03\u7528 optimized kernel<br \/>\n\u4e0d\u652f\u6301 -&gt; \u8c03\u7528 reference kernel \u6216\u8fd4\u56de\u9519\u8bef<\/p>\n<p>\u4e0d\u8981\u9759\u9ed8\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u3002\u5e38\u89c1\u9650\u5236\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\u53ea\u652f\u6301 int8&#xff0c;\u4e0d\u652f\u6301 float32\u3002<\/li>\n<li>\u53ea\u652f\u6301\u7279\u5b9a stride\u3001padding \u6216 dilation\u3002<\/li>\n<li>\u53ea\u652f\u6301 per-tensor quantization\u3002<\/li>\n<li>\u53ea\u652f\u6301\u7279\u5b9a channel \u5bf9\u9f50\u3002<\/li>\n<li>DMA buffer \u9700\u8981\u7279\u5b9a alignment\u3002<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u662f\u5b8c\u6574\u7684 fallback \u51b3\u7b56\u6d41\u7a0b&#xff1a;<\/p>\n<p>  #mermaid-svg-HVD7dsufoOHD2OA7{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-HVD7dsufoOHD2OA7 .error-icon{fill:#552222;}#mermaid-svg-HVD7dsufoOHD2OA7 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-HVD7dsufoOHD2OA7 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-HVD7dsufoOHD2OA7 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-HVD7dsufoOHD2OA7 .marker.cross{stroke:#333333;}#mermaid-svg-HVD7dsufoOHD2OA7 svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-HVD7dsufoOHD2OA7 p{margin:0;}#mermaid-svg-HVD7dsufoOHD2OA7 .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-HVD7dsufoOHD2OA7 .cluster-label text{fill:#333;}#mermaid-svg-HVD7dsufoOHD2OA7 .cluster-label span{color:#333;}#mermaid-svg-HVD7dsufoOHD2OA7 .cluster-label span p{background-color:transparent;}#mermaid-svg-HVD7dsufoOHD2OA7 .label text,#mermaid-svg-HVD7dsufoOHD2OA7 span{fill:#333;color:#333;}#mermaid-svg-HVD7dsufoOHD2OA7 .node rect,#mermaid-svg-HVD7dsufoOHD2OA7 .node circle,#mermaid-svg-HVD7dsufoOHD2OA7 .node ellipse,#mermaid-svg-HVD7dsufoOHD2OA7 .node polygon,#mermaid-svg-HVD7dsufoOHD2OA7 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-HVD7dsufoOHD2OA7 .rough-node .label text,#mermaid-svg-HVD7dsufoOHD2OA7 .node .label text,#mermaid-svg-HVD7dsufoOHD2OA7 .image-shape .label,#mermaid-svg-HVD7dsufoOHD2OA7 .icon-shape .label{text-anchor:middle;}#mermaid-svg-HVD7dsufoOHD2OA7 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-HVD7dsufoOHD2OA7 .rough-node .label,#mermaid-svg-HVD7dsufoOHD2OA7 .node .label,#mermaid-svg-HVD7dsufoOHD2OA7 .image-shape .label,#mermaid-svg-HVD7dsufoOHD2OA7 .icon-shape .label{text-align:center;}#mermaid-svg-HVD7dsufoOHD2OA7 .node.clickable{cursor:pointer;}#mermaid-svg-HVD7dsufoOHD2OA7 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-HVD7dsufoOHD2OA7 .arrowheadPath{fill:#333333;}#mermaid-svg-HVD7dsufoOHD2OA7 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-HVD7dsufoOHD2OA7 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-HVD7dsufoOHD2OA7 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-HVD7dsufoOHD2OA7 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-HVD7dsufoOHD2OA7 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-HVD7dsufoOHD2OA7 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-HVD7dsufoOHD2OA7 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-HVD7dsufoOHD2OA7 .cluster text{fill:#333;}#mermaid-svg-HVD7dsufoOHD2OA7 .cluster span{color:#333;}#mermaid-svg-HVD7dsufoOHD2OA7 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-HVD7dsufoOHD2OA7 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-HVD7dsufoOHD2OA7 rect.text{fill:none;stroke-width:0;}#mermaid-svg-HVD7dsufoOHD2OA7 .icon-shape,#mermaid-svg-HVD7dsufoOHD2OA7 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-HVD7dsufoOHD2OA7 .icon-shape p,#mermaid-svg-HVD7dsufoOHD2OA7 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-HVD7dsufoOHD2OA7 .icon-shape .label rect,#mermaid-svg-HVD7dsufoOHD2OA7 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-HVD7dsufoOHD2OA7 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-HVD7dsufoOHD2OA7 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-HVD7dsufoOHD2OA7 :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u652f\u6301<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u652f\u6301<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u6210\u529f<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u5931\u8d25<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u4e0d\u652f\u6301<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u4e0d\u652f\u6301<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>kernel \u88ab\u8c03\u7528&#xff08;Eval\/Invoke&#xff09;<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u68c0\u67e5 type \/ shape \/ \u91cf\u5316\u53c2\u6570<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u68c0\u67e5 stride \/ padding \/ dilation \/ channel \u5bf9\u9f50<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8c03\u7528 optimized kernel&#xff08;your_nnlib&#xff09;<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u6267\u884c\u7ed3\u679c<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8fd4\u56de kTfLiteOk<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8fd4\u56de kTfLiteError<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8c03\u7528 reference kernel<\/p>\n<p><\/span><\/p>\n<p>\u51b3\u7b56\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u5728 Prepare \u9636\u6bb5\u5c31\u5b8c\u6210\u80fd\u529b\u68c0\u67e5&#xff0c;\u628a\u4e0d\u652f\u6301\u7684\u7ec4\u5408\u5c3d\u65e9\u62d2\u7edd&#xff0c;\u907f\u514d\u5728\u6bcf\u6b21 Eval \u4e2d\u91cd\u590d\u5224\u65ad\u3002<\/li>\n<li>\u53ea\u6709\u6240\u6709\u6761\u4ef6\u90fd\u6ee1\u8db3\u65f6\u624d\u8d70 optimized \u8def\u5f84&#xff1b;\u4efb\u4f55\u4e00\u9879\u4e0d\u6ee1\u8db3\u90fd\u56de\u9000\u5230 reference kernel&#xff0c;\u4fdd\u8bc1\u6b63\u786e\u6027\u4f18\u5148\u3002<\/li>\n<li>\u786c\u4ef6\u6267\u884c\u5931\u8d25&#xff08;\u5982 DMA \u8d85\u65f6\u3001\u547d\u4ee4\u63d0\u4ea4\u9519\u8bef&#xff09;\u4e0d\u80fd\u9759\u9ed8\u541e\u6389&#xff0c;\u5fc5\u987b\u8f6c\u6210 kTfLiteError \u8ba9\u4e0a\u5c42\u53ef\u89c1\u3002<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u662f\u5e38\u89c1\u4e0d\u652f\u6301\u7ec4\u5408\u5728 optimized \u4e0e reference \u4e24\u6761\u8def\u5f84\u4e0b\u7684\u884c\u4e3a\u5bf9\u6bd4&#xff1a;<\/p>\n<table>\n<tr>\u4e0d\u652f\u6301\u7ec4\u5408optimized \u8def\u5f84\u884c\u4e3areference \u8def\u5f84\u884c\u4e3a\u9519\u8bef\u5904\u7406\u65b9\u5f0f<\/tr>\n<tbody>\n<tr>\n<td>float32 \u8f93\u5165<\/td>\n<td>Prepare \u9636\u6bb5\u901a\u8fc7 TF_LITE_ENSURE_EQ \u76f4\u63a5\u62d2\u7edd&#xff0c;\u4e0d\u8fdb\u5165 Eval<\/td>\n<td>\u6b63\u5e38\u6267\u884c\u6d6e\u70b9 reference kernel&#xff0c;\u8f93\u51fa\u6b63\u786e\u7ed3\u679c<\/td>\n<td>optimized \u8fd4\u56de kTfLiteError \u5e76\u6253\u5370\u65e5\u5fd7&#xff1b;reference \u6b63\u5e38\u8fd4\u56de kTfLiteOk<\/td>\n<\/tr>\n<tr>\n<td>\u7279\u5b9a stride&#xff08;\u5982 stride&#061;3&#xff09;<\/td>\n<td>Prepare \u68c0\u67e5 stride \u4e0d\u5728\u652f\u6301\u96c6\u5408\u5185&#xff0c;\u56de\u9000\u5230 reference<\/td>\n<td>\u652f\u6301\u4efb\u610f stride&#xff0c;\u6309\u53c2\u6570\u6b63\u5e38\u8ba1\u7b97<\/td>\n<td>optimized \u4e0d\u62a5\u9519&#xff0c;\u9759\u9ed8\u56de\u9000\u5230 reference&#xff1b;reference \u8fd4\u56de kTfLiteOk<\/td>\n<\/tr>\n<tr>\n<td>per-channel quantization<\/td>\n<td>Prepare \u68c0\u6d4b\u5230 per-channel \u91cf\u5316\u53c2\u6570&#xff0c;\u56de\u9000\u5230 reference<\/td>\n<td>\u652f\u6301 per-channel scale\/zero_point&#xff0c;\u9010\u901a\u9053\u53cd\u91cf\u5316<\/td>\n<td>optimized \u4e0d\u62a5\u9519&#xff0c;\u9759\u9ed8\u56de\u9000\u5230 reference&#xff1b;reference \u8fd4\u56de kTfLiteOk<\/td>\n<\/tr>\n<tr>\n<td>\u7279\u5b9a dilation&#xff08;\u5982 dilation&#061;2&#xff09;<\/td>\n<td>Prepare \u68c0\u67e5 dilation \u8d85\u51fa\u652f\u6301\u8303\u56f4&#xff0c;\u56de\u9000\u5230 reference<\/td>\n<td>\u652f\u6301\u4efb\u610f dilation&#xff0c;\u6309\u53c2\u6570\u6b63\u5e38\u8ba1\u7b97<\/td>\n<td>optimized \u4e0d\u62a5\u9519&#xff0c;\u9759\u9ed8\u56de\u9000\u5230 reference&#xff1b;reference \u8fd4\u56de kTfLiteOk<\/td>\n<\/tr>\n<tr>\n<td>channel \u6570\u4e0d\u6ee1\u8db3\u5bf9\u9f50\u8981\u6c42<\/td>\n<td>Prepare \u68c0\u67e5 channel \u5bf9\u9f50&#xff0c;\u4e0d\u6ee1\u8db3\u5219\u56de\u9000\u5230 reference<\/td>\n<td>\u65e0\u5bf9\u9f50\u8981\u6c42&#xff0c;\u4efb\u610f channel \u5747\u53ef\u8ba1\u7b97<\/td>\n<td>optimized \u4e0d\u62a5\u9519&#xff0c;\u9759\u9ed8\u56de\u9000\u5230 reference&#xff1b;reference \u8fd4\u56de kTfLiteOk<\/td>\n<\/tr>\n<tr>\n<td>DMA buffer \u672a\u5bf9\u9f50<\/td>\n<td>Eval \u9636\u6bb5\u68c0\u67e5\u5730\u5740 alignment&#xff0c;\u4e0d\u6ee1\u8db3\u5219\u56de\u9000\u5230 reference<\/td>\n<td>\u65e0 DMA \u4f9d\u8d56&#xff0c;\u666e\u901a\u5185\u5b58\u8bbf\u95ee\u5373\u53ef<\/td>\n<td>optimized \u4e0d\u62a5\u9519&#xff0c;\u9759\u9ed8\u56de\u9000\u5230 reference&#xff1b;reference \u8fd4\u56de kTfLiteOk<\/td>\n<\/tr>\n<tr>\n<td>\u786c\u4ef6\u6267\u884c\u5931\u8d25&#xff08;DMA \u8d85\u65f6\/\u547d\u4ee4\u9519\u8bef&#xff09;<\/td>\n<td>Eval \u8c03\u7528 your_nnlib \u8fd4\u56de\u975e YOUR_NNLIB_OK<\/td>\n<td>\u4e0d\u6d89\u53ca\u786c\u4ef6\u8c03\u7528&#xff0c;\u4e0d\u5b58\u5728\u8be5\u5931\u8d25\u573a\u666f<\/td>\n<td>optimized \u8fd4\u56de kTfLiteError \u5e76\u6253\u5370\u9519\u8bef\u7801&#xff1b;reference \u4e0d\u9002\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5bf9\u6bd4\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u80fd\u529b\u68c0\u67e5\u7c7b&#xff08;float32\u3001stride\u3001dilation\u3001per-channel\u3001channel \u5bf9\u9f50&#xff09;\u5728 Prepare \u9636\u6bb5\u5b8c\u6210&#xff0c;\u80fd\u63d0\u524d\u5224\u65ad\u5c31\u63d0\u524d\u5224\u65ad&#xff0c;\u907f\u514d\u6bcf\u6b21 Eval \u91cd\u590d\u68c0\u67e5\u3002<\/li>\n<li>\u8fd0\u884c\u65f6\u5931\u8d25\u7c7b&#xff08;DMA \u8d85\u65f6\u3001\u547d\u4ee4\u63d0\u4ea4\u9519\u8bef&#xff09;\u53ea\u80fd\u5728 Eval \u9636\u6bb5\u53d1\u73b0&#xff0c;\u5fc5\u987b\u8f6c\u6210 kTfLiteError \u8ba9\u4e0a\u5c42\u53ef\u89c1&#xff0c;\u4e0d\u80fd\u9759\u9ed8\u541e\u6389\u3002<\/li>\n<li>\u56de\u9000\u5230 reference \u662f\u300c\u6b63\u786e\u6027\u4f18\u5148\u300d\u7684\u9ed8\u8ba4\u7b56\u7565&#xff1a;\u53ea\u8981 optimized \u4e0d\u652f\u6301&#xff0c;\u5c31\u4fdd\u8bc1 reference \u80fd\u7ed9\u51fa\u6b63\u786e\u7ed3\u679c&#xff1b;\u53ea\u6709\u786c\u4ef6\u771f\u6b63\u6267\u884c\u5931\u8d25\u65f6\u624d\u8fd4\u56de\u9519\u8bef\u3002<\/li>\n<\/ul>\n<h4>\u5b8c\u6210\u6761\u4ef6<\/h4>\n<p>[ ] \u5355\u7b97\u5b50\u6d4b\u8bd5\u901a\u8fc7<br \/>\n[ ] \u4e0d\u652f\u6301\u7684 case \u6709\u660e\u786e\u884c\u4e3a<br \/>\n[ ] reference \u548c optimized \u8f93\u51fa\u4e00\u81f4\u6216\u8bef\u5dee\u6709\u5b9a\u4e49<br \/>\n[ ] kernel \u4e0d\u5f15\u5165\u4e0d\u5fc5\u8981\u7684\u6570\u636e\u590d\u5236<br \/>\n[ ] benchmark \u8bc1\u660e\u6709\u6027\u80fd\u6536\u76ca<\/p>\n<h3>9. \u9636\u6bb5 5&#xff1a;\u6269\u5c55\u70ed\u70b9 op<\/h3>\n<h4>\u76ee\u6807<\/h4>\n<p>\u7528 profiling \u7ed3\u679c\u51b3\u5b9a\u4e0b\u4e00\u6279\u4f18\u5316&#xff0c;\u800c\u4e0d\u662f\u4e00\u6b21\u6027\u5b9e\u73b0\u5168\u90e8 kernel\u3002<\/p>\n<p>\u63a8\u8350\u5de5\u4f5c\u5faa\u73af&#xff1a;<\/p>\n<p>\u8dd1\u6574\u6a21\u578b profiler<br \/>\n  -&gt; \u627e\u51fa\u70ed\u70b9 op<br \/>\n  -&gt; \u9009\u62e9\u4e00\u4e2a kernel<br \/>\n  -&gt; \u52a0\u6d4b\u8bd5<br \/>\n  -&gt; \u52a0 optimized wrapper<br \/>\n  -&gt; \u91cd\u65b0\u8dd1\u6574\u6a21\u578b<br \/>\n  -&gt; \u8bb0\u5f55\u6536\u76ca<\/p>\n<p>\u6bcf\u4e2a kernel \u5355\u72ec\u63d0\u4ea4\u3001\u5355\u72ec\u6d4b\u91cf&#xff0c;\u4fbf\u4e8e\u5b9a\u4f4d\u56de\u5f52\u3002<\/p>\n<h4>\u8bc4\u4f30\u8868<\/h4>\n<table>\n<tr>\u6307\u6807referenceoptimized\u76ee\u6807<\/tr>\n<tbody>\n<tr>\n<td>\u5355\u6b21 latency<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u964d\u4f4e<\/td>\n<\/tr>\n<tr>\n<td>\u6574\u6a21\u578b latency<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u964d\u4f4e<\/td>\n<\/tr>\n<tr>\n<td>peak arena<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u4e0d\u6076\u5316\u6216\u53ef\u89e3\u91ca<\/td>\n<\/tr>\n<tr>\n<td>\u56fa\u4ef6\u4ee3\u7801\u4f53\u79ef<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u5728\u9884\u7b97\u5185<\/td>\n<\/tr>\n<tr>\n<td>\u529f\u8017<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u8bb0\u5f55<\/td>\n<td align=\"right\">\u5728\u9884\u7b97\u5185<\/td>\n<\/tr>\n<tr>\n<td>\u8f93\u51fa\u8bef\u5dee<\/td>\n<td align=\"right\">\u57fa\u7ebf<\/td>\n<td align=\"right\">\u5bf9\u6bd4<\/td>\n<td align=\"right\">\u6ee1\u8db3\u7cbe\u5ea6\u8981\u6c42<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u67d0\u4e2a kernel \u52a0\u901f\u5f88\u5feb&#xff0c;\u4f46\u5f15\u5165\u5927\u91cf scratch \u6216\u590d\u5236\u5bfc\u81f4\u6574\u6a21\u578b\u53d8\u6162&#xff0c;\u5c31\u4e0d\u80fd\u53ea\u770b\u8be5 kernel \u7684\u5c40\u90e8\u6570\u5b57\u3002<\/p>\n<h3>10. \u9636\u6bb5 6&#xff1a;\u5185\u5b58\u3001\u5e76\u53d1\u548c\u7a33\u5b9a\u6027<\/h3>\n<h4>10.1 Tensor arena<\/h4>\n<p>\u7528 RecordingMicroInterpreter \u6216 RecordingMicroAllocator \u8bb0\u5f55&#xff1a;<\/p>\n<ul>\n<li>head \u4f7f\u7528\u91cf\u3002<\/li>\n<li>tail \u4f7f\u7528\u91cf\u3002<\/li>\n<li>temporary \u4f7f\u7528\u91cf\u3002<\/li>\n<li>\u6bcf\u4e2a op \u7684 persistent allocation\u3002<\/li>\n<li>scratch buffer \u603b\u91cf\u3002<\/li>\n<\/ul>\n<h4>10.2 NPU\/DSP \u5185\u5b58<\/h4>\n<p>\u660e\u786e\u533a\u5206&#xff1a;<\/p>\n<p>TFLM tensor arena<br \/>\n\u82af\u7247\u672c\u5730 SRAM<br \/>\nDMA \u53ef\u8bbf\u95ee\u5185\u5b58<br \/>\nNPU command buffer<br \/>\ndriver \u5de5\u4f5c\u533a<br \/>\ncacheable \/ non-cacheable \u533a\u57df<\/p>\n<p>\u5c3d\u91cf\u8ba9\u786c\u4ef6\u76f4\u63a5\u4f7f\u7528 TFLM tensor buffer&#xff0c;\u907f\u514d input\/output copy&#xff1b;\u4f46\u5982\u679c\u786c\u4ef6\u6709 alignment\u3001cache \u6216\u5730\u5740\u7a7a\u95f4\u8981\u6c42&#xff0c;\u5fc5\u987b\u5728\u63a5\u53e3\u5c42\u660e\u786e\u5904\u7406\u3002<\/p>\n<h4>10.3 \u5f02\u6b65\u6267\u884c<\/h4>\n<p>\u5982\u679c accelerator \u662f\u5f02\u6b65\u7684&#xff0c;\u5fc5\u987b\u5b9a\u4e49&#xff1a;<\/p>\n<ul>\n<li>command \u63d0\u4ea4\u63a5\u53e3\u3002<\/li>\n<li>\u5b8c\u6210\u901a\u77e5\u6216\u8f6e\u8be2\u63a5\u53e3\u3002<\/li>\n<li>timeout\u3002<\/li>\n<li>\u9519\u8bef\u6062\u590d\u3002<\/li>\n<li>Invoke() \u8fd4\u56de\u524d\u7684\u540c\u6b65\u4fdd\u8bc1\u3002<\/li>\n<li>\u591a\u6b21 Invoke() \u7684\u72b6\u6001\u6e05\u7406\u3002<\/li>\n<\/ul>\n<p>TFLM \u7684 kernel Invoke \u8fd4\u56de\u540e&#xff0c;\u76f8\u5173 output tensor \u5fc5\u987b\u5df2\u7ecf\u6ee1\u8db3\u5e94\u7528\u8bfb\u53d6\u7ea6\u5b9a\u3002<\/p>\n<h4>\u5b8c\u6210\u6761\u4ef6<\/h4>\n<p>[ ] \u8fde\u7eed Invoke \u7a33\u5b9a<br \/>\n[ ] \u590d\u4f4d\u540e\u53ef\u4ee5\u518d\u6b21\u8fd0\u884c<br \/>\n[ ] \u8d85\u65f6\u548c\u786c\u4ef6\u9519\u8bef\u53ef\u89c2\u5bdf<br \/>\n[ ] cache\/DMA \u4e00\u81f4\u6027\u6709\u6d4b\u8bd5<br \/>\n[ ] \u5cf0\u503c\u5185\u5b58\u6ca1\u6709\u8d85\u51fa\u82af\u7247\u9884\u7b97<\/p>\n<h3>11. \u9636\u6bb5 7&#xff1a;CI\u3001\u53d1\u5e03\u548c\u7248\u672c\u7ef4\u62a4<\/h3>\n<h4>CI \u6700\u5c0f\u77e9\u9635<\/h4>\n<p>host reference kernel tests<br \/>\nhost optimized kernel tests<br \/>\n\u76ee\u6807\u5e73\u53f0\u7f16\u8bd1<br \/>\n\u76ee\u6807\u5e73\u53f0 smoke test<br \/>\n\u4ee3\u8868\u6a21\u578b\u63a8\u7406\u6d4b\u8bd5<br \/>\nbenchmark \/ size profiling<\/p>\n<p>\u4ed3\u5e93\u5df2\u6709\u7684\u6784\u5efa\u548c\u6d4b\u8bd5\u5165\u53e3\u5305\u62ec&#xff1a;<\/p>\n<p>bazel <span class=\"token builtin class-name\">test<\/span> \/\/tensorflow\/lite\/micro\/<span class=\"token punctuation\">..<\/span>.<\/p>\n<p><span class=\"token function\">make<\/span> <span class=\"token parameter variable\">-f<\/span> tensorflow\/lite\/micro\/tools\/make\/Makefile <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token assign-left variable\">TARGET<\/span><span class=\"token operator\">&#061;<\/span>your_chip <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token assign-left variable\">OPTIMIZED_KERNEL_DIR<\/span><span class=\"token operator\">&#061;<\/span>your_chip <span class=\"token punctuation\">\\\\<\/span><br \/>\n  microlite<\/p>\n<p>\u5b9e\u9645 target \u540d\u79f0\u9700\u8981\u6839\u636e\u5e73\u53f0\u6784\u5efa\u6587\u4ef6\u52a0\u5165\u7684\u4f4d\u7f6e\u8c03\u6574\u3002<\/p>\n<p>\u4f18\u5316\u540e\u7aef\u5efa\u8bae\u63d0\u4f9b&#xff1a;<\/p>\n<p>tensorflow\/lite\/micro\/tools\/make\/targets\/your_chip_makefile.inc<br \/>\ntensorflow\/lite\/micro\/tools\/make\/ext_libs\/your_chip_nnlib.inc<br \/>\ntensorflow\/lite\/micro\/tools\/make\/ext_libs\/your_chip_nnlib_download.sh<\/p>\n<p>\u5982\u679c\u4f7f\u7528 Bazel&#xff0c;\u4e5f\u5e94\u63d0\u4f9b\u5bf9\u5e94\u7684 BUILD target \u548c\u5916\u90e8\u4f9d\u8d56\u58f0\u660e\u3002<\/p>\n<h4>\u7248\u672c\u7b56\u7565<\/h4>\n<p>\u8bb0\u5f55\u4ee5\u4e0b\u7248\u672c&#xff1a;<\/p>\n<ul>\n<li>TFLM commit \u6216 release\u3002<\/li>\n<li>schema \u7248\u672c\u3002<\/li>\n<li>\u82af\u7247 SDK \u7248\u672c\u3002<\/li>\n<li>NN library \u7248\u672c\u3002<\/li>\n<li>compiler\/toolchain \u7248\u672c\u3002<\/li>\n<li>firmware\/driver \u7248\u672c\u3002<\/li>\n<li>\u6a21\u578b\u8f6c\u6362\u5de5\u5177\u7248\u672c\u3002<\/li>\n<\/ul>\n<p>TFLM\u3001\u6a21\u578b\u8f6c\u6362\u5668\u548c NN library \u4efb\u4e00\u5347\u7ea7&#xff0c;\u90fd\u5e94\u91cd\u65b0\u8dd1\u6a21\u578b\u517c\u5bb9\u6027\u6d4b\u8bd5\u3002<\/p>\n<h3>12. \u89d2\u8272\u5206\u5de5\u5efa\u8bae<\/h3>\n<table>\n<tr>\u89d2\u8272\u8d1f\u8d23\u5185\u5bb9<\/tr>\n<tbody>\n<tr>\n<td>\u5e73\u53f0\u5de5\u7a0b\u5e08<\/td>\n<td>\u5de5\u5177\u94fe\u3001\u542f\u52a8\u3001\u94fe\u63a5\u3001\u65e5\u5fd7\u3001\u8ba1\u65f6\u3001\u5185\u5b58\u5e03\u5c40\u3002<\/td>\n<\/tr>\n<tr>\n<td>TFLM \u5de5\u7a0b\u5e08<\/td>\n<td>resolver\u3001\u6a21\u578b\u63a5\u5165\u3001kernel wrapper\u3001reference \u5bf9\u9f50\u3002<\/td>\n<\/tr>\n<tr>\n<td>NN library \u5de5\u7a0b\u5e08<\/td>\n<td>\u7b97\u6cd5\u5b9e\u73b0\u3001SIMD\/NPU API\u3001scratch \u548c\u6027\u80fd\u3002<\/td>\n<\/tr>\n<tr>\n<td>driver\/firmware \u5de5\u7a0b\u5e08<\/td>\n<td>\u547d\u4ee4\u63d0\u4ea4\u3001DMA\u3001cache\u3001\u540c\u6b65\u3001\u9519\u8bef\u6062\u590d\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6a21\u578b\u5de5\u7a0b\u5e08<\/td>\n<td>\u6a21\u578b\u8f6c\u6362\u3001\u91cf\u5316\u3001\u8f93\u5165\u9884\u5904\u7406\u3001\u8f93\u51fa\u89e3\u91ca\u3002<\/td>\n<\/tr>\n<tr>\n<td>QA\/\u6027\u80fd\u5de5\u7a0b\u5e08<\/td>\n<td>\u6b63\u786e\u6027\u3001\u56de\u5f52\u3001benchmark\u3001size \u548c\u529f\u8017\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u4e2a kernel \u7684 owner \u5e94\u540c\u65f6\u62e5\u6709&#xff1a;\u63a5\u53e3\u7ea6\u5b9a\u3001\u6d4b\u8bd5\u6570\u636e\u3001benchmark \u548c\u5931\u8d25 case&#xff0c;\u800c\u4e0d\u662f\u53ea\u7ef4\u62a4\u4e00\u4efd .cc \u6587\u4ef6\u3002<\/p>\n<h3>13. \u98ce\u9669\u4e0e\u5e94\u5bf9<\/h3>\n<table>\n<tr>\u98ce\u9669\u65e9\u671f\u4fe1\u53f7\u5e94\u5bf9<\/tr>\n<tbody>\n<tr>\n<td>\u6a21\u578b op \u672a\u8986\u76d6<\/td>\n<td>Missing registration<\/td>\n<td>\u5148\u5206\u6790 operator_codes&#xff0c;\u518d\u8865 resolver\u3002<\/td>\n<\/tr>\n<tr>\n<td>arena \u4e0d\u591f<\/td>\n<td>AllocateTensors() \u5931\u8d25<\/td>\n<td>recording allocator \u5206\u6790 head\/tail\/scratch\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u91cf\u5316\u4e0d\u4e00\u81f4<\/td>\n<td>\u8f93\u51fa\u504f\u5dee\u5927<\/td>\n<td>\u5bf9\u7167 scale\u3001zero point\u3001multiplier\u3001shift\u3002<\/td>\n<\/tr>\n<tr>\n<td>optimized \u4e0d\u7a33\u5b9a<\/td>\n<td>\u53ea\u5728\u67d0\u4e9b shape \u5931\u8d25<\/td>\n<td>\u5efa\u7acb shape\/type\/padding \u53c2\u6570\u77e9\u9635\u6d4b\u8bd5\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u52a0\u901f\u6ca1\u6709\u6536\u76ca<\/td>\n<td>\u5355 op \u5feb\u4f46\u6574\u6a21\u578b\u4e0d\u5feb<\/td>\n<td>\u6d4b\u91cf copy\u3001\u540c\u6b65\u548c\u8c03\u5ea6\u5f00\u9500\u3002<\/td>\n<\/tr>\n<tr>\n<td>DMA\/cache \u9519\u8bef<\/td>\n<td>\u5076\u53d1\u9519\u8bef\u6216\u91cd\u590d\u8fd0\u884c\u5931\u8d25<\/td>\n<td>\u589e\u52a0 alignment\u3001flush\/invalidate \u548c\u538b\u529b\u6d4b\u8bd5\u3002<\/td>\n<\/tr>\n<tr>\n<td>SDK \u5347\u7ea7\u7834\u574f\u6784\u5efa<\/td>\n<td>CI \u7f16\u8bd1\u5931\u8d25<\/td>\n<td>\u56fa\u5b9a\u7248\u672c\u5e76\u4fdd\u5b58\u6784\u5efa manifest\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u53ea\u9a8c\u8bc1 demo<\/td>\n<td>\u4e1a\u52a1\u6a21\u578b\u5931\u8d25<\/td>\n<td>\u5c3d\u65e9\u52a0\u5165\u771f\u5b9e\u4ee3\u8868\u6a21\u578b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>14. \u5de5\u7a0b\u9a8c\u6536\u6807\u51c6<\/h3>\n<h4>\u529f\u80fd\u9a8c\u6536<\/h4>\n<p>[ ] \u81f3\u5c11\u4e00\u4e2a float \u6216 int8 \u6a21\u578b\u53ef\u4ee5\u8fd0\u884c<br \/>\n[ ] \u76ee\u6807\u6a21\u578b\u6240\u6709 op \u90fd\u6709 registration<br \/>\n[ ] AllocateTensors \u548c Invoke \u7a33\u5b9a\u6210\u529f<br \/>\n[ ] \u8f93\u51fa\u4e0e reference \u5728\u7ea6\u5b9a\u8bef\u5dee\u5185<br \/>\n[ ] custom op \u6709\u660e\u786e options \u89e3\u6790<\/p>\n<h4>\u6027\u80fd\u9a8c\u6536<\/h4>\n<p>[ ] \u6709 reference baseline<br \/>\n[ ] \u6709 optimized latency<br \/>\n[ ] \u6709\u6574\u6a21\u578b\u6536\u76ca\u6570\u636e<br \/>\n[ ] \u6709 peak arena \u6570\u636e<br \/>\n[ ] \u6709\u4ee3\u7801\u4f53\u79ef\u548c\u529f\u8017\u6570\u636e<br \/>\n[ ] benchmark \u547d\u4ee4\u53ef\u590d\u73b0<\/p>\n<h4>\u5de5\u7a0b\u9a8c\u6536<\/h4>\n<p>[ ] \u5e73\u53f0\u4ee3\u7801\u548c TFLM \u540e\u7aef\u8fb9\u754c\u6e05\u6670<br \/>\n[ ] NN library \u53ef\u72ec\u7acb\u6d4b\u8bd5<br \/>\n[ ] \u4e0d\u652f\u6301\u7684\u8f93\u5165\u7ec4\u5408\u6709\u660e\u786e\u884c\u4e3a<br \/>\n[ ] CI \u80fd\u963b\u6b62\u529f\u80fd\u548c\u6027\u80fd\u56de\u5f52<br \/>\n[ ] \u7248\u672c\u3001\u5de5\u5177\u94fe\u548c\u6a21\u578b\u6765\u6e90\u6709\u8bb0\u5f55<\/p>\n<h3>15. \u6700\u5c0f\u53ef\u6267\u884c\u8def\u7ebf\u56fe<\/h3>\n<p>\u5982\u679c\u56e2\u961f\u8d44\u6e90\u6709\u9650&#xff0c;\u53ef\u4ee5\u6309\u4ee5\u4e0b\u987a\u5e8f\u843d\u5730&#xff1a;<\/p>\n<p>\u7b2c 1 \u5468&#xff1a;\u5de5\u5177\u94fe\u3001\u94fe\u63a5\u811a\u672c\u3001\u65e5\u5fd7\u3001\u8ba1\u65f6\u3001hello_world<br \/>\n\u7b2c 2 \u5468&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u6a21\u578b reference \u63a8\u7406\u548c\u8f93\u51fa\u6bd4\u5bf9<br \/>\n\u7b2c 3 \u5468&#xff1a;NN library API\u3001\u72ec\u7acb\u6d4b\u8bd5\u3001\u6027\u80fd\u57fa\u7ebf<br \/>\n\u7b2c 4 \u5468&#xff1a;CONV_2D \u6216 FULLY_CONNECTED \u7b2c\u4e00\u4e2a optimized kernel<br \/>\n\u7b2c 5 \u5468&#xff1a;\u6574\u6a21\u578b benchmark\u3001arena \u548c\u9519\u8bef\u5904\u7406<br \/>\n\u7b2c 6 \u5468&#xff1a;\u7b2c\u4e8c\u4e2a\u70ed\u70b9 kernel\u3001CI \u548c\u7248\u672c\u6587\u6863<\/p>\n<p>\u5468\u6570\u53ea\u662f\u7ec4\u7ec7\u65b9\u5f0f&#xff0c;\u4e0d\u80fd\u66ff\u4ee3\u5b9e\u9645\u9a8c\u6536\u6761\u4ef6\u3002\u6a21\u578b\u590d\u6742\u5ea6\u3001\u82af\u7247 SDK \u5b8c\u6574\u5ea6\u548c NPU driver \u72b6\u6001\u90fd\u53ef\u80fd\u6539\u53d8\u5468\u671f\u3002<\/p>\n<h3>16. \u4eca\u5929\u7684\u7cbe\u9ad3<\/h3>\n<p>\u9700\u6c42\u548c\u6a21\u578b<br \/>\n  -&gt; reference bring-up<br \/>\n  -&gt; \u5e73\u53f0\u9002\u914d<br \/>\n  -&gt; \u6a21\u578b\u6b63\u786e\u6027\u95ed\u73af<br \/>\n  -&gt; NN library \u8fb9\u754c<br \/>\n  -&gt; \u7b2c\u4e00\u4e2a optimized kernel<br \/>\n  -&gt; profiling \u9a71\u52a8\u6269\u5c55<br \/>\n  -&gt; CI \u548c\u7248\u672c\u7ef4\u62a4<\/p>\n<p>\u4e00\u53e5\u8bdd\u603b\u7ed3&#xff1a;<\/p>\n<p>AI \u82af\u7247\u63a5\u5165 TFLM \u4e0d\u662f\u628a\u51e0\u4e2a\u7b97\u5b50\u6587\u4ef6\u590d\u5236\u8fdb\u5de5\u7a0b&#xff0c;\u800c\u662f\u5efa\u7acb\u4e00\u6761\u53ef\u9a8c\u8bc1\u7684\u94fe\u8def&#xff1a;\u5e73\u53f0\u80fd\u542f\u52a8&#xff0c;\u6a21\u578b\u80fd\u6b63\u786e\u8fd0\u884c&#xff0c;\u786c\u4ef6\u5b9e\u73b0\u6709\u6e05\u6670\u8fb9\u754c&#xff0c;\u6027\u80fd\u6536\u76ca\u53ef\u91cd\u590d\u6d4b\u91cf&#xff0c;\u7248\u672c\u5347\u7ea7\u4e0d\u4f1a\u6084\u6084\u7834\u574f\u7ed3\u679c\u3002<\/p>\n<h3>17. \u76f8\u5173\u6e90\u7801\u548c\u6587\u6863<\/h3>\n<ul>\n<li>tensorflow\/lite\/micro\/docs\/new_platform_support.md<\/li>\n<li>tensorflow\/lite\/micro\/docs\/optimized_kernel_implementations.md<\/li>\n<li>tensorflow\/lite\/micro\/examples\/hello_world\/hello_world_test.cc<\/li>\n<li>tensorflow\/lite\/micro\/examples\/hello_world\/BUILD<\/li>\n<li>tensorflow\/lite\/micro\/micro_interpreter.cc<\/li>\n<li>tensorflow\/lite\/micro\/micro_mutable_op_resolver.h<\/li>\n<li>tensorflow\/lite\/micro\/kernels\/cmsis_nn\/<\/li>\n<li>tensorflow\/lite\/micro\/tools\/project_generation\/create_tflm_tree.py<\/li>\n<li>tensorflow\/lite\/micro\/tools\/make\/targets\/<\/li>\n<li>tensorflow\/lite\/micro\/tools\/make\/ext_libs\/<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981&#xff1a;\u672c\u6587\u628a\u524d 7 \u5929\u5b66\u5230\u7684 TFLM \u77e5\u8bc6\u6574\u7406\u6210\u4e00\u4efd\u53ef\u6267\u884c\u7684\u5de5\u7a0b\u8ba1\u5212&#xff0c;\u6307\u5bfc\u5982\u4f55\u8ba9\u4e00\u9897\u65b0\u7684 MCU\u3001DSP\u3001NPU \u6216 AI accelerator \u7a33\u5b9a\u8fd0\u884c TFLM \u5e76\u9010\u6b65\u83b7\u5f97\u53ef\u91cf\u5316\u7684\u6027\u80fd\u6536\u76ca\u3002\u6838\u5fc3\u539f\u5219\u662f\u300c\u5148\u8dd1\u901a reference&#xff0c;\u518d\u63a5\u5165\u4f18\u5316&#xff0c;\u6700\u540e\u7528\u6a21\u578b\u548c benchmark \u8bc1\u660e\u6536\u76ca\u300d\u3002\u6587\u7ae0\u6309 8 \u4e2a\u9636\u6bb5\u5c55\u5f00&#xff1a;\u4ece\u9700\u6c42\u4e0e baseline\u3001\u5e73\u53f0 bring-up\u3001reference \u6a21\u578b\u95ed\u73af\u3001NN l<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[997,50,78],"topic":[],"class_list":["post-96004","post","type-post","status-publish","format-standard","hentry","category-server","tag-langchain","tag-50","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8f7b\u677e\u5b66\u4e60TFLM_day8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/96004.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8f7b\u677e\u5b66\u4e60TFLM_day8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6458\u8981&#xff1a;\u672c\u6587\u628a\u524d 7 \u5929\u5b66\u5230\u7684 TFLM \u77e5\u8bc6\u6574\u7406\u6210\u4e00\u4efd\u53ef\u6267\u884c\u7684\u5de5\u7a0b\u8ba1\u5212&#xff0c;\u6307\u5bfc\u5982\u4f55\u8ba9\u4e00\u9897\u65b0\u7684 MCU\u3001DSP\u3001NPU \u6216 AI accelerator \u7a33\u5b9a\u8fd0\u884c TFLM \u5e76\u9010\u6b65\u83b7\u5f97\u53ef\u91cf\u5316\u7684\u6027\u80fd\u6536\u76ca\u3002\u6838\u5fc3\u539f\u5219\u662f\u300c\u5148\u8dd1\u901a reference&#xff0c;\u518d\u63a5\u5165\u4f18\u5316&#xff0c;\u6700\u540e\u7528\u6a21\u578b\u548c benchmark \u8bc1\u660e\u6536\u76ca\u300d\u3002\u6587\u7ae0\u6309 8 \u4e2a\u9636\u6bb5\u5c55\u5f00&#xff1a;\u4ece\u9700\u6c42\u4e0e baseline\u3001\u5e73\u53f0 bring-up\u3001reference \u6a21\u578b\u95ed\u73af\u3001NN l\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/96004.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-27T02:16:29+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/96004.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/96004.html\",\"name\":\"\u8f7b\u677e\u5b66\u4e60TFLM_day8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-27T02:16:29+00:00\",\"dateModified\":\"2026-08-27T02:16:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/96004.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/96004.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/96004.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8f7b\u677e\u5b66\u4e60TFLM_day8\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u8f7b\u677e\u5b66\u4e60TFLM_day8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/96004.html","og_locale":"zh_CN","og_type":"article","og_title":"\u8f7b\u677e\u5b66\u4e60TFLM_day8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6458\u8981&#xff1a;\u672c\u6587\u628a\u524d 7 \u5929\u5b66\u5230\u7684 TFLM \u77e5\u8bc6\u6574\u7406\u6210\u4e00\u4efd\u53ef\u6267\u884c\u7684\u5de5\u7a0b\u8ba1\u5212&#xff0c;\u6307\u5bfc\u5982\u4f55\u8ba9\u4e00\u9897\u65b0\u7684 MCU\u3001DSP\u3001NPU \u6216 AI accelerator \u7a33\u5b9a\u8fd0\u884c TFLM \u5e76\u9010\u6b65\u83b7\u5f97\u53ef\u91cf\u5316\u7684\u6027\u80fd\u6536\u76ca\u3002\u6838\u5fc3\u539f\u5219\u662f\u300c\u5148\u8dd1\u901a reference&#xff0c;\u518d\u63a5\u5165\u4f18\u5316&#xff0c;\u6700\u540e\u7528\u6a21\u578b\u548c benchmark \u8bc1\u660e\u6536\u76ca\u300d\u3002\u6587\u7ae0\u6309 8 \u4e2a\u9636\u6bb5\u5c55\u5f00&#xff1a;\u4ece\u9700\u6c42\u4e0e baseline\u3001\u5e73\u53f0 bring-up\u3001reference \u6a21\u578b\u95ed\u73af\u3001NN l","og_url":"https:\/\/www.wsisp.com\/helps\/96004.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-27T02:16:29+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/96004.html","url":"https:\/\/www.wsisp.com\/helps\/96004.html","name":"\u8f7b\u677e\u5b66\u4e60TFLM_day8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-27T02:16:29+00:00","dateModified":"2026-08-27T02:16:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/96004.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/96004.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/96004.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u8f7b\u677e\u5b66\u4e60TFLM_day8"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/96004","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=96004"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/96004\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=96004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=96004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=96004"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=96004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}