(x, name='', verbose=False)
| 108 | return x.half() |
| 109 | |
| 110 | def 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 |
| 122 | def casted_args(cast_fn, args, kwargs): |
nothing calls this directly
no test coverage detected