mirror of
https://github.com/zama-ai/concrete.git
synced 2026-04-17 03:00:54 -04:00
feat(frontend-python): add support for np.copy
This commit is contained in:
@@ -307,6 +307,10 @@ class Converter:
|
||||
ctx.error({node: "3-dimensional convolutions are not supported at the moment"})
|
||||
assert False, "unreachable" # pragma: no cover
|
||||
|
||||
def copy(self, ctx: Context, node: Node, preds: List[Conversion]) -> Conversion:
|
||||
assert len(preds) == 1
|
||||
return preds[0]
|
||||
|
||||
def dot(self, ctx: Context, node: Node, preds: List[Conversion]) -> Conversion:
|
||||
assert len(preds) == 2
|
||||
return ctx.dot(ctx.typeof(node), preds[0], preds[1])
|
||||
|
||||
@@ -226,6 +226,7 @@ class Tracer:
|
||||
np.ceil,
|
||||
np.clip,
|
||||
np.concatenate,
|
||||
np.copy,
|
||||
np.copysign,
|
||||
np.cos,
|
||||
np.cosh,
|
||||
|
||||
@@ -202,6 +202,16 @@ def deterministic_unary_function(x):
|
||||
return np.vectorize(per_element)(x)
|
||||
|
||||
|
||||
def copy_modify(x):
|
||||
"""
|
||||
A function that used `np.copy` and then modifies the copied object.
|
||||
"""
|
||||
|
||||
y = np.copy(x)
|
||||
y[1] = np.sum(x)
|
||||
return np.concatenate((x, y))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"function,parameters",
|
||||
[
|
||||
@@ -691,6 +701,13 @@ def deterministic_unary_function(x):
|
||||
},
|
||||
id="fhe.LookupTable([10, 5])[x > 5]",
|
||||
),
|
||||
pytest.param(
|
||||
copy_modify,
|
||||
{
|
||||
"x": {"status": "encrypted", "range": [0, 10], "shape": (3,)},
|
||||
},
|
||||
id="copy_modify",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_others(function, parameters, helpers):
|
||||
|
||||
Reference in New Issue
Block a user