| 10 | { |
| 11 | |
| 12 | TfLiteStatus VisitDequantizeOperator(DelegateData& delegateData, |
| 13 | TfLiteOpaqueContext* tfLiteContext, |
| 14 | TfLiteOpaqueNode* tfLiteNode, |
| 15 | int nodeIndex, |
| 16 | int32_t operatorCode) |
| 17 | { |
| 18 | TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 19 | TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex)); |
| 20 | |
| 21 | // Gather input indices and use to get input tensor. |
| 22 | const int* inputTensors; |
| 23 | auto numInputs = TfLiteOpaqueNodeNumberOfInputs(tfLiteNode); |
| 24 | if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk) |
| 25 | { |
| 26 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 27 | tfLiteContext, |
| 28 | "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ", |
| 29 | nodeIndex); |
| 30 | return kTfLiteError; |
| 31 | } |
| 32 | |
| 33 | const TfLiteOpaqueTensor* tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]); |
| 34 | |
| 35 | if (!IsValid(tfLiteContext, tfLiteInputTensor, operatorCode, nodeIndex)) |
| 36 | { |
| 37 | return kTfLiteError; |
| 38 | } |
| 39 | |
| 40 | // Gather output indices and use to get output tensors. |
| 41 | int numOutputs = 0; |
| 42 | const int* outputTensors; |
| 43 | if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors, &numOutputs) != kTfLiteOk) |
| 44 | { |
| 45 | TF_LITE_OPAQUE_MAYBE_KERNEL_LOG( |
| 46 | tfLiteContext, |
| 47 | "TfLiteArmnnOpaqueDelegate: Unable to gather output tensor indices from node #%d: ", |
| 48 | nodeIndex); |
| 49 | return kTfLiteError; |
| 50 | } |
| 51 | |
| 52 | const TfLiteOpaqueTensor* tfLiteOutputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputTensors[0]); |
| 53 | if (!IsValid(tfLiteContext, tfLiteOutputTensor, operatorCode, nodeIndex)) |
| 54 | { |
| 55 | return kTfLiteError; |
| 56 | } |
| 57 | |
| 58 | const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor); |
| 59 | armnn::TensorInfo outputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteOutputTensor, true); |
| 60 | |
| 61 | UpdateConstantTensorOutputs(inputTensorInfo, outputTensorInfo); |
| 62 | |
| 63 | bool isSupported = false; |
| 64 | armnn::BackendId setBackend; |
| 65 | auto validateFunc = [&](const armnn::TensorInfo& outputTensorInfo, bool& isSupported) |
| 66 | { |
| 67 | // If this is a Dequantize with a Constant input then will be replaced by a Constant layer that contains the |
| 68 | // dequantized values during optimization so there's no need to check if it can be supported by the backend |
| 69 | if (IsConstantTensor(tfLiteInputTensor)) |
no test coverage detected