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

Method _cast_inputs_half

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

Source from the content-addressed store, hash-verified

3105 return loss
3106
3107 def _cast_inputs_half(self, inputs):
3108 if isinstance(inputs, (list, tuple)):
3109 new_inputs = []
3110 for v in inputs:
3111 new_inputs.append(self._cast_inputs_half(v))
3112 return inputs.__class__(new_inputs)
3113 elif isinstance(inputs, dict):
3114 new_inputs = {}
3115 for k, v in inputs.items():
3116 new_inputs[k] = self._cast_inputs_half(v)
3117 return new_inputs
3118 elif hasattr(inputs, 'half') and inputs.is_floating_point():
3119 return inputs.half()
3120 else:
3121 return inputs
3122
3123 def print_forward_breakdown(self, fwd_time):
3124 gate_time = 0.0

Callers 1

_forward_prologueMethod · 0.95

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected