mirror of
https://github.com/zama-ai/concrete.git
synced 2026-01-09 12:57:55 -05:00
fix(frontend-python): assigning signed values to unsigned tensors
This commit is contained in:
@@ -1559,6 +1559,7 @@ class Context:
|
||||
np.broadcast_to(np.zeros(y.shape), required_y_shape)
|
||||
y = self.broadcast_to(y, required_y_shape)
|
||||
|
||||
x = self.to_signedness(x, of=resulting_type)
|
||||
y = self.to_signedness(y, of=resulting_type)
|
||||
|
||||
return self.operation(
|
||||
|
||||
@@ -5,6 +5,7 @@ Configuration of `pytest`.
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, List, Tuple, Union
|
||||
|
||||
@@ -295,8 +296,8 @@ class Helpers:
|
||||
|
||||
if not only_simulation:
|
||||
for i in range(retries):
|
||||
expected = sanitize(function(*sample))
|
||||
actual = sanitize(circuit.encrypt_run_decrypt(*sample))
|
||||
expected = sanitize(function(*deepcopy(sample)))
|
||||
actual = sanitize(circuit.encrypt_run_decrypt(*deepcopy(sample)))
|
||||
|
||||
if all(np.array_equal(e, a) for e, a in zip(expected, actual)):
|
||||
break
|
||||
@@ -317,8 +318,8 @@ class Helpers:
|
||||
|
||||
circuit.enable_fhe_simulation()
|
||||
for i in range(retries):
|
||||
expected = sanitize(function(*sample))
|
||||
actual = sanitize(circuit.simulate(*sample))
|
||||
expected = sanitize(function(*deepcopy(sample)))
|
||||
actual = sanitize(circuit.simulate(*deepcopy(sample)))
|
||||
|
||||
if all(np.array_equal(e, a) for e, a in zip(expected, actual)):
|
||||
break
|
||||
|
||||
@@ -443,6 +443,21 @@ def assignment_case_28():
|
||||
return shape, assign
|
||||
|
||||
|
||||
def assignment_case_29():
|
||||
"""
|
||||
Assignment test case.
|
||||
"""
|
||||
|
||||
shape = (5,)
|
||||
value = -20
|
||||
|
||||
def assign(x):
|
||||
x[0] = value
|
||||
return x
|
||||
|
||||
return shape, assign
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"shape,function",
|
||||
[
|
||||
@@ -475,6 +490,7 @@ def assignment_case_28():
|
||||
pytest.param(*assignment_case_26()),
|
||||
pytest.param(*assignment_case_27()),
|
||||
pytest.param(*assignment_case_28()),
|
||||
pytest.param(*assignment_case_29()),
|
||||
],
|
||||
)
|
||||
def test_static_assignment(shape, function, helpers):
|
||||
|
||||
Reference in New Issue
Block a user