32 const int outer_size =
36 for (
int i = 0; i < outer_size; ++i)
41 float max = std::numeric_limits<float>::lowest();
42 for (
int c = 0; c < depth; ++c)
44 max = std::max(max, input_data[i * depth + c]);
49 for (
int c = 0; c < depth; ++c)
51 sum += std::exp(input_data[i * depth + c] - max);
55 const float log_sum = std::log(sum);
56 for (
int c = 0; c < depth; ++c)
58 output_data[i * depth + c] = input_data[i * depth + c] - max - log_sum;