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

Function conversion_helper

codegeex/megatron/model/module.py:120–128  ·  view source on GitHub ↗

Apply conversion to val. Recursively apply conversion if `val` #is a nested tuple/list structure.

(val, conversion)

Source from the content-addressed store, hash-verified

118
119
120def conversion_helper(val, conversion):
121 """Apply conversion to val. Recursively apply conversion if `val`
122 #is a nested tuple/list structure."""
123 if not isinstance(val, (tuple, list)):
124 return conversion(val)
125 rtn = [conversion_helper(v, conversion) for v in val]
126 if isinstance(val, tuple):
127 rtn = tuple(rtn)
128 return rtn
129
130
131def fp32_to_float16(val, float16_convertor):

Callers 2

fp32_to_float16Function · 0.85
float16_to_fp32Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected