fix(clientlib): Allow tensor with dimensions equals to 0

This commit is contained in:
Quentin Bourgerie
2022-03-08 16:34:40 +01:00
parent 1ffd480d07
commit 44b1e5bab2
2 changed files with 2 additions and 4 deletions

View File

@@ -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;

View File

@@ -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++;