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

Function ecall_logloss

sgx_tf_ops/Enclave/Enclave.cpp:344–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342 }
343
344void ecall_logloss(float *input,int N,int M,int C,float *label,float *weight,float *output){
345 float *x = (float*)malloc(sizeof(float)*N);
346 memset(x, 0, sizeof(float)*N);
347 for(int j=0;j<N;j++){
348 x[j] = 0.0f;
349 float sum = input[insert*N+j];
350 float c = 0.0f;
351 for(int i=0;i<Nt;i++){
352 float y = input[indexs[i]*N+j] - c;
353 float t = sum + y;
354 c = (t - sum) - y;
355 sum = t;
356 }
357 x[j] = sum;
358 }
359 output[0] = 0.0f;
360 float epsilon = 1e-7f;
361 for (int i = 0; i < M; i++ ){
362 for (int j = 0; j< C;j++){
363 output[0] = output[0] - ((label[i*C+j] * logf(x[i*C+j] + epsilon) ) + (1 - label[i*C+j]) * logf(1 - x[i*C+j] + epsilon))* weight[i];
364 }
365 }
366 free(x);
367 return;
368}
369
370void ecall_relu_grad(float *input,float *grad,int N,float *output){
371 float *x = (float*)malloc(sizeof(float)*N);

Callers 1

loglossFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected