MCPcopy Create free account
hub / github.com/ARM-software/armnn / VisitPooling2dOperator

Function VisitPooling2dOperator

delegate/classic/src/Pooling.hpp:19–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17{
18
19TfLiteStatus VisitPooling2dOperator(DelegateData& delegateData,
20 TfLiteContext* tfLiteContext,
21 TfLiteNode* tfLiteNode,
22 int nodeIndex,
23 int32_t tfLitePoolingOperatorCode)
24{
25 TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
26 TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
27
28 const TfLiteTensor* tfLiteTensors = tfLiteContext->tensors;
29 const TfLiteTensor& tfLiteInputTensor = tfLiteTensors[tfLiteNode->inputs->data[0]];
30 if (IsDynamicTensor(tfLiteInputTensor))
31 {
32 TF_LITE_MAYBE_KERNEL_LOG(
33 tfLiteContext,
34 "TfLiteArmnnDelegate: Dynamic input tensors are not supported in operator #%d node #%d: ",
35 tfLitePoolingOperatorCode, nodeIndex);
36 return kTfLiteError;
37 }
38
39 const TfLiteTensor& tfLiteOutputTensor = tfLiteTensors[tfLiteNode->outputs->data[0]];
40 if (IsDynamicTensor(tfLiteOutputTensor))
41 {
42 TF_LITE_MAYBE_KERNEL_LOG(
43 tfLiteContext,
44 "TfLiteArmnnDelegate: Dynamic output tensors are not supported in operator #%d node #%d: ",
45 tfLitePoolingOperatorCode, nodeIndex);
46 return kTfLiteError;
47 }
48
49 const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteInputTensor);
50 const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteOutputTensor, true);
51
52 auto* tfLiteNodeParameters = reinterpret_cast<TfLitePoolParams*>(tfLiteNode->builtin_data);
53 TfLiteFusedActivation activationType = kTfLiteActNone;
54 if (tfLiteNodeParameters)
55 {
56 activationType = tfLiteNodeParameters->activation;
57 TfLiteStatus activationStatus = ValidateFusedActivationOperator(delegateData, tfLiteContext, outputTensorInfo,
58 outputTensorInfo, activationType);
59 if(activationStatus != kTfLiteOk)
60 {
61 return kTfLiteError;
62 }
63
64 }
65
66 armnn::PoolingAlgorithm poolingAlgorithm;
67 switch(tfLitePoolingOperatorCode)
68 {
69 case kTfLiteBuiltinAveragePool2d:
70 poolingAlgorithm = armnn::PoolingAlgorithm::Average;
71 break;
72 case kTfLiteBuiltinL2Pool2d:
73 poolingAlgorithm = armnn::PoolingAlgorithm::L2;
74 break;
75 case kTfLiteBuiltinMaxPool2d:
76 poolingAlgorithm = armnn::PoolingAlgorithm::Max;

Callers 1

VisitNodeMethod · 0.70

Calls 15

AddPooling2dLayerMethod · 0.80
GetOutputSlotMethod · 0.80
ValidateNumInputsFunction · 0.70
ValidateNumOutputsFunction · 0.70
IsDynamicTensorFunction · 0.70
GetLayerNameFunction · 0.70
ProcessInputsFunction · 0.70
ConnectFunction · 0.70
FusedActivationFunction · 0.70
CalcPaddingFunction · 0.50

Tested by

no test coverage detected