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

Function ecall_lessequal

sgx_tf_ops/Enclave/Enclave.cpp:1579–1629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1577}
1578
1579void ecall_lessequal(float *input,int N,float *output,float alpha){
1580 float *x = (float*)malloc(sizeof(float)*N);
1581 memset(x, 0, sizeof(float)*N);
1582 for(int j=0;j<N;j++){
1583 x[j] = 0.0f;
1584 float sum = input[insert*N+j];
1585 float c = 0.0f;
1586 for(int i=0;i<Nt;i++){
1587 float y = input[indexs[i]*N+j] - c;
1588 float t = sum + y;
1589 c = (t - sum) - y;
1590 sum = t;
1591 }
1592 x[j] = sum;
1593 }
1594 for (int j = 0; j < N; j++) {
1595 x[j]= (x[j] - alpha) <= 1e-7f ? 1.0f : 0.0f;
1596 }
1597 float mean = 0.0f, std, mean_sqr = 0.0f;
1598 float c_mean = 0.0f, c_mean_sqr = 0.0f;
1599 for (int j = 0; j < N; j++) {
1600 float y = (x[j]/static_cast<float>(N)) - c_mean;
1601 float t = mean + y;
1602 c_mean = (t - mean) - y;
1603 mean = t;
1604
1605 float y2 = (x[j]*x[j]/static_cast<float>(N)) - c_mean_sqr;
1606 float t2 = mean_sqr + y2;
1607 c_mean_sqr = (t2 - mean_sqr) - y2;
1608 mean_sqr = t2;
1609 }
1610 std = sqrtf(fabs(mean_sqr - mean * mean))/static_cast<float>(Nt);
1611 mean = mean/static_cast<float>(Nt);
1612 for(int i=0;i<N*(Ne-1);i++){
1613 output[i] =(x[i%N] - gaussrand(mean, std))/static_cast<float>(Nt+1);
1614 }
1615 for(int j=N*(Ne-1);j<N*Ne;j++){
1616 output[j] = 0.0f;
1617 float sum = 0.0f;
1618 float c = 0.0f;
1619 for(int i=0;i<Nt;i++){
1620 float y = -1.0f * output[indexs[i]*N+(j-N*(Ne-1))] - c;
1621 float t = sum + y;
1622 c = (t - sum) - y;
1623 sum = t;
1624 }
1625 output[j] =x[j-N*(Ne-1)] + sum;
1626 }
1627 free(x);
1628 return;
1629 }
1630
1631void ecall_greater(float *input,int N,float *output,float alpha){
1632 float *x = (float*)malloc(sizeof(float)*N);

Callers 1

lessequalFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected