Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling Int8 input/filter and Int16 output FullyConnected layer for xtensa (with ref code). #97

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions tensorflow/lite/micro/kernels/xtensa/fully_connected.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,31 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
case kTfLiteInt8: {
switch (filter->type) {
case kTfLiteInt8: {
return XtensaEvalFullyConnectedQuantizedInt8(
context, node, data, input, filter, bias, output);
switch (output->type) {
case kTfLiteInt8: {
return XtensaEvalFullyConnectedQuantizedInt8(
context, node, data, input, filter, bias, output);
break;
}
case kTfLiteInt16: {
tflite::reference_integer_ops::FullyConnected(
FullyConnectedParamsQuantized(data),
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<int8_t>(input),
tflite::micro::GetTensorShape(filter),
tflite::micro::GetTensorData<int8_t>(filter),
tflite::micro::GetTensorShape(bias),
tflite::micro::GetOptionalTensorData<int32_t>(bias),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<int16_t>(output));
break;
}
default: {
MicroPrintf("Output type %s (%d) not supported.",
TfLiteTypeGetName(output->type), input->type);
return kTfLiteError;
}
}
}
case kTfLiteInt4: {
return XtensaEvalFullyConnectedQuantizedInt8(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ TfLiteStatus XtensaPrepareFullyConnected(TfLiteContext* context,
TfLiteTensor* output = micro_context->AllocateTempOutputTensor(
node, kFullyConnectedOutputTensor);
TF_LITE_ENSURE(context, output != nullptr);
TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);
// Disabling this check to support Int8 input, filter and Int16 output variant
// TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);

if (filter->type == kTfLiteInt4) {
#if defined(HIFI5) && defined(NNLIB_HIFI5)
Expand Down
Loading