| 131 | } |
| 132 | |
| 133 | graph_t create_test_graph(const char* test_node_name, int c, int h, int w, int layout, int data_type) |
| 134 | { |
| 135 | graph_t graph = create_graph(nullptr, nullptr, nullptr); |
| 136 | |
| 137 | if(graph == nullptr) |
| 138 | { |
| 139 | std::cerr << "create failed: ERRNO: " << get_tengine_errno() << "\n"; |
| 140 | return nullptr; |
| 141 | } |
| 142 | |
| 143 | if(set_graph_layout(graph, layout) < 0) |
| 144 | { |
| 145 | std::cerr << "set layout failed: ERRNO: " << get_tengine_errno() << "\n"; |
| 146 | return nullptr; |
| 147 | } |
| 148 | |
| 149 | const char* input_name = "data"; |
| 150 | |
| 151 | if(create_input_node(graph, input_name, c, h, w, data_type) < 0) |
| 152 | { |
| 153 | std::cerr << "create input failed\n"; |
| 154 | return nullptr; |
| 155 | } |
| 156 | |
| 157 | if(create_test_node(graph, test_node_name, input_name) < 0) |
| 158 | { |
| 159 | std::cerr << "create test node failed\n"; |
| 160 | return nullptr; |
| 161 | } |
| 162 | |
| 163 | /* set input/output node */ |
| 164 | const char* inputs[] = {input_name}; |
| 165 | const char* outputs[] = {test_node_name}; |
| 166 | |
| 167 | if(set_graph_input_node(graph, inputs, sizeof(inputs) / sizeof(char*)) < 0) |
| 168 | { |
| 169 | std::cerr << "set inputs failed: ERRNO: " << get_tengine_errno() << "\n"; |
| 170 | return nullptr; |
| 171 | } |
| 172 | |
| 173 | if(set_graph_output_node(graph, outputs, sizeof(outputs) / sizeof(char*)) < 0) |
| 174 | { |
| 175 | std::cerr << "set outputs failed: ERRNO: " << get_tengine_errno() << "\n"; |
| 176 | return nullptr; |
| 177 | } |
| 178 | |
| 179 | return graph; |
| 180 | } |
| 181 | |
| 182 | void* set_input_data(graph_t graph) |
| 183 | { |
no test coverage detected