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

Function mean

imperative/python/megengine/xla/rules/reduction.py:115–124  ·  view source on GitHub ↗
(inp, axes=None, keepdims=False)

Source from the content-addressed store, hash-verified

113
114
115def mean(inp, axes=None, keepdims=False):
116 axes = _normalize_reduce_axes(inp.shape, axes)
117 inp_sum = sum(inp, axes, keepdims)
118 inp_shape = inp.shape
119
120 divider = 1.0
121 for ax in axes:
122 divider *= inp_shape[ax]
123
124 return div(inp_sum, divider)
125
126
127@register_lower_rule(mops.Reduce)

Callers 2

reduce_lowerFunction · 0.70
meanMethod · 0.70

Calls 3

_normalize_reduce_axesFunction · 0.85
sumFunction · 0.85
divFunction · 0.85

Tested by

no test coverage detected