| 17 | { |
| 18 | |
| 19 | TfLiteStatus VisitTransposeOperator(DelegateData& delegateData, |
| 20 | TfLiteContext* tfLiteContext, |
| 21 | TfLiteNode* tfLiteNode, |
| 22 | int nodeIndex, |
| 23 | int32_t tfliteTransposeOperatorCode) |
| 24 | { |
| 25 | TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 2, nodeIndex)); |
| 26 | TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 27 | |
| 28 | const TfLiteTensor *tfLiteTensors = tfLiteContext->tensors; |
| 29 | const TfLiteTensor& tfLiteInputTensor0 = tfLiteTensors[tfLiteNode->inputs->data[0]]; |
| 30 | if (IsDynamicTensor(tfLiteInputTensor0)) |
| 31 | { |
| 32 | TF_LITE_MAYBE_KERNEL_LOG(tfLiteContext, |
| 33 | "TfLiteArmnnDelegate: Dynamic input tensors are not supported in " |
| 34 | "operator #%d node #%d: ", |
| 35 | tfliteTransposeOperatorCode, nodeIndex); |
| 36 | |
| 37 | return kTfLiteError; |
| 38 | } |
| 39 | |
| 40 | const TfLiteTensor& tfLiteInputTensor1 = tfLiteTensors[tfLiteNode->inputs->data[1]]; |
| 41 | if (IsDynamicTensor(tfLiteInputTensor1)) |
| 42 | { |
| 43 | TF_LITE_MAYBE_KERNEL_LOG(tfLiteContext, |
| 44 | "TfLiteArmnnDelegate: Dynamic input tensors are not supported in " |
| 45 | "operator #%d node #%d: ", |
| 46 | tfliteTransposeOperatorCode, nodeIndex); |
| 47 | return kTfLiteError; |
| 48 | } |
| 49 | |
| 50 | const TfLiteTensor& tfLiteOutputTensor = tfLiteTensors[tfLiteNode->outputs->data[0]]; |
| 51 | if (IsDynamicTensor(tfLiteOutputTensor)) |
| 52 | { |
| 53 | TF_LITE_MAYBE_KERNEL_LOG(tfLiteContext, |
| 54 | "TfLiteArmnnDelegate: Dynamic output tensors are not supported in " |
| 55 | "operator #%d node #%d: ", |
| 56 | tfliteTransposeOperatorCode, nodeIndex); |
| 57 | return kTfLiteError; |
| 58 | } |
| 59 | |
| 60 | const armnn::TensorInfo& inputTensorInfo0 = GetTensorInfoForTfLiteTensor(tfLiteInputTensor0); |
| 61 | const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteOutputTensor, true); |
| 62 | |
| 63 | auto* permTensorDataPtr = tflite::GetTensorData<int32_t>(&tfLiteInputTensor1); |
| 64 | unsigned int numEl = tfLiteInputTensor1.dims->data[0]; |
| 65 | |
| 66 | if (numEl > static_cast<int>(armnn::MaxNumOfTensorDimensions)) |
| 67 | { |
| 68 | return kTfLiteError; |
| 69 | } |
| 70 | |
| 71 | if (tfLiteInputTensor1.dims->size != 1) |
| 72 | { |
| 73 | return kTfLiteError; |
| 74 | } |
| 75 | |
| 76 | armnn::TransposeDescriptor descriptor(armnn::PermutationVector( |
no test coverage detected