| 60 | } |
| 61 | |
| 62 | static void GetOutResult(float* input, float* output, float* array, float* sum_array, int in_size, int on_size) |
| 63 | { |
| 64 | float* input_ptr = ( float* )input; |
| 65 | float* output_ptr = ( float* )output; |
| 66 | float* array_ptr = ( float* )array; |
| 67 | float* sum_array_ptr = ( float* )sum_array; |
| 68 | |
| 69 | memset(sum_array, 0x0, in_size * sizeof(float)); |
| 70 | |
| 71 | /* get the exp and the summary */ |
| 72 | |
| 73 | for(int j = 0; j < on_size; j++) |
| 74 | { |
| 75 | |
| 76 | for(int l = 0; l < in_size; l++) |
| 77 | { |
| 78 | int index = j * in_size + l; |
| 79 | output_ptr[index] = exp(input_ptr[index] - array_ptr[l]); |
| 80 | sum_array_ptr[l] += output_ptr[index]; |
| 81 | |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /* the final result */ |
| 86 | for(int j = 0; j < on_size; j++) |
| 87 | { |
| 88 | for(int l = 0; l < in_size; l++) |
| 89 | { |
| 90 | int index = j * in_size + l; |
| 91 | output_ptr[index] /= sum_array_ptr[l]; |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | typedef int (*ref_softmax_kernel_t)(void* input, void* output, void* max_array, void* sum_array, op_data* op_param); |
| 97 |
no outgoing calls
no test coverage detected