test: iteration of tracers

This commit is contained in:
Umut
2022-07-19 13:22:05 +02:00
parent 318a171520
commit f5842fb7ad

View File

@@ -0,0 +1,30 @@
"""
Tests of execution of iteration of tracer.
"""
import numpy as np
import pytest
import concrete.numpy as cnp
@pytest.mark.parametrize("shape", [(3,), (3, 2), (3, 2, 4)])
def test_iter(shape, helpers):
"""
Test iteration of tracers.
"""
def function(x):
result = cnp.zeros(x.shape[1:])
for value in x:
result += value
return result
configuration = helpers.configuration()
compiler = cnp.Compiler(function, {"x": "encrypted"})
inputset = [np.random.randint(0, 2**2, size=shape) for _ in range(100)]
circuit = compiler.compile(inputset, configuration)
sample = np.random.randint(0, 2**2, size=shape)
helpers.check_execution(circuit, function, sample)