This commit is contained in:
Colin 2023-12-29 19:55:53 +08:00
parent b3df9e423c
commit 3db6e2c25b
3 changed files with 46 additions and 0 deletions

View File

@ -3,6 +3,27 @@
## data flow ## data flow
query
|
tokenizer -> input_ids
|
rotary_pos_emb embedding -> [1, 6, 4096]
\ /
GLMBlock x 28 -> [6, 1, 4096] <━━━┓
RMSNorm -> [6, 1, 4096] ┃
[-1:] -> [1, 1, 4096] ┃
Linear -> [1, 1, 65024] ┃
softmax -> [1, 65024] ┃
multinomial -> [1] ┃
cat([input_ids, next_tokens]) ━━━┛
input_ids = tokenizer.build_chat_input(query, history=history, role=role) input_ids = tokenizer.build_chat_input(query, history=history, role=role)
for: for:

View File

@ -55,3 +55,23 @@ def DumpListToFile(list, name="list"):
for d in list: for d in list:
f.writelines("%s" % d + os.linesep) f.writelines("%s" % d + os.linesep)
f.close() f.close()
prob_true = 0
prob_all = 0
def ProbGE0(tensor: torch.tensor):
global prob_true
global prob_all
m = tensor.ge(0)
prob_true = prob_true + m.sum().item()
prob_all = prob_all + math.prod(tensor.shape)
def DumpProb():
global prob_true
global prob_all
print("prob_true : " + str(prob_true))
print("prob_all : " + str(prob_all))
print("prob : " + str((prob_true * 100) / prob_all) + "%")

View File

@ -11,3 +11,8 @@ show.DumpTensorToImage(radata, "test.png")
radata = torch.randn(127, 127) radata = torch.randn(127, 127)
show.DumpTensorToLog(radata, "test.log") show.DumpTensorToLog(radata, "test.log")
radata = torch.randn(127, 127) - 0.5
show.ProbGE0(radata)
show.DumpProb()