MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / load_tensor

Function load_tensor

imperative/python/megengine/utils/module_stats.py:452–462  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

450 inputs = [inputs]
451
452 def load_tensor(x):
453 if isinstance(x, np.ndarray):
454 return Tensor(x)
455 elif isinstance(x, collections.abc.Mapping):
456 return {k: load_tensor(v) for k, v in x.items()}
457 elif isinstance(x, tuple) and hasattr(x, "_fields"): # nametuple
458 return type(x)(*(load_tensor(value) for value in x))
459 elif isinstance(x, collections.abc.Sequence):
460 return [load_tensor(v) for v in x]
461 else:
462 return Tensor(x, dtype=np.float32)
463
464 inputs = load_tensor(inputs)
465

Callers 1

module_statsFunction · 0.85

Calls 2

itemsMethod · 0.80
TensorClass · 0.50

Tested by

no test coverage detected