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

Method reduce

imperative/python/megengine/functional/einsum.py:70–78  ·  view source on GitHub ↗
(self, shape: EinsumShape)

Source from the content-addressed store, hash-verified

68 return EinsumOperand(shape, self._ctx.transpose(self._tracer, axis), self._ctx)
69
70 def reduce(self, shape: EinsumShape) -> "EinsumOperand":
71 if shape == self._shape:
72 return self
73 for dim in shape:
74 assert len(dim) == 1
75 assert dim in self.shape
76 axis = [*filter(lambda x: self.shape[x] not in shape, range(len(self.shape)))]
77 assert tuple([*filter(lambda x: x in shape, self.shape)]) == shape
78 return EinsumOperand(shape, self._ctx.reduce(self._tracer, axis), self._ctx)
79
80 # TODO: Some scenarios should be re-implemented using dnn kernel
81 def diag_plane(self, shape: EinsumShape) -> "EinsumOperand":

Callers 1

einsum_implFunction · 0.45

Calls 1

EinsumOperandClass · 0.85

Tested by

no test coverage detected