| 14 | { |
| 15 | |
| 16 | TfLiteStatus VisitPooling2dOperator(DelegateData& delegateData, |
| 17 | TfLiteOpaqueContext* tfLiteContext, |
| 18 | TfLiteOpaqueNode* tfLiteNode, |
| 19 | int nodeIndex, |
| 20 | int32_t tfLitePoolingOperatorCode) |
| 21 | { |
| 22 | TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 23 | TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 24 | |
| 25 | // Gather input indices and use to get input tensors. |
| 26 | int numInputs = 0; |
| 27 | const int* inputTensors; |
| 28 | if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk) |
| 29 | { |
| 30 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 31 | tfLiteContext, |
| 32 | "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ", |
| 33 | nodeIndex); |
| 34 | return kTfLiteError; |
| 35 | } |
| 36 | |
| 37 | const TfLiteOpaqueTensor* tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]); |
| 38 | if (!IsValid(tfLiteContext, tfLiteInputTensor, tfLitePoolingOperatorCode, nodeIndex)) |
| 39 | { |
| 40 | return kTfLiteError; |
| 41 | } |
| 42 | |
| 43 | // Gather output indices and use to get output tensors. |
| 44 | int numOutputs = 0; |
| 45 | const int* outputTensors; |
| 46 | if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors, &numOutputs) != kTfLiteOk) |
| 47 | { |
| 48 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 49 | tfLiteContext, |
| 50 | "TfLiteArmnnOpaqueDelegate: Unable to gather output tensor indices from node #%d: ", |
| 51 | nodeIndex); |
| 52 | return kTfLiteError; |
| 53 | } |
| 54 | |
| 55 | const TfLiteOpaqueTensor* tfLiteOutputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputTensors[0]); |
| 56 | if (!IsValid(tfLiteContext, tfLiteOutputTensor, tfLitePoolingOperatorCode, nodeIndex)) |
| 57 | { |
| 58 | return kTfLiteError; |
| 59 | } |
| 60 | |
| 61 | const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor); |
| 62 | const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteOutputTensor, true); |
| 63 | |
| 64 | auto* tfLiteNodeParameters = reinterpret_cast<TfLitePoolParams*>(TfLiteOpaqueNodeGetBuiltinData(tfLiteNode)); |
| 65 | TfLiteFusedActivation activationType = kTfLiteActNone; |
| 66 | if (tfLiteNodeParameters) |
| 67 | { |
| 68 | activationType = tfLiteNodeParameters->activation; |
| 69 | TfLiteStatus activationStatus = ValidateFusedActivationOperator(delegateData, |
| 70 | tfLiteContext, |
| 71 | outputTensorInfo, |
| 72 | outputTensorInfo, |
| 73 | activationType); |
no test coverage detected