| 23 | } |
| 24 | |
| 25 | void output_data_info(std::shared_ptr<Network> network, size_t output_size) { |
| 26 | for (size_t index = 0; index < output_size; index++) { |
| 27 | auto output_tensor = network->get_output_tensor(index); |
| 28 | void* out_data = output_tensor->get_memory_ptr(); |
| 29 | size_t out_length = output_tensor->get_tensor_total_size_in_byte() / |
| 30 | output_tensor->get_layout().get_elem_size(); |
| 31 | LiteDataType dtype = output_tensor->get_layout().data_type; |
| 32 | float max = -1000.0f; |
| 33 | float min = 1000.0f; |
| 34 | int max_idx = 0; |
| 35 | int min_idx = 0; |
| 36 | float sum = 0.0f; |
| 37 | #define cb(_dtype, _real_dtype) \ |
| 38 | case LiteDataType::_dtype: { \ |
| 39 | for (size_t i = 0; i < out_length; i++) { \ |
| 40 | _real_dtype data = static_cast<_real_dtype*>(out_data)[i]; \ |
| 41 | sum += data; \ |
| 42 | if (max < data) { \ |
| 43 | max = data; \ |
| 44 | max_idx = i; \ |
| 45 | } \ |
| 46 | if (min > data) { \ |
| 47 | min = data; \ |
| 48 | min_idx = i; \ |
| 49 | } \ |
| 50 | } \ |
| 51 | } break; |
| 52 | |
| 53 | switch (dtype) { |
| 54 | cb(LITE_FLOAT, float); |
| 55 | cb(LITE_INT, int); |
| 56 | cb(LITE_INT8, int8_t); |
| 57 | cb(LITE_UINT8, uint8_t); |
| 58 | default: |
| 59 | printf("unknow datatype"); |
| 60 | } |
| 61 | printf("output_length %zu index %zu max=%e , max idx=%d, min=%e , min_idx=%d, " |
| 62 | "sum=%e\n", |
| 63 | out_length, index, max, max_idx, min, min_idx, sum); |
| 64 | } |
| 65 | #undef cb |
| 66 | } |
| 67 | } // namespace |
| 68 | |
| 69 | namespace { |
no test coverage detected