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

Function fp32_to_float16

DeepSpeedExample/megatron/model/module.py:128–137  ·  view source on GitHub ↗

Convert fp32 `val` to fp16/bf16

(val, float16_convertor)

Source from the content-addressed store, hash-verified

126
127
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
140def float16_to_fp32(val):

Callers 1

forwardMethod · 0.70

Calls 1

conversion_helperFunction · 0.70

Tested by

no test coverage detected