blob: 4a29db805b3870e70b25fc92ef13750b5b7fa55a [file] [log] [blame]
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +01001/*
Ledion Dajab0aacb42023-02-17 09:37:58 +01002 * SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +01003 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19/****************************************************************************
20 * Includes
21 ****************************************************************************/
22
23#include "command_stream.hpp"
24
25#include <stdio.h>
26
27using namespace std;
28using namespace EthosU::CommandStream;
29
30/****************************************************************************
31 * Data
32 ****************************************************************************/
Anton Moberg908a07c2021-04-08 09:50:57 +020033// clang-format off
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010034__attribute__((section(".sram.data"), aligned(16))) char commandStream[] = {
35 DRIVER_ACTION_MAGIC()
36 DRIVER_ACTION_NOP()
37 DRIVER_ACTION_NOP()
38 DRIVER_ACTION_COMMAND_STREAM(84)
39
40 0x30, 0x01, 0x00, 0x00, // cmd0.NPU_SET_DMA0_SRC_REGION 0 -
41 0x30, 0x40, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, // cmd1.NPU_SET_DMA0_SRC 0 0x00000030 (48)
42 0x31, 0x01, 0x01, 0x00, // cmd0.NPU_SET_DMA0_DST_REGION 1 -
43 0x31, 0x40, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, // cmd1.NPU_SET_DMA0_DST 0 0x00000480 (1152)
44 0x32, 0x40, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // cmd1.NPU_SET_DMA0_LEN 0 0x00000050 (80)
45 0x10, 0x00, 0x00, 0x00, // cmd0.NPU_OP_DMA_START 0 -
46 0x0f, 0x01, 0x01, 0x00, // cmd0.NPU_SET_IFM_REGION 1 -
47 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_IFM_BASE0 0 0x00000000 (0)
48 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_IFM_BASE1 0 0x00000000 (0)
49 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_IFM_BASE2 0 0x00000000 (0)
50 0x03, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_IFM_BASE3 0 0x00000000 (0)
51 0x0b, 0x01, 0x07, 0x00, // cmd0.NPU_SET_IFM_HEIGHT0_M1 7 -
52 0x0c, 0x01, 0x07, 0x00, // cmd0.NPU_SET_IFM_HEIGHT1_M1 7 -
53 0x0a, 0x01, 0x07, 0x00, // cmd0.NPU_SET_IFM_WIDTH0_M1 7 -
54 0x04, 0x01, 0x0f, 0x00, // cmd0.NPU_SET_IFM_DEPTH_M1 15 -
55 0x06, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // cmd1.NPU_SET_IFM_STRIDE_C 0 0x00000001 (1)
56 0x05, 0x40, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, // cmd1.NPU_SET_IFM_STRIDE_Y 0 0x00000080 (128)
57 0x04, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, // cmd1.NPU_SET_IFM_STRIDE_X 0 0x00000010 (16)
58 0x09, 0x01, 0x00, 0x00, // cmd0.NPU_SET_IFM_ZERO_POINT 0 -
59 0x05, 0x01, 0x00, 0x00, // cmd0.NPU_SET_IFM_PRECISION 0 -
60 0x07, 0x01, 0x00, 0x00, // cmd0.NPU_SET_IFM_UPSCALE 0 -
61 0x00, 0x01, 0x00, 0x00, // cmd0.NPU_SET_IFM_PAD_TOP 0 -
62 0x01, 0x01, 0x00, 0x00, // cmd0.NPU_SET_IFM_PAD_LEFT 0 -
63 0x03, 0x01, 0x00, 0x00, // cmd0.NPU_SET_IFM_PAD_BOTTOM 0 -
64 0x02, 0x01, 0x00, 0x00, // cmd0.NPU_SET_IFM_PAD_RIGHT 0 -
65 0x1f, 0x01, 0x01, 0x00, // cmd0.NPU_SET_OFM_REGION 1 -
66 0x10, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // cmd1.NPU_SET_OFM_BASE0 0 0x00000400 (1024)
67 0x11, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_OFM_BASE1 0 0x00000000 (0)
68 0x12, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_OFM_BASE2 0 0x00000000 (0)
69 0x13, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_OFM_BASE3 0 0x00000000 (0)
70 0x1b, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_HEIGHT0_M1 7 -
71 0x1c, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_HEIGHT1_M1 7 -
72 0x1a, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_WIDTH0_M1 7 -
73 0x12, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_HEIGHT_M1 7 -
74 0x11, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_WIDTH_M1 7 -
75 0x13, 0x01, 0x01, 0x00, // cmd0.NPU_SET_OFM_DEPTH_M1 1 -
76 0x16, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // cmd1.NPU_SET_OFM_STRIDE_C 0 0x00000001 (1)
77 0x15, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, // cmd1.NPU_SET_OFM_STRIDE_Y 0 0x00000010 (16)
78 0x14, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // cmd1.NPU_SET_OFM_STRIDE_X 0 0x00000002 (2)
79 0x18, 0x01, 0x00, 0x00, // cmd0.NPU_SET_OFM_ZERO_POINT 0 -
80 0x14, 0x01, 0x00, 0x00, // cmd0.NPU_SET_OFM_PRECISION 0 -
81 0x21, 0x01, 0x00, 0x00, // cmd0.NPU_SET_KERNEL_HEIGHT_M1 0 -
82 0x20, 0x01, 0x00, 0x00, // cmd0.NPU_SET_KERNEL_WIDTH_M1 0 -
83 0x22, 0x01, 0x00, 0x00, // cmd0.NPU_SET_KERNEL_STRIDE 0 -
84 0x28, 0x01, 0x01, 0x00, // cmd0.NPU_SET_WEIGHT_REGION 1 -
85 0x20, 0x40, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, // cmd1.NPU_SET_WEIGHT_BASE 0 0x00000480 (1152)
86 0x21, 0x40, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // cmd1.NPU_SET_WEIGHT_LENGTH 0 0x00000050 (80)
87 0x29, 0x01, 0x00, 0x00, // cmd0.NPU_SET_SCALE_REGION 0 -
88 0x22, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cmd1.NPU_SET_SCALE_BASE 0 0x00000000 (0)
89 0x23, 0x40, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, // cmd1.NPU_SET_SCALE_LENGTH 0 0x00000020 (32)
90 0x25, 0x01, 0x00, 0x00, // cmd0.NPU_SET_ACTIVATION 0 -
91 0x26, 0x01, 0x00, 0x00, // cmd0.NPU_SET_ACTIVATION_MIN 0 -
92 0x27, 0x01, 0xff, 0x00, // cmd0.NPU_SET_ACTIVATION_MAX 255 -
93 0x16, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_BLK_HEIGHT_M1 7 -
94 0x15, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_BLK_WIDTH_M1 7 -
95 0x17, 0x01, 0x07, 0x00, // cmd0.NPU_SET_OFM_BLK_DEPTH_M1 7 -
96 0x0d, 0x01, 0x06, 0x00, // cmd0.NPU_SET_IFM_IB_END 10 -
97 0x2d, 0x01, 0x0e, 0x00, // cmd0.NPU_SET_AB_START 30 -
98 0x24, 0x01, 0x00, 0x00, // cmd0.NPU_SET_ACC_FORMAT 0 -
99 0x2f, 0x01, 0x00, 0x00, // cmd0.NPU_SET_BLOCKDEP 0 -
100 0x11, 0x00, 0x00, 0x00, // cmd0.NPU_OP_DMA_WAIT 0 -
101 0x02, 0x00, 0x00, 0x00, // cmd0.NPU_OP_CONV 0 -
102 0x00, 0x00, 0xff, 0xff, // cmd0.NPU_OP_STOP 65535 -
Anton Moberg908a07c2021-04-08 09:50:57 +0200103}; // clang-format on
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100104
Kristofer Jonssona739d212022-05-05 12:11:52 +0200105__attribute__((section(".sram.data"), aligned(16))) char tflmModel[] = {
Anton Moberg908a07c2021-04-08 09:50:57 +0200106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0xa4, 0x7b, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0xa4, 0x7b,
107 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x5c, 0xe6, 0x4d, 0xf9, 0xef, 0x6f, 0xcf,
109 0x5e, 0x2e, 0xbe, 0x0d, 0xbd, 0x4c, 0xfc, 0x0b, 0xeb, 0xa9, 0x29, 0xd9, 0x27, 0xe7, 0xa4, 0xf4, 0x63, 0xf3, 0x92,
110 0x42, 0x32, 0xa2, 0x81, 0x51, 0x01, 0xc1, 0x00, 0x00, 0xf0, 0xaf, 0xeb, 0xcd, 0xc3, 0xe1, 0x12, 0xb7, 0x44, 0xff,
111 0x4f, 0xbb, 0x39, 0x01, 0x08, 0x9e, 0x96, 0x87, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x4c, 0x35, 0x30, 0x89, 0x1d,
112 0x00, 0xe0, 0xfc, 0xff, 0xbf, 0x1f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100113
Kristofer Jonssona739d212022-05-05 12:11:52 +0200114__attribute__((section(".sram.data"), aligned(16))) char tflmArena[] = {
Anton Moberg908a07c2021-04-08 09:50:57 +0200115 0xac, 0x0a, 0x7f, 0x8c, 0x2f, 0xaa, 0xc4, 0x97, 0x75, 0xa6, 0x16, 0xb7, 0xc0, 0xcc, 0x21, 0xd8, 0x43, 0xb3, 0x4e,
116 0x9a, 0xfb, 0x52, 0xa2, 0xdb, 0xc3, 0x76, 0x7d, 0x8b, 0x67, 0x7d, 0xe5, 0xd8, 0x09, 0xa4, 0x74, 0x6c, 0xd3, 0xde,
117 0xa1, 0x9f, 0x15, 0x51, 0x59, 0xa5, 0xf2, 0xd6, 0x66, 0x62, 0x24, 0xb7, 0x05, 0x70, 0x57, 0x3a, 0x2b, 0x4c, 0x46,
118 0x3c, 0x4b, 0xe4, 0xd8, 0xbd, 0x84, 0x0e, 0x58, 0x9a, 0xb2, 0xf6, 0x8c, 0xcd, 0xcc, 0x45, 0x3a, 0x39, 0x29, 0x62,
119 0xc1, 0x42, 0x48, 0x7a, 0xe6, 0x7d, 0xae, 0xca, 0x27, 0x4a, 0xea, 0xcf, 0x57, 0xa8, 0x65, 0x87, 0xae, 0xc8, 0xdf,
120 0x7a, 0x58, 0x5e, 0x6b, 0x91, 0x51, 0x8b, 0x8d, 0x64, 0xa5, 0xe6, 0xf3, 0xec, 0x19, 0x42, 0x09, 0xd6, 0x4d, 0x6b,
121 0x2f, 0x12, 0x48, 0x98, 0x5f, 0x56, 0x09, 0x1b, 0x4e, 0x16, 0x94, 0x97, 0xee, 0xa5, 0x73, 0x08, 0x2d, 0x05, 0xd0,
122 0x13, 0x45, 0x5e, 0xf3, 0x92, 0x26, 0xd5, 0xc5, 0x1e, 0x08, 0xf5, 0xfe, 0x47, 0x35, 0xc7, 0x4f, 0x07, 0xee, 0x23,
123 0xaf, 0x1d, 0xb9, 0xde, 0xc0, 0x09, 0xbe, 0xde, 0x52, 0xbb, 0x86, 0xfa, 0x63, 0x60, 0x3e, 0x79, 0xd8, 0xa7, 0x95,
124 0xcc, 0xb1, 0x7c, 0x08, 0xcd, 0xf3, 0x82, 0x23, 0x76, 0x1d, 0x03, 0x3e, 0x85, 0x93, 0xc2, 0xd0, 0xc7, 0x93, 0x0c,
125 0xcb, 0xad, 0x8e, 0x3b, 0x47, 0x1e, 0xa7, 0x61, 0x7b, 0xb8, 0x20, 0xdd, 0xd1, 0xa3, 0xc1, 0x3f, 0xff, 0x94, 0x09,
126 0xcd, 0xb2, 0x24, 0xb9, 0x4a, 0x91, 0x89, 0x7f, 0xd2, 0xd5, 0xf1, 0x20, 0xa2, 0x34, 0xc2, 0x1f, 0xda, 0x97, 0x85,
127 0xca, 0xc2, 0x1c, 0x1b, 0xf4, 0x48, 0x27, 0x6a, 0x97, 0xe0, 0x3d, 0x79, 0xa3, 0xea, 0xb9, 0x43, 0xfe, 0x79, 0xb3,
128 0x2f, 0xcb, 0x2d, 0x34, 0xc6, 0x72, 0xab, 0xa6, 0xbc, 0xb7, 0x44, 0xc6, 0x74, 0x1c, 0xd8, 0x6f, 0x37, 0x22, 0xe3,
129 0x84, 0x91, 0x80, 0xa8, 0x9d, 0x22, 0x80, 0x68, 0xcf, 0x04, 0xa4, 0xe7, 0xfa, 0x52, 0x35, 0x5c, 0x1d, 0x9e, 0x85,
130 0x17, 0x51, 0x26, 0x26, 0x4e, 0xb2, 0x9c, 0xe8, 0x0d, 0xea, 0x38, 0xf4, 0x62, 0xef, 0x9d, 0x11, 0xf1, 0xf0, 0x62,
131 0x4f, 0x79,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0x56, 0x8d, 0x8b, 0x41, 0x1c, 0x75, 0x91,
141 0xbc, 0xac, 0x55, 0x37, 0x05, 0xa8, 0x30, 0x22, 0x34, 0x51, 0x31, 0xf5, 0x5f, 0x23, 0x45, 0xa6, 0x41, 0xc7, 0xa9,
142 0x38, 0x53, 0x32, 0xa3, 0x16, 0x17, 0xf3, 0xc0, 0xc5, 0x64, 0x5e, 0x5f, 0x5c, 0x9b, 0xa9, 0xc5, 0x9c, 0x2c, 0xd2,
143 0x5e, 0x6e, 0x79, 0x03, 0x00, 0xa1, 0xdb, 0x18, 0x71, 0xd7, 0x72, 0x9f, 0xb2, 0x8e, 0x83, 0xd6, 0x24, 0xf5, 0x74,
144 0xac, 0xa2, 0xe7, 0x99, 0x18, 0x30, 0x63, 0xd1, 0xf8, 0x5d, 0x3f, 0xf9, 0xf9, 0x83, 0x49, 0xd1, 0xe0, 0x62, 0x86,
145 0xf9, 0x77, 0x2a, 0xbe, 0x76, 0x82, 0xcd, 0x03, 0x0d, 0xfa, 0x70, 0x51, 0x43, 0x0e, 0xe7, 0x27, 0xd7, 0x9a, 0x95,
146 0x2b, 0x7f, 0x73, 0xc9, 0x60, 0x40, 0xbd, 0x7f, 0xe9, 0x1d, 0x05, 0x00, 0x36, 0x08, 0x0a, 0x8a, 0xf7, 0x13, 0x71,
147 0x72, 0x09, 0x66, 0x48, 0x2b, 0x32, 0xc6, 0xfa, 0xba, 0x33, 0xc5, 0x1e, 0x7f, 0x8d, 0x04, 0x5c, 0x17, 0xd8, 0xcf,
148 0x4b, 0xbb, 0xd6, 0x1b, 0x7b, 0x82, 0xf0, 0x64, 0x1e, 0x79, 0x19, 0x4c, 0xb0, 0x62, 0x58, 0x67, 0x51, 0x3e, 0xde,
149 0x66, 0xe1, 0xa3, 0x23, 0x0d, 0x6a, 0xde, 0x7a, 0x11, 0xeb, 0x7b, 0xf8, 0x6b, 0x10, 0xc3, 0xa7, 0x81, 0x37, 0x52,
150 0xda, 0x45, 0xb1, 0xae, 0x37, 0xb0, 0x90, 0xe3, 0xca, 0x0c, 0x91, 0x94, 0x5c, 0x77, 0xdd, 0xd1, 0x90, 0xf0, 0x43,
151 0x32, 0xca, 0x4b, 0x82, 0x9b, 0x95, 0xf3, 0x85, 0x0e, 0x5b, 0xae, 0xea, 0x29, 0x7c, 0x0c, 0x18, 0x3a, 0xfc, 0xd0,
152 0xeb, 0xc1, 0x3a, 0x71, 0x93, 0x24, 0xdc, 0x46, 0x15, 0x0a, 0x5b, 0xe6, 0xed, 0x56, 0x90, 0x18, 0x47, 0x2b, 0xbc,
153 0x8d, 0x51, 0x68, 0x33, 0x65, 0x02, 0x0b, 0x68, 0xdb, 0xaa, 0x02, 0xbb, 0xa3, 0xd7, 0x33, 0x81, 0xbd, 0x21, 0x50,
154 0x34, 0xad, 0xa5, 0x20, 0x38, 0x61, 0xb7, 0xb6, 0x14, 0x65, 0xd7, 0x80, 0x84, 0x16, 0x4a, 0x26, 0x5b, 0xc5, 0x43,
155 0x13, 0xa1, 0xe5, 0x2e, 0xae, 0x94, 0xd7, 0x65, 0x2a, 0xb6, 0x25, 0x96, 0x73, 0xb5, 0x85, 0x8d, 0xb8, 0xc4, 0x25,
156 0x05, 0xbc, 0x89, 0x39, 0x2a, 0xe8, 0x69, 0x35, 0xd4, 0x4d, 0xbe, 0xab, 0x5e, 0x1e, 0xb9, 0x33, 0x01, 0x18, 0x35,
157 0x7d, 0x25, 0x7d, 0x62, 0x85, 0xad, 0x02, 0x83, 0xd2, 0x91, 0x03, 0x3e, 0x1f, 0x45, 0x5e, 0x20, 0x28, 0xb4, 0xe2,
158 0xac, 0x35, 0xbc, 0x6b, 0x97, 0xd9, 0x49, 0x0d, 0xfd, 0x51, 0xf6, 0x70, 0xf7, 0xeb, 0x6e, 0x28, 0x49, 0xae, 0x3f,
159 0x48, 0x35, 0x90, 0xc1, 0x13, 0x0c, 0x7f, 0x93, 0x5f, 0xb2, 0x66, 0x65, 0x48, 0x0f, 0x90, 0x97, 0x9a, 0xc5, 0x62,
160 0xe5, 0xc2, 0x19, 0x7f, 0x92, 0xf8, 0x54, 0x90, 0xa3, 0xb4, 0xe0, 0x1b, 0x39, 0x43, 0xe9, 0x3c, 0xe4, 0xec, 0x5b,
161 0xe7, 0xf3, 0x3d, 0x1f, 0x18, 0xae, 0x0e, 0xcf, 0x76, 0x72, 0x60, 0x9f, 0xfe, 0x72, 0x04, 0x3d, 0xae, 0xd8, 0xc3,
162 0x9f, 0x83, 0xfa, 0xed, 0x12, 0x11, 0xb3, 0x8b, 0x68, 0xbf, 0x1d, 0xfc, 0xd3, 0x24, 0x4c, 0x56, 0xaa, 0x5b, 0xc4,
163 0xcd, 0x0d, 0x55, 0xd0, 0x79, 0x0b, 0x6d, 0x69, 0x6d, 0x66, 0x81, 0x65, 0x4b, 0x93, 0xe9, 0xac, 0xb8, 0xfa, 0x8f,
164 0xe1, 0x10, 0xa6, 0xf2, 0x3f, 0x98, 0x4c, 0xce, 0x94, 0x9d, 0x13, 0x2f, 0x50, 0x95, 0x68, 0xb9, 0xe1, 0x6e, 0x84,
165 0x25, 0xf7, 0x19, 0xc0, 0x49, 0xb1, 0xd0, 0xa5, 0xa5, 0x96, 0xbc, 0x43, 0xaa, 0xb9, 0x79, 0x07, 0xe0, 0xa8, 0x76,
166 0xcb, 0x56, 0x80, 0x75, 0x34, 0x80, 0x88, 0xbd, 0xe5, 0xc1, 0xf4, 0x53, 0x36, 0x04, 0x3b, 0xa1, 0x8a, 0xdc, 0xa4,
167 0x68, 0x27, 0x16, 0x65, 0xa0, 0xc3, 0x81, 0x6c, 0xe4, 0x3c, 0x6a, 0x9e, 0xfb, 0x95, 0x3c, 0x9b, 0xfb, 0xea, 0x90,
168 0x79, 0x79, 0xd8, 0xe9, 0x04, 0x46, 0x95, 0x5a, 0x78, 0xd5, 0x01, 0x34, 0x4d, 0x1f, 0xa9, 0x50, 0xb7, 0x00, 0x00,
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100180
181char input0[] = {
Anton Moberg908a07c2021-04-08 09:50:57 +0200182 0xac, 0x0a, 0x7f, 0x8c, 0x2f, 0xaa, 0xc4, 0x97, 0x75, 0xa6, 0x16, 0xb7, 0xc0, 0xcc, 0x21, 0xd8, 0x43, 0xb3, 0x4e,
183 0x9a, 0xfb, 0x52, 0xa2, 0xdb, 0xc3, 0x76, 0x7d, 0x8b, 0x67, 0x7d, 0xe5, 0xd8, 0x09, 0xa4, 0x74, 0x6c, 0xd3, 0xde,
184 0xa1, 0x9f, 0x15, 0x51, 0x59, 0xa5, 0xf2, 0xd6, 0x66, 0x62, 0x24, 0xb7, 0x05, 0x70, 0x57, 0x3a, 0x2b, 0x4c, 0x46,
185 0x3c, 0x4b, 0xe4, 0xd8, 0xbd, 0x84, 0x0e, 0x58, 0x9a, 0xb2, 0xf6, 0x8c, 0xcd, 0xcc, 0x45, 0x3a, 0x39, 0x29, 0x62,
186 0xc1, 0x42, 0x48, 0x7a, 0xe6, 0x7d, 0xae, 0xca, 0x27, 0x4a, 0xea, 0xcf, 0x57, 0xa8, 0x65, 0x87, 0xae, 0xc8, 0xdf,
187 0x7a, 0x58, 0x5e, 0x6b, 0x91, 0x51, 0x8b, 0x8d, 0x64, 0xa5, 0xe6, 0xf3, 0xec, 0x19, 0x42, 0x09, 0xd6, 0x4d, 0x6b,
188 0x2f, 0x12, 0x48, 0x98, 0x5f, 0x56, 0x09, 0x1b, 0x4e, 0x16, 0x94, 0x97, 0xee, 0xa5, 0x73, 0x08, 0x2d, 0x05, 0xd0,
189 0x13, 0x45, 0x5e, 0xf3, 0x92, 0x26, 0xd5, 0xc5, 0x1e, 0x08, 0xf5, 0xfe, 0x47, 0x35, 0xc7, 0x4f, 0x07, 0xee, 0x23,
190 0xaf, 0x1d, 0xb9, 0xde, 0xc0, 0x09, 0xbe, 0xde, 0x52, 0xbb, 0x86, 0xfa, 0x63, 0x60, 0x3e, 0x79, 0xd8, 0xa7, 0x95,
191 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0x6e, 0x79, 0x03, 0x00, 0xa1, 0xdb, 0x18, 0x71, 0xd7, 0x72, 0x9f, 0xb2, 0x8e, 0x83, 0xd6, 0x24, 0xf5, 0x74,
211 0xac, 0xa2, 0xe7, 0x99, 0x18, 0x30, 0x63, 0xd1, 0xf8, 0x5d, 0x3f, 0xf9, 0xf9, 0x83, 0x49, 0xd1, 0xe0, 0x62, 0x86,
212 0xf9, 0x77, 0x2a, 0xbe, 0x76, 0x82, 0xcd, 0x03, 0x0d, 0xfa, 0x70, 0x51, 0x43, 0x0e, 0xe7, 0x27, 0xd7, 0x9a, 0x95,
213 0x2b, 0x7f, 0x73, 0xc9, 0x60, 0x40, 0xbd, 0x7f, 0xe9, 0x1d, 0x05, 0x00, 0x36, 0x08, 0x0a, 0x8a, 0xf7, 0x13, 0x71,
214 0x72, 0x09, 0x66, 0x48, 0x2b, 0x32, 0xc6, 0xfa, 0xba, 0x33, 0xc5, 0x1e, 0x7f, 0x8d, 0x04, 0x5c, 0x17, 0xd8, 0xcf,
215 0x4b, 0xbb, 0xd6, 0x1b, 0x7b, 0x82, 0xf0, 0x64, 0x1e, 0x79, 0x19, 0x4c, 0xb0, 0x62, 0x58, 0x67, 0x51, 0x3e, 0xde,
216 0x66, 0xe1, 0xa3, 0x23, 0x0d, 0x6a, 0xde, 0x7a, 0x11, 0xeb, 0x7b, 0xf8, 0x6b, 0x10, 0xc3, 0xa7, 0x81, 0x37, 0x52,
217 0xda, 0x45, 0xb1, 0xae, 0x37, 0xb0, 0x90, 0xe3, 0xca, 0x0c, 0x91, 0x94, 0x5c, 0x77, 0xdd, 0xd1, 0x90, 0xf0, 0x43,
218 0x32, 0xca, 0x4b, 0x82, 0x9b, 0x95, 0xf3, 0x85, 0x0e, 0x5b, 0xae, 0xea, 0x29, 0x7c, 0x0c, 0x18, 0x3a, 0xfc, 0xd0,
219 0xeb, 0xc1, 0x3a, 0x71, 0x93, 0x24, 0xdc, 0x46, 0x15, 0x0a, 0x5b, 0xe6, 0xed, 0x56, 0x90, 0x18, 0x47, 0x2b, 0xbc,
220 0x8d, 0x51, 0x68, 0x33, 0x65, 0x02, 0x0b, 0x68, 0xdb, 0xaa, 0x02, 0xbb, 0xa3, 0xd7, 0x33, 0x81, 0xbd, 0x21, 0x50,
221 0x34, 0xad, 0xa5, 0x20, 0x38, 0x61, 0xb7, 0xb6, 0x14, 0x65, 0xd7, 0x80, 0x84, 0x16, 0x4a, 0x26, 0x5b, 0xc5, 0x43,
222 0x13, 0xa1, 0xe5, 0x2e, 0xae, 0x94, 0xd7, 0x65, 0x2a, 0xb6, 0x25, 0x96, 0x73, 0xb5, 0x85, 0x8d, 0xb8, 0xc4, 0x25,
223 0x05, 0xbc, 0x89, 0x39, 0x2a, 0xe8, 0x69, 0x35, 0xd4, 0x4d, 0xbe, 0xab, 0x5e, 0x1e, 0xb9, 0x33, 0x01, 0x18, 0x35,
224 0x7d, 0x25, 0x7d, 0x62, 0x85, 0xad, 0x02, 0x83, 0xd2, 0x91, 0x03, 0x3e, 0x1f, 0x45, 0x5e, 0x20, 0x28, 0xb4, 0xe2,
225 0xac, 0x35, 0xbc, 0x6b, 0x97, 0xd9, 0x49, 0x0d, 0xfd, 0x51, 0xf6, 0x70, 0xf7, 0xeb, 0x6e, 0x28, 0x49, 0xae, 0x3f,
226 0x48, 0x35, 0x90, 0xc1, 0x13, 0x0c, 0x7f, 0x93, 0x5f, 0xb2, 0x66, 0x65, 0x48, 0x0f, 0x90, 0x97, 0x9a, 0xc5, 0x62,
227 0xe5, 0xc2, 0x19, 0x7f, 0x92, 0xf8, 0x54, 0x90, 0xa3, 0xb4, 0xe0, 0x1b, 0x39, 0x43, 0xe9, 0x3c, 0xe4, 0xec, 0x5b,
228 0xe7, 0xf3, 0x3d, 0x1f, 0x18, 0xae, 0x0e, 0xcf, 0x76, 0x72, 0x60, 0x9f, 0xfe, 0x72, 0x04, 0x3d, 0xae, 0xd8, 0xc3,
229 0x9f, 0x83, 0xfa, 0xed, 0x12, 0x11, 0xb3, 0x8b, 0x68, 0xbf, 0x1d, 0xfc, 0xd3, 0x24, 0x4c, 0x56, 0xaa, 0x5b, 0xc4,
230 0xcd, 0x0d, 0x55, 0xd0, 0x79, 0x0b, 0x6d, 0x69, 0x6d, 0x66, 0x81, 0x65, 0x4b, 0x93, 0xe9, 0xac, 0xb8, 0xfa, 0x8f,
231 0xe1, 0x10, 0xa6, 0xf2, 0x3f, 0x98, 0x4c, 0xce, 0x94, 0x9d, 0x13, 0x2f, 0x50, 0x95, 0x68, 0xb9, 0xe1, 0x6e, 0x84,
232 0x25, 0xf7, 0x19, 0xc0, 0x49, 0xb1, 0xd0, 0xa5, 0xa5, 0x96, 0xbc, 0x43, 0xaa, 0xb9, 0x79, 0x07, 0xe0, 0xa8, 0x76,
233 0xcb, 0x56, 0x80, 0x75, 0x34, 0x80, 0x88, 0xbd, 0xe5, 0xc1, 0xf4, 0x53, 0x36, 0x04, 0x3b, 0xa1, 0x8a, 0xdc, 0xa4,
234 0x68, 0x27, 0x16, 0x65, 0xa0, 0xc3, 0x81, 0x6c, 0xe4, 0x3c, 0x6a, 0x9e, 0xfb, 0x95, 0x3c, 0x9b, 0xfb, 0xea, 0x90,
235 0x79, 0x79, 0xd8, 0xe9, 0x04, 0x46, 0x95, 0x5a, 0x78, 0xd5, 0x01, 0x34, 0x4d, 0x1f, 0xa9, 0x50, 0xb7};
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100236
Anton Moberg908a07c2021-04-08 09:50:57 +0200237char expected0[] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x65, 0xff, 0x00, 0xff,
238 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x70, 0xff, 0x50, 0xff, 0x00, 0xff, 0x00, 0xff,
239 0x59, 0xff, 0x88, 0xff, 0x00, 0xff, 0x00, 0xff, 0x31, 0xff, 0x7c, 0xff, 0x00, 0xff, 0x00, 0xff,
240 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x2a, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
241 0x00, 0xff, 0xab, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x73, 0xff,
242 0x00, 0xff, 0x9d, 0xff, 0x00, 0xff, 0x00, 0xff, 0xbe, 0xff, 0xa5, 0xff, 0x00, 0xff, 0x5f, 0xff,
243 0x00, 0xff, 0xbd, 0xff, 0x00, 0xff, 0x3f, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
244 0x00, 0xff, 0x00, 0xff, 0x17, 0xff, 0x00, 0xff, 0x00, 0xff, 0x1f, 0xff, 0x00, 0xff, 0x00, 0xff};
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100245
246/****************************************************************************
247 * Functions
248 ****************************************************************************/
249
250int main() {
Kristofer Jonssona739d212022-05-05 12:11:52 +0200251 /*
252 * The command stream compiled by Vela only uses two base addresses (for a
253 * network without fast scratch).
254 *
255 * The first base address points at the TFLM model. This buffer contains
256 * constant data, like the command stream, weights and biases.
257 *
258 * The second base address points at the TFLM arena. This buffer contains
259 * variable data, like the IFM, OFM, activations etc.
260 *
261 * NOTE! Really important to understand is that the command stream will
262 * access the IFM and OFM buffers using the second base address only.
263 * Consequently the input- and output pointers below are referring to an
264 * offset within the TFLM arena.
265 *
266 * NOTE! The offsets of the IFM and OFM buffers within the TFLM arena
267 * varies between models. They can be found comparing input tensor 4 and
268 * output tensor 0 with the address of the TFLM arena.
269 *
270 * The remaining base addresses are unused.
271 */
272 CommandStream cs(
273 DataPointer(commandStream, sizeof(commandStream)),
274 BasePointers({DataPointer(tflmModel, sizeof(tflmModel)), DataPointer(tflmArena, sizeof(tflmArena))}),
275 PmuEvents({ETHOSU_PMU_CYCLE, ETHOSU_PMU_NPU_IDLE, ETHOSU_PMU_NPU_ACTIVE}));
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100276
277 const size_t repeat = 100;
Jonny Svärd44b250b2022-04-19 15:35:01 +0200278 uint64_t cycleCount = 0;
279 int errors = 0;
280 int res;
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100281
Kristofer Jonssona739d212022-05-05 12:11:52 +0200282 // Input data located inside the arena
283 DataPointer inputPointer(tflmArena, sizeof(input0));
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100284
Kristofer Jonssona739d212022-05-05 12:11:52 +0200285 // Output data located inside the arena
286 DataPointer outputPointer(tflmArena + 1024, sizeof(expected0));
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100287
288 // Expected output data
289 DataPointer expectedPointer(expected0, sizeof(expected0));
290
Ledion Dajab0aacb42023-02-17 09:37:58 +0100291 printf("Running %u iterations using sync API...\n", repeat);
Jonny Svärd44b250b2022-04-19 15:35:01 +0200292
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100293 // Clear PMU
294 cs.getPmu().clear();
295
296 // Run inference
Jonny Svärd44b250b2022-04-19 15:35:01 +0200297 res = cs.run(repeat);
298 if (res == 0) {
299 cycleCount = cs.getPmu().getCycleCount();
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100300
Jonny Svärd44b250b2022-04-19 15:35:01 +0200301 // Print PMU counters
302 cs.getPmu().print();
303 printf("cycleCount=%llu, cycleCountPerJob=%llu\n", cycleCount, cycleCount / repeat);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100304
Jonny Svärd44b250b2022-04-19 15:35:01 +0200305 // Compare output with expected data
306 if (outputPointer != expectedPointer) {
307 printf("Output mismatch for sync test\n");
308 res = 1;
309 }
310 }
311 errors = res;
312 printf("\n");
313
314 // Test using the async API
Ledion Dajab0aacb42023-02-17 09:37:58 +0100315 printf("Running %u iterations using async API...\n", repeat);
Jonny Svärd44b250b2022-04-19 15:35:01 +0200316
317 // Clear PMU
318 cs.getPmu().clear();
319
320 // Dummy wait loop count for inference to complete
321 int wait_loops = 0;
322
323 // Run async job
324 for (size_t r = repeat; r > 0; r--) {
325 res = cs.run_async();
326 if (res != 0) {
327 // Invoke async failed
328 errors++;
329 break;
330 }
331
332 // Wait for inference to complete
333 while ((res = cs.wait_async(false)) == 1) {
334 // CPU is free to do other work while waiting for inference completion
335 wait_loops++;
336 }
337
338 // Check inference result
339 if (res != 0) {
340 printf("Async inference test failed\n");
341 errors++;
342 break;
343 }
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100344 }
345
Jonny Svärd44b250b2022-04-19 15:35:01 +0200346 // Print async results on success
347 if (res == 0) {
348 cycleCount = cs.getPmu().getCycleCount();
349
350 // Print PMU counters
351 cs.getPmu().print();
352 printf("cycleCount=%llu, cycleCountPerJob=%llu\n", cycleCount, cycleCount / repeat);
353
354 printf("wait_loops=%d\n", wait_loops);
355
356 // Compare output with expected data
357 if (outputPointer != expectedPointer) {
358 printf("Output mismatch for async test\n");
359 errors++;
360 }
361 }
362 printf("\n");
363
364 return errors;
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100365}