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

Function main

tests/bin/test_convert_calibration.cpp:56–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56int main(int argc, char* argv[])
57{
58 int res;
59
60 while((res = getopt(argc, argv, "r:")) != -1)
61 {
62 switch(res)
63 {
64 case 'r':
65 repeat_count = strtoul(optarg, NULL, 10);
66 break;
67 default:
68 break;
69 }
70 }
71
72 // const char * model_name="mobilenet";
73 int img_h = 224;
74 int img_w = 224;
75
76 /* prepare input data */
77 float* input_data = ( float* )malloc(sizeof(float) * img_h * img_w * 3);
78 get_input_data(image_file, input_data, img_h, img_w, channel_mean, 0.017);
79 int img_size = img_h * img_w * 3;
80 float in_scale = 0;
81 int in_zero = 0;
82 init_tengine();
83
84 if(request_tengine_version("0.9") < 0)
85 return 1;
86
87 graph_t graph = create_graph(nullptr, "tengine", text_file);
88
89 if(graph == nullptr)
90 {
91 std::cout << "Create graph0 failed\n";
92 return -1;
93 }
94
95 /* get input tensor */
96 int node_idx = 0;
97 int tensor_idx = 0;
98
99 tensor_t input_tensor = get_graph_input_tensor(graph, node_idx, tensor_idx);
100 if(input_tensor == nullptr)
101 {
102 std::printf("Cannot find input tensor,node_idx: %d,tensor_idx: %d\n", node_idx, tensor_idx);
103 return -1;
104 }
105
106 get_tensor_quant_param(input_tensor,&in_scale,&in_zero,1);
107
108 int8_t * input_s8 = (int8_t*)malloc(sizeof(int8_t) * img_size);
109
110 for(int i = 0; i < img_size;i++)
111 {
112 input_s8[i] = round(input_data[i] / in_scale);
113 }

Callers

nothing calls this directly

Calls 15

init_tengineFunction · 0.85
request_tengine_versionFunction · 0.85
create_graphFunction · 0.85
get_graph_input_tensorFunction · 0.85
get_tensor_quant_paramFunction · 0.85
set_tensor_shapeFunction · 0.85
set_tensor_data_typeFunction · 0.85
set_tensor_bufferFunction · 0.85
prerun_graphFunction · 0.85
run_graphFunction · 0.85
get_graph_output_tensorFunction · 0.85
get_tensor_shapeFunction · 0.85

Tested by

no test coverage detected