MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / maybe_float

Function maybe_float

PATH/core/fp16/utils.py:110–119  ·  view source on GitHub ↗
(x, name='', verbose=False)

Source from the content-addressed store, hash-verified

108 return x.half()
109
110def maybe_float(x, name='', verbose=False):
111 if is_nested(x):
112 return type(x)([maybe_float(y) for y in x])
113
114 if not x.is_cuda or type_string(x) == 'FloatTensor':
115 return x
116 else:
117 if verbose:
118 print('Half->Float ({})'.format(name))
119 return x.float()
120
121# NB: returneds casted `args`, mutates `kwargs` in-place
122def casted_args(cast_fn, args, kwargs):

Callers

nothing calls this directly

Calls 2

is_nestedFunction · 0.85
type_stringFunction · 0.85

Tested by

no test coverage detected