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

Function half_conversion

DeepSpeedExample/megatron/model/module.py:130–136  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

128def fp32_to_float16(val, float16_convertor):
129 """Convert fp32 `val` to fp16/bf16"""
130 def half_conversion(val):
131 val_typecheck = val
132 if isinstance(val_typecheck, (Parameter, Variable)):
133 val_typecheck = val.data
134 if isinstance(val_typecheck, _FLOAT_TYPES):
135 val = float16_convertor(val)
136 return val
137 return conversion_helper(val, half_conversion)
138
139

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected