| 11 | { |
| 12 | |
| 13 | TfLiteStatus VisitL2NormalizationOperator(DelegateData& delegateData, |
| 14 | TfLiteOpaqueContext* tfLiteContext, |
| 15 | TfLiteOpaqueNode* tfLiteNode, |
| 16 | int nodeIndex, |
| 17 | int32_t tfLiteL2NormalizationOperatorCode) |
| 18 | { |
| 19 | TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 20 | TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 21 | |
| 22 | // Gather input indices and use to get input tensor. |
| 23 | int numInputs = 0; |
| 24 | const int* inputTensors; |
| 25 | if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk) |
| 26 | { |
| 27 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 28 | tfLiteContext, |
| 29 | "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ", |
| 30 | nodeIndex); |
| 31 | return kTfLiteError; |
| 32 | } |
| 33 | // Use input indices to get input tensor. |
| 34 | const TfLiteOpaqueTensor* tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]); |
| 35 | if (!IsValid(tfLiteContext, tfLiteInputTensor, tfLiteL2NormalizationOperatorCode, nodeIndex)) |
| 36 | { |
| 37 | return kTfLiteError; |
| 38 | } |
| 39 | // Gather output indices and use to get output tensor. |
| 40 | int numOutputs = 0; |
| 41 | const int* outputTensors; |
| 42 | if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors, &numOutputs) != kTfLiteOk) |
| 43 | { |
| 44 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 45 | tfLiteContext, |
| 46 | "TfLiteArmnnOpaqueDelegate: Unable to gather output tensor indices from node #%d: ", |
| 47 | nodeIndex); |
| 48 | return kTfLiteError; |
| 49 | } |
| 50 | // Use output indices to get output tensor. |
| 51 | const TfLiteOpaqueTensor* tfLiteOutputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputTensors[0]); |
| 52 | if (!IsValid(tfLiteContext, tfLiteOutputTensor, tfLiteL2NormalizationOperatorCode, nodeIndex)) |
| 53 | { |
| 54 | return kTfLiteError; |
| 55 | } |
| 56 | |
| 57 | const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor); |
| 58 | const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteOutputTensor, true); |
| 59 | |
| 60 | armnn::L2NormalizationDescriptor descriptor; |
| 61 | descriptor.m_DataLayout = armnn::DataLayout::NHWC; |
| 62 | |
| 63 | bool isSupported = false; |
| 64 | armnn::BackendId setBackend; |
| 65 | auto validateFunc = [&](const armnn::TensorInfo& outInfo, bool& isSupported) |
| 66 | { |
| 67 | FORWARD_LAYER_OPAQUE_SUPPORT_FUNC("L2_NORMALIZATION", |
| 68 | tfLiteContext, |
| 69 | IsL2NormalizationSupported, |
| 70 | delegateData.m_Backends, |
no test coverage detected