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

Function get_cosine

imperative/python/megengine/quantization/quantize.py:220–226  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

218 batch_size = data.shape[0]
219
220 def get_cosine(x, y):
221 ndim = len(x.shape)
222 axis = tuple(range(1, ndim))
223 up = (x * y).sum(axis=axis)
224 down = norm(x, axis=axis) * norm(y, axis=axis)
225 sim = up / down
226 return sim.mean(axis=0)
227
228 def search(mod, inputs, outputs, where):
229

Callers 1

searchFunction · 0.85

Calls 3

normFunction · 0.50
sumMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected