File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
examples/models/llama3_2_vision/runner Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,16 @@ def __init__(self, args):
45
45
use_kv_cache = args .kv_cache ,
46
46
vocab_size = params ["vocab_size" ],
47
47
)
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.
48
51
self .model_bytes = None
49
52
with open (args .pte , "rb" ) as f :
50
53
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.
51
58
self .model = _load_for_executorch_from_buffer (self .model_bytes )
52
59
self .use_kv_cache = args .kv_cache
53
60
You can’t perform that action at this time.
0 commit comments