Skip to content

Commit 4f08a3d

Browse files
author
chenyuankun
committed
Fix optional chaining for batch size calculation in PreTrainedModel
1 parent 9584263 commit 4f08a3d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/models.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ export class PreTrainedModel extends Callable {
17571757
const dtype = session?.config?.kv_cache_dtype ?? 'float32';
17581758
const empty = (dtype === 'float16') ? new Uint16Array() : [];
17591759

1760-
const batch_size = (decoderFeeds[this.main_input_name] ?? decoderFeeds.attention_mask).dims?.[0] ?? 1;
1760+
const batch_size = (decoderFeeds[this.main_input_name] ?? decoderFeeds.attention_mask)?.dims?.[0] ?? 1;
17611761
const shapes = getKeyValueShapes(this.config, { batch_size });
17621762

17631763
for (const name in shapes) {

0 commit comments

Comments
 (0)