-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Hi,
I understand that to work with float numbers I need to write a code on SFDL. I also know pepper has a feature for private prover input like what we have in "apps_sfdl/genome_snp_freq.c". My question is how can I used the private prover input feature, and at the same type work with float numbers. I wrote a simple code:
program LR {
//Constants
//Dimention of inputs
const SIZE = 3;
//An upper bound for number of multiplication in exponentiation operations defined by a FOR LOOP
const UPPER_B = 10000;
//Precision
const L = 3;
//These two are defined based on L
const TEN_P_L = 1000;
const E_P_TEN_P_ML = 1.0010005;
//Types
type Param = struct {float<32,32>[SIZE] W, float<32,32>[1] B};
type Input = struct {float<32,32>[SIZE] X, hash_t WB};
type Output = struct {float P};
//Main method, called "output"
function Output output (Input In){
var Param p;
hashget(&p, &(In.WB));
var int<32> i;
var float sum;
var float exp;
sum = 0;
exp = 1;
//Computing WX+B
for (i = 0 to SIZE-1)
sum = sum + In.X[i] * p.W[i];
sum = sum + p.B[0];
//Appling precision L
sum = sum * TEN_P_L;
//Computing e^{WX+B}
for (i = 1 to UPPER_B)
if (sum >= i)
exp = exp * E_P_TEN_P_ML;
//Returning e^{WX+B} as the output
output.P = exp;
}
}
but I got the following error:
LOG: Building executables
- compile apps_sfdl/LR_S.sfdl --metrics --cql -b 0 -w 10240 -t ZAATAR -db-hash-func ggh -db-num-addresses 1024 -ram-cell-num-bits 32 -db-hash-num-bits 1216 -db-thr-num-addresses-naive 32768 -fast-ram-address-width 32 -fast-ram-word-width 64
metric_num_lines_in_sfdl LR_S 38
metric_num_lines_in_source LR_S 38
make[1]: Entering directory `/home/fara/pepper/compiler/frontend'
ant compile
Buildfile: /home/fara/pepper/compiler/frontend/build.xml
compile:
BUILD SUCCESSFUL
Total time: 0 seconds
make[1]: Leaving directory `/home/fara/pepper/compiler/frontend'
WARNING: --cstdarithtruncate is disabled, so type errors will warn and arithmetic is not ANSI C compliant
Compiling ../pepper/apps_sfdl/LR_S.sfdl
java.text.ParseException: Unknown type hash_t
at SFE.Compiler.SFECompiler.compileDataType(SFECompiler.java:670)
at SFE.Compiler.SFECompiler.compileStructFields(SFECompiler.java:1041)
at SFE.Compiler.SFECompiler.compileKnownType(SFECompiler.java:776)
at SFE.Compiler.SFECompiler.compileDataType(SFECompiler.java:662)
at SFE.Compiler.SFECompiler.compileType(SFECompiler.java:618)
at SFE.Compiler.SFECompiler.compileTypeDeclarations(SFECompiler.java:575)
at SFE.Compiler.SFECompiler.compileProgram(SFECompiler.java:334)
at zcc.ZCC.compile(ZCC.java:207)
at zcc.ZCC.main(ZCC.java:127)
Error in line 15: Unknown type hash_t
make: *** [apps_sfdl_gen/LR_S.cpp] Error 1
I appreciate if you can advise me on that.
Thanks,
Fattaneh