| 2069 | } |
| 2070 | |
| 2071 | void ecall_minimum_grad(float *input1,float *input2,float *grad,int N,float *output1,float *output2){ |
| 2072 | float *x1 = (float*)malloc(sizeof(float)*N); |
| 2073 | memset(x1, 0, sizeof(float)*N); |
| 2074 | for(int j=0;j<N;j++){ |
| 2075 | x1[j] = 0.0f; |
| 2076 | float sum = input1[insert*N+j]; |
| 2077 | float c = 0.0f; |
| 2078 | for(int i=0;i<Nt;i++){ |
| 2079 | float y = input1[indexs[i]*N+j] - c; |
| 2080 | float t = sum + y; |
| 2081 | c = (t - sum) - y; |
| 2082 | sum = t; |
| 2083 | } |
| 2084 | x1[j] = sum; |
| 2085 | } |
| 2086 | float *x2 = (float*)malloc(sizeof(float)*N); |
| 2087 | memset(x2, 0, sizeof(float)*N); |
| 2088 | for(int j=0;j<N;j++){ |
| 2089 | x2[j] = 0.0f; |
| 2090 | float sum = input2[insert*N+j]; |
| 2091 | float c = 0.0f; |
| 2092 | for(int i=0;i<Nt;i++){ |
| 2093 | float y = input2[indexs[i]*N+j] - c; |
| 2094 | float t = sum + y; |
| 2095 | c = (t - sum) - y; |
| 2096 | sum = t; |
| 2097 | } |
| 2098 | x2[j] = sum; |
| 2099 | } |
| 2100 | float *g = (float*)malloc(sizeof(float)*N); |
| 2101 | memset(g, 0, sizeof(float)*N); |
| 2102 | for(int j=0;j<N;j++){ |
| 2103 | g[j] = 0.0f; |
| 2104 | float sum = grad[insert*N+j]; |
| 2105 | float c = 0.0f; |
| 2106 | for(int i=0;i<Nt;i++){ |
| 2107 | float y = grad[indexs[i]*N+j] - c; |
| 2108 | float t = sum + y; |
| 2109 | c = (t - sum) - y; |
| 2110 | sum = t; |
| 2111 | } |
| 2112 | g[j] = sum; |
| 2113 | } |
| 2114 | |
| 2115 | for (int j = 0; j < N; j++) { |
| 2116 | if(x1[j] <= x2[j]){ |
| 2117 | x1[j] = g[j]; |
| 2118 | x2[j] = 0.0f; |
| 2119 | } |
| 2120 | else{ |
| 2121 | x1[j] = 0.0f; |
| 2122 | x2[j] = g[j]; |
| 2123 | } |
| 2124 | } |
| 2125 | |
| 2126 | float mean = 0.0f, std, mean_sqr = 0.0f; |
| 2127 | float c_mean = 0.0f, c_mean_sqr = 0.0f; |
| 2128 | for (int j = 0; j < N; j++) { |
no test coverage detected