| 194 | } |
| 195 | |
| 196 | void dump_output_data(node_t test_node) |
| 197 | { |
| 198 | tensor_t output_tensor = get_node_output_tensor(test_node, 0); |
| 199 | int dims[4]; |
| 200 | |
| 201 | get_tensor_shape(output_tensor, dims, 4); |
| 202 | |
| 203 | void* o_buf = get_tensor_buffer(output_tensor); |
| 204 | int data_type = get_tensor_data_type(output_tensor); |
| 205 | float scale = 0.1f; |
| 206 | int zero = 0; |
| 207 | if(data_type == TENGINE_DT_INT8 || data_type == TENGINE_DT_UINT8) |
| 208 | { |
| 209 | get_tensor_quant_param(output_tensor, &scale, &zero, 1); |
| 210 | printf("output scale: %f ,zero: %d\n", scale, zero); |
| 211 | } |
| 212 | |
| 213 | for(int i = 0; i < dims[1] * dims[0] * dims[2] * dims[3]; i++) |
| 214 | { |
| 215 | if(data_type == TENGINE_DT_FP32) |
| 216 | { |
| 217 | float* p = ( float* )o_buf; |
| 218 | std::cout << i << " " << p[i] << "\n"; |
| 219 | } |
| 220 | else if(data_type == TENGINE_DT_FP16) |
| 221 | { |
| 222 | __fp16* p = ( __fp16* )o_buf; |
| 223 | |
| 224 | #ifdef __ARM_ARCH |
| 225 | std::cout << i << " " << ( float )p[i] << "\n"; |
| 226 | #else |
| 227 | std::cout << i << " " << fp16_to_fp32(p[i]) << "\n"; |
| 228 | #endif |
| 229 | } |
| 230 | else if(data_type == TENGINE_DT_INT8) |
| 231 | { |
| 232 | int8_t* p = ( int8_t* )o_buf; |
| 233 | std::cout << i << " " << ( int )p[i] << "\n"; |
| 234 | } |
| 235 | else |
| 236 | { |
| 237 | uint8_t* p = ( uint8_t* )o_buf; |
| 238 | |
| 239 | std::cout << i << " " << ( int )p[i] << "\n"; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | release_graph_tensor(output_tensor); |
| 244 | } |
| 245 | |
| 246 | int main(int argc, char* argv[]) |
| 247 | { |
no test coverage detected