| 158 | } |
| 159 | |
| 160 | void* set_input_data(graph_t graph) |
| 161 | { |
| 162 | tensor_t input_tensor = get_graph_input_tensor(graph, 0, 0); |
| 163 | |
| 164 | int buf_size = get_tensor_buffer_size(input_tensor); |
| 165 | // void* i_buf = malloc(buf_size); |
| 166 | |
| 167 | int dims[4]; |
| 168 | |
| 169 | get_tensor_shape(input_tensor, dims, 4); |
| 170 | |
| 171 | #ifdef DIMENSION2 |
| 172 | int elem_num = dims[0] * dims[1]; |
| 173 | #endif |
| 174 | #ifdef DIMENSION3 |
| 175 | int elem_num = dims[0] * dims[1] * dims[2]; |
| 176 | #endif |
| 177 | int data_type = get_tensor_data_type(input_tensor); |
| 178 | |
| 179 | for(int i = 0; i < elem_num; i++) |
| 180 | { |
| 181 | if(data_type == TENGINE_DT_FP32) |
| 182 | { |
| 183 | float* f = ( float* )i_buf; |
| 184 | f[i] = i_buf[i]; |
| 185 | } |
| 186 | else if(data_type == TENGINE_DT_FP16) |
| 187 | { |
| 188 | __fp16* f16 = ( __fp16* )i_buf; |
| 189 | |
| 190 | #ifdef __ARM_ARCH |
| 191 | f16[i] = -1.0; |
| 192 | #else |
| 193 | f16[i] = fp32_to_fp16(-1.1); |
| 194 | #endif |
| 195 | } |
| 196 | else if(data_type == TENGINE_DT_INT8) |
| 197 | { |
| 198 | int8_t* int8 = ( int8_t* )i_buf; |
| 199 | int8[i] = -32; |
| 200 | } |
| 201 | else |
| 202 | { |
| 203 | uint8_t* i8 = ( uint8_t* )i_buf; |
| 204 | i8[i] = 32; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | set_tensor_buffer(input_tensor, i_buf, buf_size); |
| 209 | |
| 210 | release_graph_tensor(input_tensor); |
| 211 | |
| 212 | return i_buf; |
| 213 | } |
| 214 | |
| 215 | void dump_output_data(node_t test_node) |
| 216 | { |
no test coverage detected