MCPcopy Index your code
hub / github.com/apache/tvm / softmax_python

Function softmax_python

python/tvm/topi/testing/softmax_python.py:23–39  ·  view source on GitHub ↗

Softmax operator. Parameters ---------- a_np : numpy.ndarray N-D input data Returns ------- output_np : numpy.ndarray N-D output with same shape

(a_np, axis=1)

Source from the content-addressed store, hash-verified

21
22
23def softmax_python(a_np, axis=1):
24 """Softmax operator.
25 Parameters
26 ----------
27 a_np : numpy.ndarray
28 N-D input data
29
30 Returns
31 -------
32 output_np : numpy.ndarray
33 N-D output with same shape
34 """
35 max_elem = np.amax(a_np, axis=axis, keepdims=True)
36 e = np.exp(a_np - max_elem)
37 expsum = np.sum(e, axis=axis, keepdims=True)
38 out_np = e / expsum
39 return out_np
40
41
42def log_softmax_python(a_np, axis=1):

Callers 1

attention_pythonFunction · 0.90

Calls 2

expMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…