File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -243,8 +243,8 @@ def hf_model_weights_iterator(
243
243
for st_file in hf_weights_files :
244
244
with safe_open (st_file , framework = "pt" ) as f :
245
245
for name in f .keys ():
246
- param = f .get_slice (name )
247
- yield name , convert_pyslice_to_tensor ( param )
246
+ param = f .get_tensor (name )
247
+ yield name , param
248
248
else :
249
249
for bin_file in hf_weights_files :
250
250
state = torch .load (bin_file , map_location = "cpu" )
@@ -265,12 +265,7 @@ def convert_pyslice_to_tensor(x: Any) -> torch.Tensor:
265
265
tensor first.
266
266
"""
267
267
if not isinstance (x , torch .Tensor ):
268
- try :
269
- x = x [:]
270
- except IndexError :
271
- # IndexError happens when the tensor is empty.
272
- # transformer.h.0.attn.masked_bias is empty in some gpt2 models.
273
- return torch .Tensor ()
268
+ x = x [:]
274
269
return x
275
270
276
271
You can’t perform that action at this time.
0 commit comments