google / fully-homomorphic-encryption

An FHE compiler for C++
Apache License 2.0
3.51k stars 252 forks source link

Passing 2 or 3 dimension arrays as parameters to transpiler fails #23

Closed davidbrucecousins closed 2 years ago

davidbrucecousins commented 2 years ago

I have seen the problem with 2 or 3 dimensioned arrays of int and unsigned char, and also with a struct containing the array. Arrays of structs work but not a struct with an array inside.

The following transpiled code ....

pragma_hls_top

void foo(int bar[4][4]) { ... } gives the following errors: Yosys: Use --sandbox_debug to see verbose messages from the sandbox bazel-out/k8-opt/bin/transpiler/examples/foo/bar_yosys_interpreted_cleartext.v:2: ERROR: syntax error, unexpected TOK_PRIMITIVE, expecting TOK_ID

XLS: F0628 11:01:33.027923 4 booleanifier.cc:205] Check failed: array_update->indices().size() == 1 Booleanification is only supported for 1d arrays; got 2. Check failure stack trace: 0x56531575f851: xls::logging_internal::LogMessage::Flush() 0x56531575f9cd: xls::logging_internal::LogMessageFatal::~LogMessageFatal() 0x56531566e289: xls::Booleanifier::HandleSpecialOps() 0x56531569726c: std::_Function_handler<>::_M_invoke() 0x56531569af7e: xls::AbstractEvaluate<>() 0x56531569d20a: xls::Booleanifier::Run() 0x56531569d7e0: xls::Booleanifier::Booleanify() 0x56531568a84a: xls::RealMain() 0x56531568893a: main 0x7fe5dba95083: __libc_start_main

I could not duplicate this using the example/sum3d

the following tarball has and example of code failing.
bazel run --verbose_failures //transpiler/examples/bug2:quick_cleartext_testbench will use the file inc3d.cc from example/sum3d and runs fine! but

bazel run --verbose_failures //transpiler/examples/bug2:foo_cleartext_testbench uses a file called foo.cc that has a similar call signature, and that fails as described above.

both use the same testbench, with only a compile flag to differentiate which function is called (see the BUILD file for the differences)

davidbrucecousins commented 2 years ago

bug2.tar.gz

malchev commented 2 years ago

Fixed in commit 0c323faf7c8ea4af5fedb1129c5324921913c684.