| 155 | } |
| 156 | |
| 157 | TfLiteStatus VisitPooling3dOperator(DelegateData& delegateData, |
| 158 | TfLiteOpaqueContext* tfLiteContext, |
| 159 | TfLiteOpaqueNode* tfLiteNode, |
| 160 | int nodeIndex, |
| 161 | std::string customOperatorName) |
| 162 | { |
| 163 | TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 164 | TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 165 | |
| 166 | // Gather input indices and use to get input tensors. |
| 167 | int numInputs = 0; |
| 168 | const int* inputTensors; |
| 169 | if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk) |
| 170 | { |
| 171 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 172 | tfLiteContext, |
| 173 | "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ", |
| 174 | nodeIndex); |
| 175 | return kTfLiteError; |
| 176 | } |
| 177 | |
| 178 | const TfLiteOpaqueTensor* tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]); |
| 179 | if (!IsValid(tfLiteContext, tfLiteInputTensor, kTfLiteBuiltinCustom, nodeIndex)) |
| 180 | { |
| 181 | return kTfLiteError; |
| 182 | } |
| 183 | |
| 184 | // Gather output indices and use to get output tensors. |
| 185 | int numOutputs = 0; |
| 186 | const int* outputTensors; |
| 187 | if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors, &numOutputs) != kTfLiteOk) |
| 188 | { |
| 189 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 190 | tfLiteContext, |
| 191 | "TfLiteArmnnOpaqueDelegate: Unable to gather output tensor indices from node #%d: ", |
| 192 | nodeIndex); |
| 193 | return kTfLiteError; |
| 194 | } |
| 195 | |
| 196 | const TfLiteOpaqueTensor* tfLiteOutputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputTensors[0]); |
| 197 | if (!IsValid(tfLiteContext, tfLiteOutputTensor, kTfLiteBuiltinCustom, nodeIndex)) |
| 198 | { |
| 199 | return kTfLiteError; |
| 200 | } |
| 201 | |
| 202 | // Set the input and output info |
| 203 | const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor); |
| 204 | const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteOutputTensor, true); |
| 205 | |
| 206 | // Custom Operators are defined by the name string associated to the operator. Use this to determine |
| 207 | // which pooling algorithm to create the armnn operator with. L2 Pooling3D is unsupported in TfLite. |
| 208 | armnn::PoolingAlgorithm poolingAlgorithm; |
| 209 | if (customOperatorName == "MaxPool3D") |
| 210 | { |
| 211 | poolingAlgorithm = armnn::PoolingAlgorithm::Max; |
| 212 | } |
| 213 | else if (customOperatorName == "AveragePool3D") |
| 214 | { |
no test coverage detected