| 150 | } |
| 151 | |
| 152 | bool WillInputBeOptimizedToConst(TfLiteContext* tfLiteContext, int32_t inputIdx) |
| 153 | { |
| 154 | int32_t connectedIndex; |
| 155 | TfLiteNode* connectedNode = GetNodeConnectedToInput(tfLiteContext, connectedIndex, inputIdx); |
| 156 | |
| 157 | if (connectedNode) |
| 158 | { |
| 159 | TfLiteRegistration* tfLiteRegistration = nullptr; |
| 160 | |
| 161 | if (tfLiteContext->GetNodeAndRegistration(tfLiteContext, connectedIndex, &connectedNode, &tfLiteRegistration) |
| 162 | == kTfLiteOk) |
| 163 | { |
| 164 | switch (tfLiteRegistration->builtin_code) |
| 165 | { |
| 166 | case kTfLiteBuiltinDequantize: |
| 167 | { |
| 168 | if (connectedNode->inputs->size >= 1) |
| 169 | { |
| 170 | const TfLiteTensor* tfLiteTensors = tfLiteContext->tensors; |
| 171 | const TfLiteTensor& tfLiteInputTensor = tfLiteTensors[connectedNode->inputs->data[0]]; |
| 172 | |
| 173 | // If the input to the Dequantize is a Constant then both that Constant layer and the Dequantize |
| 174 | // layer will be replaced by a single Constant layer containing the dequantized values. |
| 175 | if (tflite::IsConstantTensor(&tfLiteInputTensor)) |
| 176 | { |
| 177 | return true; |
| 178 | } |
| 179 | } |
| 180 | break; |
| 181 | } |
| 182 | default: |
| 183 | { |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | return false; |
| 189 | } |
| 190 | |
| 191 | } // namespace armnnDelegate |
| 192 |
no test coverage detected