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

Function test_new_operator

internal/tests/executor/tests/test_fc.cpp:194–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194void test_new_operator(int rep)
195{
196 Node* node0 = create_fc_node();
197 Node* node1 = create_fc_node();
198
199 caffe_run_fully_connected(node0, 0, nullptr);
200
201 SocInfo* soc_info = TestGetSocInfo();
202 NodeOps* fc_ops = NodeOpsRegistryManager::FindNodeOps(soc_info, node1);
203
204 fc_ops->SetHelper(std::malloc, std::free, nullptr);
205
206 if(!fc_ops->Prerun(node1))
207 {
208 std::cout << "Prerun failed\n";
209 }
210
211 if(!fc_ops->Run(node1))
212 {
213 std::cout << "Run failed\n";
214 }
215
216 /* compare date */
217
218 Tensor* tensor = node0->GetOutputTensor(0);
219 float* data0 = ( float* )get_tensor_mem(tensor);
220
221 tensor = node1->GetOutputTensor(0);
222
223 float* data1 = ( float* )get_tensor_mem(tensor);
224
225 std::vector<int> output_dim = tensor->GetShape().GetDim();
226
227 std::vector<int> mismatch;
228
229 if(!CompareFloatTensor(data0, data1, output_dim, mismatch))
230 {
231 std::cout << "MISMATCH: ";
232 for(unsigned int i = 0; i < mismatch.size(); i++)
233 std::cout << " " << mismatch[i];
234 std::cout << "\n";
235
236 DumpFloat("/tmp/data0", data0, tensor->GetShape().GetSize());
237 DumpFloat("/tmp/data1", data1, tensor->GetShape().GetSize());
238
239 return;
240 }
241
242 /* performance benchmark ... */
243
244 unsigned long start = get_cur_time();
245
246 for(int i = 0; i < rep; i++)
247 fc_ops->Run(node1);
248
249 unsigned long end = get_cur_time();
250
251 std::printf("OUR IMPLEMENTATION ...\n");

Callers 1

mainFunction · 0.70

Calls 13

create_fc_nodeFunction · 0.85
get_tensor_memFunction · 0.85
CompareFloatTensorFunction · 0.85
SetHelperMethod · 0.80
DumpFloatFunction · 0.50
get_cur_timeFunction · 0.50
PrerunMethod · 0.45
RunMethod · 0.45
GetOutputTensorMethod · 0.45
sizeMethod · 0.45
GetSizeMethod · 0.45
PostrunMethod · 0.45

Tested by

no test coverage detected