From aeb24668446f741b804039f3153a455d8bab8834 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 10 Nov 2022 12:35:46 -0800 Subject: [PATCH] Pick TFLite delegate for Web CPU PiperOrigin-RevId: 487611446 --- .../web/components/processors/base_options.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/mediapipe/tasks/web/components/processors/base_options.ts b/mediapipe/tasks/web/components/processors/base_options.ts index a7f7bd28..ac24a8db 100644 --- a/mediapipe/tasks/web/components/processors/base_options.ts +++ b/mediapipe/tasks/web/components/processors/base_options.ts @@ -70,17 +70,11 @@ async function configureExternalFile( /** Configues the `acceleration` option. */ function configureAcceleration(options: BaseOptions, proto: BaseOptionsProto) { - if ('delegate' in options) { - const acceleration = new Acceleration(); - if (options.delegate === 'cpu') { - acceleration.setXnnpack( - new InferenceCalculatorOptions.Delegate.Xnnpack()); - proto.setAcceleration(acceleration); - } else if (options.delegate === 'gpu') { - acceleration.setGpu(new InferenceCalculatorOptions.Delegate.Gpu()); - proto.setAcceleration(acceleration); - } else { - proto.clearAcceleration(); - } + const acceleration = proto.getAcceleration() ?? new Acceleration(); + if (options.delegate === 'gpu') { + acceleration.setGpu(new InferenceCalculatorOptions.Delegate.Gpu()); + } else { + acceleration.setTflite(new InferenceCalculatorOptions.Delegate.TfLite()); } + proto.setAcceleration(acceleration); }