MCPcopy
hub / github.com/hpcaitech/ColossalAI / replace

Method replace

colossalai/_analyzer/_subclasses/meta_tensor.py:142–147  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

140 device = None
141
142 def replace(x):
143 nonlocal device
144 if isinstance(x, str) or isinstance(x, _device):
145 device = x
146 return torch.device("meta")
147 return x
148
149 elem = self._tensor.to(*tree_map(replace, args), **tree_map(replace, kwargs))
150 return MetaTensor(elem, device=device)

Callers 2

emit_nodeMethod · 0.45
to_folderMethod · 0.45

Calls 1

deviceMethod · 0.45

Tested by

no test coverage detected