Fix python stuff (#109)

pull/181/head^2
Georgi Gerganov 1 year ago
parent 467b149761
commit c1c7026b47
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

@ -88,27 +88,18 @@ def write_tokens(fout, tokenizer):
def process_and_write_variables(fout, model, ftype):
for name, data in model.items():
for name, datao in model.items():
if name.endswith("freqs"):
continue
shape = data.shape
shape = datao.shape
print(f"Processing variable: {name} with shape: {shape} and type: {data.dtype}\n")
print(f"Processing variable: {name} with shape: {shape} and type: {datao.dtype}")
data = np.squeeze(data)
data = datao.numpy().squeeze()
n_dims = len(shape)
# for efficiency - transpose some matrices
# "model/h.*/attn/c_attn/w"
# "model/h.*/attn/c_proj/w"
# "model/h.*/mlp/c_fc/w"
# "model/h.*/mlp/c_proj/w"
#if name.endswith(("/attn/c_attn/w", "/attn/c_proj/w", "/mlp/c_fc/w", "/mlp/c_proj/w")):
# print("Transposing")
# data = data.transpose()
# default type is fp16
ftype_cur = 1
if ftype == 0 or n_dims == 1:
@ -123,7 +114,7 @@ def process_and_write_variables(fout, model, ftype):
fout.write(struct.pack("i", dim))
fout.write(sname)
# data
# data output to file
data.tofile(fout)
def main():

Loading…
Cancel
Save