Skip to content

Commit 925409d

Browse files
committed
Add comments
1 parent 9e68531 commit 925409d

File tree

1 file changed

+7
-0
lines changed
  • examples/models/llama3_2_vision/runner

1 file changed

+7
-0
lines changed

examples/models/llama3_2_vision/runner/native.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ def __init__(self, args):
4545
use_kv_cache=args.kv_cache,
4646
vocab_size=params["vocab_size"],
4747
)
48+
# Save the loaded model bytes to prevent data from going out of
49+
# scope after the `with` and getting cleaned up by Python's
50+
# garbage collector.
4851
self.model_bytes = None
4952
with open(args.pte, "rb") as f:
5053
self.model_bytes = f.read()
54+
# Need to use _load_for_executorch_from_buffer instead of
55+
# _load_for_executorch because the latter uses MmapDataLoader,
56+
# which doesn't have load_into() implemented, which is needed
57+
# for loading initialized mutable buffers.
5158
self.model = _load_for_executorch_from_buffer(self.model_bytes)
5259
self.use_kv_cache = args.kv_cache
5360

0 commit comments

Comments
 (0)