28 const float *input_data,
33 const int outer_size =
36 for (
int i = 0; i < outer_size; ++i)
38 float squared_l2_norm = 0;
39 for (
int c = 0; c < depth; ++c)
41 const float val = input_data[depth * i + c];
42 squared_l2_norm += val * val;
44 float l2_norm = std::sqrt(squared_l2_norm);
45 l2_norm = std::fmax(l2_norm, epsilon);
46 for (
int c = 0; c < depth; ++c)
48 output_data[depth * i + c] = input_data[depth * i + c] / l2_norm;
void L2Normalization(const luci_interpreter::RuntimeShape &input_shape, const float *input_data, const luci_interpreter::RuntimeShape &output_shape, float *output_data, float epsilon=1e-6)