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

Function ecall_onehot

sgx_tf_ops/Enclave/Enclave.cpp:2960–3039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2958}
2959
2960void ecall_onehot(float* input, int N, int M,int C,int L,float* output,int alpha){
2961 float *x = (float*)malloc(sizeof(float)*N);
2962 memset(x, 0, sizeof(float)*N);
2963 for(int j=0;j<N;j++){
2964 x[j] = 0.0f;
2965 float sum = input[insert*N+j];
2966 float c = 0.0f;
2967 for(int i=0;i<Nt;i++){
2968 float y = input[indexs[i]*N+j] - c;
2969 float t = sum + y;
2970 c = (t - sum) - y;
2971 sum = t;
2972 }
2973 x[j] = sum;
2974 }
2975
2976 float *x1 = (float*)malloc(sizeof(float)*M*L*alpha);
2977 memset(x1, 0, sizeof(float)*M*L*alpha);
2978
2979 int *arg = (int*)malloc(sizeof(int)*M*L);
2980 memset(arg, 0, sizeof(int)*M*L);
2981 for(int i = 0;i<M;i++){
2982 for(int j = 0;j<L;j++){
2983 arg[i*L+j] = 0;
2984 float tmpmax = x[i*C*L+0+j];
2985 for(int k = 0;k<C;k++){
2986 if(x[i*C*L+k*L+j] > tmpmax){
2987 arg[i*L+j] = k;
2988 tmpmax = x[i*C*L+k*L+j];
2989 }
2990 }
2991 }
2992 }
2993
2994 for(int i = 0;i<M;i++){
2995 for(int j = 0;j<L;j++){
2996 for(int k = 0;k<alpha;k++){
2997 x1[i*L*alpha+j*alpha+k] = 0.0f;
2998 }}}
2999
3000 for(int i = 0;i<M;i++){
3001 for(int j = 0;j<L;j++){
3002 x1[i*L*alpha+j*alpha+arg[i*L+j]] = 1.0f;
3003 }}
3004
3005 float mean = 0.0f, std, mean_sqr = 0.0f;
3006 float c_mean = 0.0f, c_mean_sqr = 0.0f;
3007 for (int j = 0; j < M*L*alpha; j++) {
3008 float y = (x1[j]/static_cast<float>(M*L*alpha)) - c_mean;
3009 float t = mean + y;
3010 c_mean = (t - mean) - y;
3011 mean = t;
3012
3013 float y2 = (x1[j]*x1[j]/static_cast<float>(M*L*alpha)) - c_mean_sqr;
3014 float t2 = mean_sqr + y2;
3015 c_mean_sqr = (t2 - mean_sqr) - y2;
3016 mean_sqr = t2;
3017 }

Callers 1

onehotFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected