35 const int outer_size = params.
num_rows;
38 for (
int i = 0; i < outer_size; ++i)
43 float max = std::numeric_limits<float>::lowest();
44 for (
int c = 0; c < depth; ++c)
46 max = std::max(max, input_data[i * depth + c]);
51 for (
int c = 0; c < depth; ++c)
53 sum += std::exp(input_data[i * depth + c] - max);
57 const float log_sum = std::log(sum);
58 for (
int c = 0; c < depth; ++c)
60 output_data[i * depth + c] = input_data[i * depth + c] - max - log_sum;