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

Function ecall_dot_grad

sgx_tf_ops/Enclave/Enclave.cpp:4248–4482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4246}
4247
4248void ecall_dot_grad(float* input1,float* input2, float* grad,int N1,int N2,int* shape1, int* shape2 ,int ndims,float* output1,float* output2){
4249 float *x1 = (float*)malloc(sizeof(float)*N1);
4250 memset(x1, 0, sizeof(float)*N1);
4251 for(int j=0;j<N1;j++){
4252 x1[j] = 0.0f;
4253 float sum = input1[insert*N1+j];
4254 float c = 0.0f;
4255 for(int i=0;i<Nt;i++){
4256 float y = input1[indexs[i]*N1+j] - c;
4257 float t = sum + y;
4258 c = (t - sum) - y;
4259 sum = t;
4260 }
4261 x1[j] = sum;
4262 }
4263
4264 float *x2 = (float*)malloc(sizeof(float)*N2);
4265 memset(x2, 0, sizeof(float)*N2);
4266 for(int j=0;j<N2;j++){
4267 x2[j] = 0.0f;
4268 float sum = input2[insert*N2+j];
4269 float c = 0.0f;
4270 for(int i=0;i<Nt;i++){
4271 float y = input2[indexs[i]*N2+j] - c;
4272 float t = sum + y;
4273 c = (t - sum) - y;
4274 sum = t;
4275 }
4276 x2[j] = sum;
4277 }
4278
4279 int N = std::max(N1,N2);
4280 float *g = (float*)malloc(sizeof(float)*N);
4281 memset(g, 0, sizeof(float)*N);
4282 for(int j=0;j<N;j++){
4283 g[j] = 0.0f;
4284 float sum = grad[insert*N+j];
4285 float c = 0.0f;
4286 for(int i=0;i<Nt;i++){
4287 float y = grad[indexs[i]*N+j] - c;
4288 float t = sum + y;
4289 c = (t - sum) - y;
4290 sum = t;
4291 }
4292 g[j] = sum;
4293 }
4294
4295 if(ndims == 2){
4296 if(shape1[1] > shape2[1]){
4297 int M = shape1[0]/Ne;
4298 int L = shape1[1];
4299 for(int i=0;i<M;i++){
4300 float tmp2 = x2[i];
4301 x2[i] = 0.0f;
4302 for(int j=0;j<L;j++){
4303 float tmp1 = x1[i*L+j];
4304 x1[i*L+j] = tmp2 * g[i*L+j];
4305 x2[i] += tmp1 * g[i*L+j];

Callers 1

dot_gradFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected