MCPcopy Create free account
hub / github.com/OAID/Tengine / softmax

Function softmax

executor/operator/common/region.cpp:58–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void softmax(float* input, int n, int stride, float* output)
59{
60 int i;
61 float sum = 0;
62 float largest = input[0];
63 for(i = 0; i < n; ++i)
64 {
65 if(input[i * stride] > largest)
66 largest = input[i * stride];
67 }
68 for(i = 0; i < n; ++i)
69 {
70 float e = exp(input[i * stride] - largest);
71 sum += e;
72 output[i * stride] = e;
73 }
74 for(i = 0; i < n; ++i)
75 {
76 output[i * stride] /= sum;
77 }
78}
79
80void softmax_cpu(float* input, int n, int batch, int batch_offset, int groups, int stride, float* output)
81{

Callers 1

softmax_cpuFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected