MCPcopy Create free account
hub / github.com/ARM-software/armnn / TestGraphAfterAddingCopyLayers

Function TestGraphAfterAddingCopyLayers

src/armnn/test/GraphTests.cpp:274–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274static void TestGraphAfterAddingCopyLayers(const armnn::Graph& graph, const armnn::Graph& origGraph)
275{
276 std::vector<Edge> origEdges = GetEdgeList(origGraph);
277 std::vector<Edge> newEdges = GetEdgeList(graph);
278
279 // Adding copy layers should not produce any duplicate edges.
280 {
281 std::vector<Edge> sortedNewEdges = newEdges;
282 std::sort(sortedNewEdges.begin(), sortedNewEdges.end());
283
284 auto last = std::unique(sortedNewEdges.begin(), sortedNewEdges.end());
285 CHECK_MESSAGE(last == sortedNewEdges.end(), "New graph contains duplicate edges!");
286 }
287
288 // Each new edge must be tested.
289 while (!newEdges.empty())
290 {
291 const Edge edge = std::move(newEdges.back());
292 newEdges.pop_back();
293
294 // Edge present in the original graph?
295 int originalEdge = -1;
296 for (unsigned int i = 0; i < origEdges.size(); i++)
297 {
298 const Edge& origEdge = origEdges[i];
299 if (origEdge.first->GetNameStr() == edge.first->GetNameStr() &&
300 origEdge.second->GetNameStr() == edge.second->GetNameStr())
301 {
302 originalEdge = armnn::numeric_cast<int>(i);
303 }
304 }
305
306 if (originalEdge != -1)
307 {
308 // Each vertex should correspond to a layer.
309 const armnn::Layer* srcLayer = edge.first;
310 const armnn::Layer* dstLayer = edge.second;
311 CHECK(srcLayer);
312 CHECK(dstLayer);
313
314 // Both layers must have the same compute device.
315 if (srcLayer && dstLayer)
316 {
317 CHECK((srcLayer->GetBackendId() == dstLayer->GetBackendId()));
318 }
319
320 // Marks edge in original graph as observed (by deleting it).
321 origEdges.erase(origEdges.begin() + originalEdge);
322 }
323 else
324 {
325 // Edge did not exist in the original graph.
326 // It must then be an edge connecting a layer and a copy layer.
327 const armnn::Layer* srcLayer = edge.first;
328 const armnn::Layer* dstLayer = edge.second;
329
330 if (srcLayer == nullptr || dstLayer == nullptr)
331 {

Callers 1

GraphTests.cppFile · 0.85

Calls 9

GetEdgeListFunction · 0.85
GraphHasNamedLayerFunction · 0.85
emptyMethod · 0.80
push_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
GetBackendIdMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected