From 44b1e5bab291019fdbc67f7446e8956f54e7bb0e Mon Sep 17 00:00:00 2001 From: Quentin Bourgerie Date: Tue, 8 Mar 2022 16:34:40 +0100 Subject: [PATCH] fix(clientlib): Allow tensor with dimensions equals to 0 --- compiler/include/concretelang/ClientLib/Types.h | 2 -- compiler/lib/ClientLib/EncryptedArguments.cpp | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/include/concretelang/ClientLib/Types.h b/compiler/include/concretelang/ClientLib/Types.h index 70066eb68..606e383a6 100644 --- a/compiler/include/concretelang/ClientLib/Types.h +++ b/compiler/include/concretelang/ClientLib/Types.h @@ -39,12 +39,10 @@ struct TensorData { inline size_t length() { if (sizes.empty()) { - assert(false); return 0; } size_t len = 1; for (auto size : sizes) { - assert(size > 0); len *= size; } return len; diff --git a/compiler/lib/ClientLib/EncryptedArguments.cpp b/compiler/lib/ClientLib/EncryptedArguments.cpp index 85e9a2a9a..358972885 100644 --- a/compiler/lib/ClientLib/EncryptedArguments.cpp +++ b/compiler/lib/ClientLib/EncryptedArguments.cpp @@ -142,12 +142,12 @@ EncryptedArguments::pushArg(size_t width, const void *data, for (size_t size : values_and_sizes.sizes) { preparedArgs.push_back((void *)size); } + // Set the stride for each dimension, equal to the product of the // following dimensions. int64_t stride = values_and_sizes.length(); - // If encrypted +1 set the stride for the lwe size rank for (size_t size : values_and_sizes.sizes) { - stride /= size; + stride = (size == 0 ? 0 : (stride / size)); preparedArgs.push_back((void *)stride); } currentPos++;