-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(compiler): overflow in simulation
- Loading branch information
Showing
3 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
compilers/concrete-compiler/compiler/tests/python/overflow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import sys | ||
import shutil | ||
import numpy as np | ||
from concrete.compiler import LibrarySupport | ||
from test_simulation import compile_run_assert | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 2: | ||
print("Usage: overflow.py mlir_file.mlir input_int... expected_out_int") | ||
exit() | ||
|
||
with open(sys.argv[1], "r") as f: | ||
mlir_input = f.read() | ||
|
||
artifact_dir = "./py_test_lib_compile_and_run" | ||
engine = LibrarySupport.new(artifact_dir) | ||
args = list(map(int, sys.argv[2:-1])) | ||
expected_result = int(sys.argv[-1]) | ||
args_and_shape = [] | ||
for arg in args: | ||
if isinstance(arg, int): | ||
args_and_shape.append((arg, None)) | ||
else: # np.array | ||
args_and_shape.append((arg.flatten().tolist(), list(arg.shape))) | ||
compile_run_assert(engine, mlir_input, args_and_shape, expected_result) | ||
shutil.rmtree(artifact_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters