MCPcopy Create free account
hub / github.com/OAID/Tengine / test_cast

Function test_cast

internal/bin/test_interp.cpp:194–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194int test_cast(int c, int h, int w, const char* test_node_name, int layout, int data_type, int resize_type)
195{
196 graph_t graph = create_test_graph(test_node_name, c, h, w, layout, data_type, resize_type);
197
198 if(graph == nullptr)
199 return -1;
200
201 /* set input */
202 tensor_t input_tensor = get_graph_input_tensor(graph, 0, 0);
203
204 int buf_size = get_tensor_buffer_size(input_tensor);
205 float* i_buf = ( float* )malloc(buf_size);
206
207 FILE *infp;
208 infp=fopen("./data/interp_in.bin","rb");
209 if(fread(i_buf, sizeof(float), buf_size/sizeof(float), infp)==0)
210 {
211 printf("read input data file failed!\n");
212 return false;
213 }
214 fclose(infp);
215
216 // for(unsigned int i = 0; i < buf_size/sizeof(float) ; i++)
217 // {
218 // i_buf[i] = i;
219 // }
220 set_tensor_buffer(input_tensor, i_buf, buf_size);
221 release_graph_tensor(input_tensor);
222
223 if(prerun_graph(graph) < 0)
224 {
225 std::cerr << "prerun_graph failed: ERRNO: " << get_tengine_errno() << "\n";
226 return 1;
227 }
228 // get device
229 node_t test_node = get_graph_node(graph, test_node_name);
230 // const char* dev = get_node_device(test_node);
231
232 // std::cout << "node running on dev: " << dev << "\n";
233
234 // run graph and time calc
235 int repeat_count = 1;
236 const char * rep_str=std::getenv("REPEAT");
237 if(rep_str)
238 repeat_count=strtoul(rep_str,NULL,10);
239
240 // unsigned long start_time = get_cur_time();
241 for(int i=0;i<repeat_count;i++)
242 {
243 run_graph(graph,1);
244 }
245 // unsigned long end_time = get_cur_time();
246 // unsigned long off_time = end_time - start_time;
247 // std::printf("Repeat [%d] time %.2f us per RUN. used %lu us\n", repeat_count, 1.0f * off_time / repeat_count,
248 // off_time);
249
250
251

Callers 1

mainFunction · 0.70

Calls 15

get_graph_input_tensorFunction · 0.85
get_tensor_buffer_sizeFunction · 0.85
set_tensor_bufferFunction · 0.85
release_graph_tensorFunction · 0.85
prerun_graphFunction · 0.85
get_tengine_errnoFunction · 0.85
get_graph_nodeFunction · 0.85
run_graphFunction · 0.85
get_node_output_tensorFunction · 0.85
get_tensor_bufferFunction · 0.85
release_graph_nodeFunction · 0.85
postrun_graphFunction · 0.85

Tested by

no test coverage detected