| 110 | } |
| 111 | |
| 112 | std::vector<DebugLayer*> InsertDebugLayerAfter(Graph& graph, Layer& layer, bool toFile) |
| 113 | { |
| 114 | std::vector<DebugLayer*> debugLayers; |
| 115 | debugLayers.reserve(layer.GetNumOutputSlots()); |
| 116 | |
| 117 | // Connect a DebugLayer to each output slot of the layer |
| 118 | uint32_t outputSlotIdx = 0; |
| 119 | for (auto outputSlot = layer.BeginOutputSlots(); outputSlot != layer.EndOutputSlots(); ++outputSlot) |
| 120 | { |
| 121 | const std::string debugName = std::string("DebugLayerAfter") + layer.GetNameStr() + "_" + |
| 122 | std::to_string(outputSlotIdx); |
| 123 | |
| 124 | DebugLayer* debugLayer = |
| 125 | graph.InsertNewLayer<DebugLayer>(*outputSlot, debugName.c_str(), toFile); |
| 126 | |
| 127 | // Sets output tensor info for the debug layer. |
| 128 | if (debugLayer->GetInputSlot(0).GetConnectedOutputSlot() != &(*outputSlot)) |
| 129 | { |
| 130 | throw armnn::Exception("unable to set output tensor info for the debug layer."); |
| 131 | } |
| 132 | |
| 133 | TensorInfo debugInfo = debugLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(); |
| 134 | |
| 135 | debugLayer->GetOutputSlot().SetTensorInfo(debugInfo); |
| 136 | |
| 137 | // NOTE: It is OK to do this because DebugLayer is only supported on CpuRef |
| 138 | debugLayer->SetBackendId(Compute::CpuRef); |
| 139 | |
| 140 | debugLayers.emplace_back(debugLayer); |
| 141 | |
| 142 | ++outputSlotIdx; |
| 143 | } |
| 144 | |
| 145 | return debugLayers; |
| 146 | } |
| 147 | |
| 148 | } // namespace armnn |
no test coverage detected