MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / WalkDict

Function WalkDict

codegeex/paddle/pt_to_pdparams.py:15–26  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

13
14
15def WalkDict(x):
16 for i in x:
17 if isinstance(x[i], dict):
18 WalkDict(x[i])
19 elif isinstance(x[i], torch.Tensor):
20 print(f"Converting '{i}' from 'torch.Tensor' to 'numpy.ndarray'.")
21 npy = x[i].cpu().numpy()
22 if any([f".{layer}.weight" in i for layer in linear_layer]):
23 print(f"Transposing linear layer weight '{i}'.")
24 x[i] = npy.T
25 else:
26 x[i] = npy
27
28
29def parse_opt():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected