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

Function ecall_logprob

sgx_tf_ops/Enclave/Enclave.cpp:3115–3199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3113}
3114
3115void ecall_logprob(float* input,float* mu,float* sigma, int N,float* output){
3116 float *x = (float*)malloc(sizeof(float)*N);
3117 memset(x, 0, sizeof(float)*N);
3118 for(int j=0;j<N;j++){
3119 x[j] = 0.0f;
3120 float sum = input[insert*N+j];
3121 float c = 0.0f;
3122 for(int i=0;i<Nt;i++){
3123 float y = input[indexs[i]*N+j] - c;
3124 float t = sum + y;
3125 c = (t - sum) - y;
3126 sum = t;
3127 }
3128 x[j] = sum;
3129 }
3130 float *m = (float*)malloc(sizeof(float)*N);
3131 memset(m, 0, sizeof(float)*N);
3132 for(int j=0;j<N;j++){
3133 m[j] = 0.0f;
3134 float sum = mu[insert*N+j];
3135 float c = 0.0f;
3136 for(int i=0;i<Nt;i++){
3137 float y = mu[indexs[i]*N+j] - c;
3138 float t = sum + y;
3139 c = (t - sum) - y;
3140 sum = t;
3141 }
3142 m[j] = sum;
3143 }
3144 float *sig = (float*)malloc(sizeof(float)*N);
3145 memset(sig, 0, sizeof(float)*N);
3146 for(int j=0;j<N;j++){
3147 sig[j] = 0.0f;
3148 float sum = sigma[insert*N+j];
3149 float c = 0.0f;
3150 for(int i=0;i<Nt;i++){
3151 float y = sigma[indexs[i]*N+j] - c;
3152 float t = sum + y;
3153 c = (t - sum) - y;
3154 sum = t;
3155 }
3156 sig[j] = sum;
3157 }
3158
3159 for(int i=0;i<N;i++){
3160 float PI = 3.1415926535897932384626433832795028841971;
3161 float eps = 1e-11; // small epsilon value
3162 x[i] = logf(1e-45+(1 / (sqrt(2 * PI) * sig[i]) * exp(-(x[i] - m[i]) * (x[i] - m[i]) / (2 * sig[i]*sig[i]))));
3163 }
3164
3165 float mean = 0.0f, std, mean_sqr = 0.0f;
3166 float c_mean = 0.0f, c_mean_sqr = 0.0f;
3167 for (int j = 0; j < N; j++) {
3168 float y = (x[j]/static_cast<float>(N)) - c_mean;
3169 float t = mean + y;
3170 c_mean = (t - mean) - y;
3171 mean = t;
3172

Callers 1

logprobFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected