From 38ccacca6959e50d54dac7da866bd7920ff7277f Mon Sep 17 00:00:00 2001 From: Umut Date: Wed, 6 Apr 2022 17:12:27 +0200 Subject: [PATCH] feat: warn possible problematic usage of astype --- concrete/numpy/tracing/tracer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/concrete/numpy/tracing/tracer.py b/concrete/numpy/tracing/tracer.py index ef6ca2448..077ffccdf 100644 --- a/concrete/numpy/tracing/tracer.py +++ b/concrete/numpy/tracing/tracer.py @@ -477,10 +477,16 @@ class Tracer: """ normalized_dtype = np.dtype(dtype) - output_dtype = Value.of(normalized_dtype.type(0)).dtype + if normalized_dtype != np.int64: + print( + "Warning: when using `value.astype(newtype)`, " + "only use `np.int64` as the newtype " + "to avoid unexpected overflows " + "during inputset evaluation" + ) output_value = deepcopy(self.output) - output_value.dtype = output_dtype + output_value.dtype = Value.of(normalized_dtype.type(0)).dtype computation = Node.generic( "astype",