| 1745 | } |
| 1746 | |
| 1747 | void ecall_reducemean(float *input,int N,float *output){ |
| 1748 | float *x = (float*)malloc(sizeof(float)*N); |
| 1749 | memset(x, 0, sizeof(float)*N); |
| 1750 | for(int j=0;j<N;j++){ |
| 1751 | x[j] = 0.0f; |
| 1752 | float sum = input[insert*N+j]; |
| 1753 | float c = 0.0f; |
| 1754 | for(int i=0;i<Nt;i++){ |
| 1755 | float y = input[indexs[i]*N+j] - c; |
| 1756 | float t = sum + y; |
| 1757 | c = (t - sum) - y; |
| 1758 | sum = t; |
| 1759 | } |
| 1760 | x[j] = sum; |
| 1761 | |
| 1762 | } |
| 1763 | output[0] =0.0f; |
| 1764 | for (int j = 0; j < N; j++){ |
| 1765 | output[0] += x[j]/static_cast<float>(N); |
| 1766 | } |
| 1767 | return; |
| 1768 | } |
| 1769 | |
| 1770 | void ecall_reducemean_grad(float *input,float grad,int N,float *output){ |
| 1771 | float *x = (float*)malloc(sizeof(float)*N); |