blob: 0440b584568e365ffd451b4914558402391f13cf [file] [log] [blame]
Davide Grohmannb35f0c62022-06-15 11:23:25 +02001
2/*
3 * Copyright (c) 2022 Arm Limited.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the License); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#ifndef TEST_HELPERS_H
21#define TEST_HELPERS_H
22
23#include <inttypes.h>
24#include <stdio.h>
25
26#include "ethosu_core_interface.h"
27
28namespace MessageHandler {
29
30ethosu_core_network_info_req networkInfoIndexedRequest(uint64_t user_arg, uint32_t index) {
31 ethosu_core_network_info_req req = {user_arg, // user_arg
32 { // network
33 ETHOSU_CORE_NETWORK_INDEX, // type
34 {{
35 index, // index
36 0 // ignored padding of union
37 }}}};
38 return req;
39}
40
41ethosu_core_network_info_req networkInfoBufferRequest(uint64_t user_arg, unsigned char *ptr, uint32_t ptr_size) {
42 ethosu_core_network_info_req req = {user_arg, // user_arg
43 { // network
44 ETHOSU_CORE_NETWORK_BUFFER, // type
45 {{
46 reinterpret_cast<uint32_t>(ptr), // ptr
47 ptr_size // size
48 }}}};
49 return req;
50}
51
52ethosu_core_network_info_rsp networkInfoResponse(uint64_t user_arg) {
53 ethosu_core_network_info_rsp rsp = {
54 user_arg, // user_arg
55 "Vela Optimised", // description
56 1, // ifm_count
57 {/* not comparable */}, // ifm_sizes
58 1, // ofm_count
59 {/* not comparable */}, // ofm_sizes
60 ETHOSU_CORE_STATUS_OK // status
61 };
62 return rsp;
63}
64
65ethosu_core_inference_req inferenceIndexedRequest(uint64_t user_arg,
66 uint32_t index,
67 unsigned char *input_data,
68 uint32_t input_data_size,
69 uint8_t *output_data,
70 uint32_t output_data_size) {
71 ethosu_core_inference_req req = {
72 user_arg, // user_arg
73 1, // ifm_count
74 { // ifm
75 {
76 reinterpret_cast<uint32_t>(input_data), // ptr
77 input_data_size // size
78 }},
79 1, // ofm_count
80 { // ofm
81 {
82 reinterpret_cast<uint32_t>(output_data), // ptr
83 output_data_size // size
84 }},
85 { // network
86 ETHOSU_CORE_NETWORK_INDEX, // type
87 {{
88 index, // index
89 0 // ignored padding of union
90 }}},
91 {0, 0, 0, 0, 0, 0, 0, 0}, // pmu_event_config
92 0 // pmu_cycle_counter_enable
93 };
94 return req;
95}
96
97ethosu_core_inference_req inferenceBufferRequest(uint64_t user_arg,
98 unsigned char *ptr,
99 uint32_t ptr_size,
100 unsigned char *input_data,
101 uint32_t input_data_size,
102 uint8_t *output_data,
103 uint32_t output_data_size) {
104 ethosu_core_inference_req req = {
105 user_arg, // user_arg
106 1, // ifm_count
107 { // ifm
108 {
109 reinterpret_cast<uint32_t>(input_data), // ptr
110 input_data_size // size
111 }},
112 1, // ofm_count
113 { // ofm
114 {
115 reinterpret_cast<uint32_t>(output_data), // ptr
116 output_data_size // size
117 }},
118 { // network
119 ETHOSU_CORE_NETWORK_BUFFER, // type
120 {{
121 reinterpret_cast<uint32_t>(ptr), // ptr
122 ptr_size // size
123 }}},
124 {0, 0, 0, 0, 0, 0, 0, 0}, // pmu_event_config
125 0 // pmu_cycle_counter_enable
126 };
127 return req;
128}
129} // namespace MessageHandler
130
131#endif