| 18 | constexpr unsigned int MaxNumOfTensorDimensions = 5U; |
| 19 | |
| 20 | TfLiteStatus VisitSplitOperator(DelegateData& delegateData, |
| 21 | TfLiteOpaqueContext* tfLiteContext, |
| 22 | TfLiteOpaqueNode* tfLiteNode, |
| 23 | int nodeIndex, |
| 24 | int32_t tfLiteSplitOperatorCode) |
| 25 | { |
| 26 | TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 2, nodeIndex)); |
| 27 | |
| 28 | auto* splitParameters = reinterpret_cast<TfLiteSplitParams*>(TfLiteOpaqueNodeGetBuiltinData(tfLiteNode)); |
| 29 | int numSplits = NonNegative(splitParameters->num_splits, nodeIndex); |
| 30 | |
| 31 | TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, numSplits, nodeIndex)); |
| 32 | |
| 33 | // Gather input indices and use to get Axis tensor. |
| 34 | const int* inputTensors; |
| 35 | auto numInputs = TfLiteOpaqueNodeNumberOfInputs(tfLiteNode); |
| 36 | if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk) |
| 37 | { |
| 38 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 39 | tfLiteContext, |
| 40 | "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ", |
| 41 | nodeIndex); |
| 42 | return kTfLiteError; |
| 43 | } |
| 44 | |
| 45 | const TfLiteOpaqueTensor* tfLiteAxisTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]); |
| 46 | if (!IsValid(tfLiteContext, tfLiteAxisTensor, tfLiteSplitOperatorCode, nodeIndex)) |
| 47 | { |
| 48 | return kTfLiteError; |
| 49 | } |
| 50 | |
| 51 | // Use input indices to get input tensor. |
| 52 | const TfLiteOpaqueTensor* tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[1]); |
| 53 | if (!IsValid(tfLiteContext, tfLiteInputTensor, tfLiteSplitOperatorCode, nodeIndex)) |
| 54 | { |
| 55 | return kTfLiteError; |
| 56 | } |
| 57 | |
| 58 | // Gather output indices and use to get output tensors. |
| 59 | const int* outputTensors; |
| 60 | if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors, &numSplits) != kTfLiteOk) |
| 61 | { |
| 62 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 63 | tfLiteContext, |
| 64 | "TfLiteArmnnOpaqueDelegate: Unable to gather output tensor indices from node #%d: ", |
| 65 | nodeIndex); |
| 66 | return kTfLiteError; |
| 67 | } |
| 68 | |
| 69 | const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor); |
| 70 | |
| 71 | if (GetTensorInfoForTfLiteOpaqueTensor(tfLiteAxisTensor).GetNumElements() != 1) |
| 72 | { |
| 73 | return kTfLiteError; |
| 74 | } |
| 75 | |
| 76 | auto* axisTensorDataPtr = static_cast<uint32_t*>(TfLiteOpaqueTensorData(tfLiteAxisTensor)); |
| 77 | std::vector<int32_t> axisTensorData(axisTensorDataPtr, axisTensorDataPtr + 1); |
no test coverage detected