MCPcopy Create free account
hub / github.com/ARM-software/armnn / VisitQuantizeOperator

Function VisitQuantizeOperator

delegate/opaque/src/Quantization.hpp:113–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113TfLiteStatus VisitQuantizeOperator(DelegateData& delegateData,
114 TfLiteOpaqueContext* tfLiteContext,
115 TfLiteOpaqueNode* tfLiteNode,
116 int nodeIndex,
117 int32_t operatorCode)
118{
119 TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
120 TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
121
122 // Gather input indices and use to get input tensor.
123 const int* inputTensors;
124 auto numInputs = TfLiteOpaqueNodeNumberOfInputs(tfLiteNode);
125 if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk)
126 {
127 TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
128 tfLiteContext,
129 "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ",
130 nodeIndex);
131 return kTfLiteError;
132 }
133
134 const TfLiteOpaqueTensor* tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]);
135 if (!IsValid(tfLiteContext, tfLiteInputTensor, operatorCode, nodeIndex))
136 {
137 return kTfLiteError;
138 }
139
140 // Gather output indices and use to get output tensors.
141 int numOutputs = 0;
142 const int* outputTensors;
143 if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors, &numOutputs) != kTfLiteOk)
144 {
145 TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
146 tfLiteContext,
147 "TfLiteArmnnOpaqueDelegate: Unable to gather output tensor indices from node #%d: ",
148 nodeIndex);
149 return kTfLiteError;
150 }
151
152 const TfLiteOpaqueTensor* tfLiteOutputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputTensors[0]);
153 if (!IsValid(tfLiteContext, tfLiteOutputTensor, operatorCode, nodeIndex))
154 {
155 return kTfLiteError;
156 }
157
158 // Only affine per-layer quantization is supported.
159 if (!IsAffineQuantization(*tfLiteOutputTensor))
160 {
161 TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
162 tfLiteContext,
163 "TfLiteArmnnOpaqueDelegate: Only affine per-layer quantization is supported in operator #%d node #%d: ",
164 operatorCode, nodeIndex);
165 return kTfLiteError;
166 }
167
168 const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor);
169 const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteOutputTensor, true);
170

Callers 1

VisitNodeMethod · 0.70

Calls 15

GetNameFunction · 0.85
AddQuantizeLayerMethod · 0.80
GetOutputSlotMethod · 0.80
ValidateNumInputsFunction · 0.70
ValidateNumOutputsFunction · 0.70
IsValidFunction · 0.70
IsAffineQuantizationFunction · 0.70
ProcessInputsFunction · 0.70
ConnectFunction · 0.70
GetDataTypeMethod · 0.45

Tested by

no test coverage detected