MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / ecall_maximum_grad

Function ecall_maximum_grad

sgx_tf_ops/Enclave/Enclave.cpp:1880–2001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1878 }
1879
1880void ecall_maximum_grad(float *input1,float *input2,float *grad,int N,float *output1,float *output2){
1881 float *x1 = (float*)malloc(sizeof(float)*N);
1882 memset(x1, 0, sizeof(float)*N);
1883 for(int j=0;j<N;j++){
1884 x1[j] = 0.0f;
1885 float sum = input1[insert*N+j];
1886 float c = 0.0f;
1887 for(int i=0;i<Nt;i++){
1888 float y = input1[indexs[i]*N+j] - c;
1889 float t = sum + y;
1890 c = (t - sum) - y;
1891 sum = t;
1892 }
1893 x1[j] = sum;
1894 }
1895 float *x2 = (float*)malloc(sizeof(float)*N);
1896 memset(x2, 0, sizeof(float)*N);
1897 for(int j=0;j<N;j++){
1898 x2[j] = 0.0f;
1899 float sum = input2[insert*N+j];
1900 float c = 0.0f;
1901 for(int i=0;i<Nt;i++){
1902 float y = input2[indexs[i]*N+j] - c;
1903 float t = sum + y;
1904 c = (t - sum) - y;
1905 sum = t;
1906 }
1907 x2[j] = sum;
1908 }
1909 float *g = (float*)malloc(sizeof(float)*N);
1910 memset(g, 0, sizeof(float)*N);
1911 for(int j=0;j<N;j++){
1912 g[j] = 0.0f;
1913 float sum = grad[insert*N+j];
1914 float c = 0.0f;
1915 for(int i=0;i<Nt;i++){
1916 float y = grad[indexs[i]*N+j] - c;
1917 float t = sum + y;
1918 c = (t - sum) - y;
1919 sum = t;
1920 }
1921 g[j] = sum;
1922 }
1923
1924 for (int j = 0; j < N; j++) {
1925 if(x1[j] >= x2[j]){
1926 x1[j] = g[j];
1927 x2[j] = 0.0f;
1928 }
1929 else{
1930 x1[j] = 0.0f;
1931 x2[j] = g[j];
1932 }
1933 }
1934
1935 float mean = 0.0f, std, mean_sqr = 0.0f;
1936 float c_mean = 0.0f, c_mean_sqr = 0.0f;
1937 for (int j = 0; j < N; j++) {

Callers 1

maximum_gradFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected