Enable unsigned quantized infererence using XNNPACK.

PiperOrigin-RevId: 488179656
This commit is contained in:
Alan Kelly 2022-11-13 07:08:28 -08:00 committed by Copybara-Service
parent da36468409
commit bb6fa85703
3 changed files with 6 additions and 0 deletions

View File

@ -151,6 +151,8 @@ InferenceCalculatorCpuImpl::MaybeCreateDelegate(CalculatorContext* cc) {
auto xnnpack_opts = TfLiteXNNPackDelegateOptionsDefault();
xnnpack_opts.num_threads =
GetXnnpackNumThreads(opts_has_delegate, opts_delegate);
// TODO Remove once XNNPACK is enabled by default.
xnnpack_opts.flags |= TFLITE_XNNPACK_DELEGATE_FLAG_QU8;
return TfLiteDelegatePtr(TfLiteXNNPackDelegateCreate(&xnnpack_opts),
&TfLiteXNNPackDelegateDelete);
}

View File

@ -114,6 +114,8 @@ InferenceCalculatorXnnpackImpl::CreateDelegate(CalculatorContext* cc) {
auto xnnpack_opts = TfLiteXNNPackDelegateOptionsDefault();
xnnpack_opts.num_threads =
GetXnnpackNumThreads(opts_has_delegate, opts_delegate);
// TODO Remove once XNNPACK is enabled by default.
xnnpack_opts.flags |= TFLITE_XNNPACK_DELEGATE_FLAG_QU8;
return TfLiteDelegatePtr(TfLiteXNNPackDelegateCreate(&xnnpack_opts),
&TfLiteXNNPackDelegateDelete);
}

View File

@ -941,6 +941,8 @@ absl::Status TfLiteInferenceCalculator::LoadDelegate(CalculatorContext* cc) {
if (use_xnnpack) {
auto xnnpack_opts = TfLiteXNNPackDelegateOptionsDefault();
xnnpack_opts.num_threads = GetXnnpackNumThreads(calculator_opts);
// TODO Remove once XNNPACK is enabled by default.
xnnpack_opts.flags |= TFLITE_XNNPACK_DELEGATE_FLAG_QU8;
delegate_ = TfLiteDelegatePtr(TfLiteXNNPackDelegateCreate(&xnnpack_opts),
&TfLiteXNNPackDelegateDelete);
RET_CHECK_EQ(interpreter_->ModifyGraphWithDelegate(delegate_.get()),