| 111 | } |
| 112 | |
| 113 | TfLiteNode* GetNodeConnectedToInput(TfLiteContext* tfLiteContext, |
| 114 | int32_t& connectedIndex, |
| 115 | int32_t inputIdx) |
| 116 | { |
| 117 | TfLiteIntArray* executionPlan = nullptr; |
| 118 | if (tfLiteContext->GetExecutionPlan(tfLiteContext, &executionPlan) != kTfLiteOk) |
| 119 | { |
| 120 | TF_LITE_KERNEL_LOG(tfLiteContext, "TfLiteArmnnDelegate: Unable to get graph execution plan."); |
| 121 | return nullptr; |
| 122 | } |
| 123 | |
| 124 | for (int i = 0; i < executionPlan->size; ++i) |
| 125 | { |
| 126 | connectedIndex = executionPlan->data[i]; |
| 127 | |
| 128 | // If TfLite nodes can be delegated to ArmNN |
| 129 | TfLiteNode* connectedNode = nullptr; |
| 130 | TfLiteRegistration* tfLiteRegistration = nullptr; |
| 131 | if (tfLiteContext->GetNodeAndRegistration( |
| 132 | tfLiteContext, connectedIndex, &connectedNode, &tfLiteRegistration) != kTfLiteOk) |
| 133 | { |
| 134 | TF_LITE_KERNEL_LOG(tfLiteContext, |
| 135 | "TfLiteArmnnDelegate: Unable to get node and registration for node %d.", |
| 136 | connectedIndex); |
| 137 | continue; |
| 138 | } |
| 139 | for (int j= 0; j < connectedNode->outputs->size; ++j) |
| 140 | { |
| 141 | if (connectedNode->outputs->data[j] == inputIdx) |
| 142 | { |
| 143 | return connectedNode; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | // No node found so set connectedIndex to -1 |
| 148 | connectedIndex = -1; |
| 149 | return nullptr; |
| 150 | } |
| 151 | |
| 152 | bool WillInputBeOptimizedToConst(TfLiteContext* tfLiteContext, int32_t inputIdx) |
| 153 | { |
no outgoing calls
no test coverage detected