MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / _cast_inputs_half

Method _cast_inputs_half

deepspeed/runtime/engine.py:3180–3194  ·  view source on GitHub ↗
(self, inputs)

Source from the content-addressed store, hash-verified

3178 return loss
3179
3180 def _cast_inputs_half(self, inputs):
3181 if isinstance(inputs, (list, tuple)):
3182 new_inputs = []
3183 for v in inputs:
3184 new_inputs.append(self._cast_inputs_half(v))
3185 return inputs.__class__(new_inputs)
3186 elif isinstance(inputs, dict):
3187 new_inputs = {}
3188 for k, v in inputs.items():
3189 new_inputs[k] = self._cast_inputs_half(v)
3190 return new_inputs
3191 elif hasattr(inputs, 'half') and inputs.is_floating_point():
3192 return inputs.half()
3193 else:
3194 return inputs
3195
3196 def print_forward_breakdown(self, fwd_time):
3197 gate_time = 0.0

Callers 1

_forward_prologueMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected