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

Function VisitL2NormalizationOperator

delegate/classic/src/Normalization.hpp:16–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14{
15
16TfLiteStatus VisitL2NormalizationOperator(DelegateData& delegateData,
17 TfLiteContext* tfLiteContext,
18 TfLiteNode* tfLiteNode,
19 int nodeIndex,
20 int32_t operatorCode)
21{
22 TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
23 TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
24
25 const TfLiteTensor* tfLiteTensors = tfLiteContext->tensors;
26 const TfLiteTensor& tfLiteInputTensor = tfLiteTensors[tfLiteNode->inputs->data[0]];
27 if (!IsValid(tfLiteContext, tfLiteInputTensor, operatorCode, nodeIndex))
28 {
29 return kTfLiteError;
30 }
31
32 const TfLiteTensor& tfLiteOutputTensor = tfLiteTensors[tfLiteNode->outputs->data[0]];
33 if (!IsValid(tfLiteContext, tfLiteOutputTensor, operatorCode, nodeIndex))
34 {
35 return kTfLiteError;
36 }
37
38 const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteInputTensor);
39 const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteOutputTensor, true);
40
41 armnn::L2NormalizationDescriptor descriptor;
42 descriptor.m_DataLayout = armnn::DataLayout::NHWC;
43
44 bool isSupported = false;
45 armnn::BackendId setBackend;
46 auto validateFunc = [&](const armnn::TensorInfo& outInfo, bool& isSupported)
47 {
48 FORWARD_LAYER_SUPPORT_FUNC("L2_NORMALIZATION",
49 tfLiteContext,
50 IsL2NormalizationSupported,
51 delegateData.m_Backends,
52 isSupported,
53 setBackend,
54 inputTensorInfo,
55 outInfo,
56 descriptor);
57 };
58
59 if (!delegateData.m_Network)
60 {
61 validateFunc(outputTensorInfo, isSupported);
62 return isSupported ? kTfLiteOk : kTfLiteError;
63 }
64
65 // Add a L2Normalization layer
66 auto layerName = GetLayerName(armnn::LayerType::L2Normalization, nodeIndex);
67 armnn::IConnectableLayer* layer = delegateData.m_Network->AddL2NormalizationLayer(descriptor, layerName.c_str());
68 layer->SetBackendId(setBackend);
69 ARMNN_ASSERT(layer != nullptr);
70
71 armnn::IOutputSlot& outputSlot = layer->GetOutputSlot(0);
72 outputSlot.SetTensorInfo(outputTensorInfo);
73

Callers 1

VisitNodeMethod · 0.70

Calls 12

GetOutputSlotMethod · 0.80
ValidateNumInputsFunction · 0.70
ValidateNumOutputsFunction · 0.70
IsValidFunction · 0.70
GetLayerNameFunction · 0.70
ProcessInputsFunction · 0.70
ConnectFunction · 0.70
c_strMethod · 0.45
SetBackendIdMethod · 0.45
SetTensorInfoMethod · 0.45

Tested by

no test coverage detected