| 209 | } |
| 210 | |
| 211 | TfLiteStatus VisitSplitVOperator(DelegateData& delegateData, |
| 212 | TfLiteOpaqueContext* tfLiteContext, |
| 213 | TfLiteOpaqueNode* tfLiteNode, |
| 214 | int nodeIndex, |
| 215 | int32_t tfLiteSplitVOperatorCode) |
| 216 | { |
| 217 | |
| 218 | TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 3, nodeIndex)); |
| 219 | |
| 220 | const int* inputTensors; |
| 221 | auto numInputs = TfLiteOpaqueNodeNumberOfInputs(tfLiteNode); |
| 222 | if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk) |
| 223 | { |
| 224 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 225 | tfLiteContext, |
| 226 | "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ", |
| 227 | nodeIndex); |
| 228 | return kTfLiteError; |
| 229 | } |
| 230 | |
| 231 | const TfLiteOpaqueTensor* tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]); |
| 232 | if (!IsValid(tfLiteContext, tfLiteInputTensor, tfLiteSplitVOperatorCode, nodeIndex)) |
| 233 | { |
| 234 | return kTfLiteError; |
| 235 | } |
| 236 | |
| 237 | const TfLiteOpaqueTensor* tfLiteSplitsTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[1]); |
| 238 | if (!IsValid(tfLiteContext, tfLiteSplitsTensor, tfLiteSplitVOperatorCode, nodeIndex)) |
| 239 | { |
| 240 | return kTfLiteError; |
| 241 | } |
| 242 | |
| 243 | const TfLiteOpaqueTensor* tfLiteAxisTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[2]); |
| 244 | if (!IsValid(tfLiteContext, tfLiteAxisTensor, tfLiteSplitVOperatorCode, nodeIndex)) |
| 245 | { |
| 246 | return kTfLiteError; |
| 247 | } |
| 248 | |
| 249 | const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor); |
| 250 | const armnn::TensorInfo& splitsTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteSplitsTensor); |
| 251 | |
| 252 | if (splitsTensorInfo.GetNumDimensions() != 1) |
| 253 | { |
| 254 | return kTfLiteError; |
| 255 | } |
| 256 | |
| 257 | if (GetTensorInfoForTfLiteOpaqueTensor(tfLiteAxisTensor).GetNumElements() != 1) |
| 258 | { |
| 259 | return kTfLiteError; |
| 260 | } |
| 261 | |
| 262 | auto* axisTensorDataPtr = static_cast<uint32_t*>(TfLiteOpaqueTensorData(tfLiteAxisTensor)); |
| 263 | std::vector<int32_t> axisTensorData(axisTensorDataPtr, axisTensorDataPtr + 1); |
| 264 | int32_t axis = axisTensorData[0]; |
| 265 | |
| 266 | auto inputDimensions = static_cast<int32_t>(inputTensorInfo.GetNumDimensions()); |
| 267 | if (((axis < -inputDimensions) && (axis < 0)) || ((axis >= inputDimensions) && (axis > 0))) |
| 268 | { |
no test coverage detected