Skip to content

Commit c9677e8

Browse files
committed
Fixed assignment error in AssignmentInstructions.parse_assign_line()
1 parent 9e4eafa commit c9677e8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

backends/model_converter/no_pickle_fake_torch.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ def extract_weights_from_checkpoint(fb0):
2727
with myzip.open(folder_name + f'/data/{load_instruction.obj_key}') as myfile:
2828
if (load_instruction.load_from_file_buffer(myfile)):
2929
torch_weights['state_dict'][sd_key] = load_instruction.get_data()
30-
for sd_key,special in special_instructions.items():
31-
torch_weights['state_dict'][sd_key] = special
30+
if len(special_instructions) > 0:
31+
torch_weights['state_dict']['_metadata'] = {}
32+
for sd_key,special in special_instructions.items():
33+
torch_weights['state_dict']['_metadata'][sd_key] = special
3234
return torch_weights
3335

3436
def examine_pickle(fb0):
@@ -96,7 +98,7 @@ def parse_assign_line(self, line):
9698
del huge_mess
9799
assignments[-1] = assignments[-1].strip('}')
98100
re_var = re.compile('^_var\d+$')
99-
assignment_count
101+
assignment_count = 0
100102
for a in assignments:
101103
if self._add_assignment(a, re_var):
102104
assignment_count = assignment_count + 1

0 commit comments

Comments
 (0)