| 54 | } |
| 55 | |
| 56 | int 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 | } |
nothing calls this directly
no test coverage detected