diff --git a/src/models.js b/src/models.js index 7133e64d5..760993641 100644 --- a/src/models.js +++ b/src/models.js @@ -1757,7 +1757,7 @@ export class PreTrainedModel extends Callable { const dtype = session?.config?.kv_cache_dtype ?? 'float32'; const empty = (dtype === 'float16') ? new Uint16Array() : []; - const batch_size = (decoderFeeds[this.main_input_name] ?? decoderFeeds.attention_mask).dims?.[0] ?? 1; + const batch_size = (decoderFeeds[this.main_input_name] ?? decoderFeeds.attention_mask)?.dims?.[0] ?? 1; const shapes = getKeyValueShapes(this.config, { batch_size }); for (const name in shapes) {