MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / conversion_helper

Function conversion_helper

DeepSpeedExample/megatron/model/module.py:117–125  ·  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

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

Callers 2

fp32_to_float16Function · 0.70
float16_to_fp32Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected