MCPcopy Create free account
hub / github.com/OpenTalker/StyleHEAT / to_float

Function to_float

utils/misc.py:106–121  ·  view source on GitHub ↗

r"""Move all halfs to float. Args: data (dict, list or tensor): Input data.

(data)

Source from the content-addressed store, hash-verified

104
105
106def to_float(data):
107 r"""Move all halfs to float.
108
109 Args:
110 data (dict, list or tensor): Input data.
111 """
112 if isinstance(data, torch.Tensor) and torch.is_floating_point(data):
113 data = data.float()
114 return data
115 elif isinstance(data, container_abcs.Mapping):
116 return {key: to_float(data[key]) for key in data}
117 elif isinstance(data, container_abcs.Sequence) and \
118 not isinstance(data, string_classes):
119 return [to_float(d) for d in data]
120 else:
121 return data
122
123
124def get_and_setattr(cfg, name, default):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected