From c9ef76c9a303840c4e9e3a37854904497e07151b Mon Sep 17 00:00:00 2001 From: Joshua Lochner Date: Wed, 5 Jun 2024 01:32:44 +0200 Subject: [PATCH] Only set preferredOutputLocation if shapes are present --- src/models.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/models.js b/src/models.js index fc22da794..8fcb80b8a 100644 --- a/src/models.js +++ b/src/models.js @@ -225,11 +225,14 @@ async function getSession(pretrained_model_name_or_path, fileName, options) { const shapes = getKeyValueShapes(options.config, { prefix: 'present', }); - const preferredOutputLocation = {}; - for (const key in shapes) { - preferredOutputLocation[key] = 'gpu-buffer'; + if (Object.keys(shapes).length > 0) { + // Only set preferredOutputLocation if shapes are present + const preferredOutputLocation = {}; + for (const key in shapes) { + preferredOutputLocation[key] = 'gpu-buffer'; + } + session_options.preferredOutputLocation = preferredOutputLocation; } - session_options.preferredOutputLocation = preferredOutputLocation; } const buffer = await bufferPromise;