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

Function einsum_subgraph

imperative/python/megengine/functional/einsum.py:461–471  ·  view source on GitHub ↗
(equation, inputs: Tuple[Tensor, ...])

Source from the content-addressed store, hash-verified

459
460
461def einsum_subgraph(equation, inputs: Tuple[Tensor, ...]) -> Tensor:
462 dtype = inputs[0].dtype
463 device = inputs[0].device
464 # assume all inputs has same dtype and device
465 for input in inputs[1:]:
466 assert input.dtype == dtype
467 assert input.device == device
468 einsum = _get_einsum_op(
469 equation, dtype, device, tuple(map(lambda x: x.ndim, inputs))
470 )
471 return einsum(*inputs)[0]
472
473
474def einsum(equation: str, *args: Tensor) -> Tensor:

Callers 1

einsumFunction · 0.85

Calls 2

_get_einsum_opFunction · 0.85
einsumFunction · 0.85

Tested by

no test coverage detected