| 131 | } |
| 132 | |
| 133 | void* set_input_data(graph_t graph) |
| 134 | { |
| 135 | tensor_t input_tensor = get_graph_input_tensor(graph, 0, 0); |
| 136 | |
| 137 | int buf_size = get_tensor_buffer_size(input_tensor); |
| 138 | void* i_buf = malloc(buf_size); |
| 139 | |
| 140 | int dims[4]; |
| 141 | |
| 142 | get_tensor_shape(input_tensor, dims, 4); |
| 143 | |
| 144 | int elem_num = dims[0] * dims[1]; |
| 145 | int data_type = get_tensor_data_type(input_tensor); |
| 146 | |
| 147 | for(int i = 0; i < elem_num; i++) |
| 148 | { |
| 149 | if(data_type == TENGINE_DT_FP32) |
| 150 | { |
| 151 | float* f = ( float* )i_buf; |
| 152 | f[i] = -1.1; |
| 153 | } |
| 154 | else if(data_type == TENGINE_DT_FP16) |
| 155 | { |
| 156 | __fp16* f16 = ( __fp16* )i_buf; |
| 157 | |
| 158 | #ifdef __ARM_ARCH |
| 159 | f16[i] = -1.0; |
| 160 | #else |
| 161 | f16[i] = fp32_to_fp16(-1.1); |
| 162 | #endif |
| 163 | } |
| 164 | else if(data_type == TENGINE_DT_INT8) |
| 165 | { |
| 166 | int8_t* int8 = ( int8_t* )i_buf; |
| 167 | int8[i] = -32; |
| 168 | } |
| 169 | else |
| 170 | { |
| 171 | uint8_t* i8 = ( uint8_t* )i_buf; |
| 172 | i8[i] = 32; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | set_tensor_buffer(input_tensor, i_buf, buf_size); |
| 177 | |
| 178 | release_graph_tensor(input_tensor); |
| 179 | |
| 180 | return i_buf; |
| 181 | } |
| 182 | |
| 183 | void dump_output_data(node_t test_node) |
| 184 | { |
no test coverage detected