mirror of
https://git.adityakumar.xyz/llama.cpp.git
synced 2024-11-09 15:29:43 +00:00
Fix python stuff (#109)
This commit is contained in:
parent
467b149761
commit
c1c7026b47
1 changed files with 14 additions and 23 deletions
|
@ -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…
Reference in a new issue