mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
refactor: remove variable length array usages
This commit is contained in:
@@ -12,16 +12,6 @@ if (APPLE)
|
||||
add_definitions("-Wno-narrowing")
|
||||
endif()
|
||||
|
||||
add_compile_options(-Wfatal-errors) # stop at first error
|
||||
# variable length array = vla
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# using Clang
|
||||
add_compile_options(-Wno-vla-extension)
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# using GCC
|
||||
add_compile_options(-Wno-vla)
|
||||
endif()
|
||||
|
||||
# If we are trying to build the compiler with LLVM/MLIR as libraries
|
||||
if( NOT DEFINED LLVM_EXTERNAL_CONCRETELANG_SOURCE_DIR )
|
||||
message(FATAL_ERROR "Concrete compiler requires a unified build with LLVM/MLIR")
|
||||
|
||||
@@ -138,11 +138,11 @@ decryptReturnedTensor(std::istream &istream, ClientLambda &lambda,
|
||||
<< expectedRank << " which cannot be decrypted to rank " << rank;
|
||||
}
|
||||
OUTCOME_TRY(auto values, lambda.decryptReturnedValues(keySet, istream));
|
||||
size_t sizes[rank];
|
||||
llvm::SmallVector<size_t, 6> sizes;
|
||||
for (size_t dim = 0; dim < rank; dim++) {
|
||||
sizes[dim] = shape.dimensions[dim];
|
||||
sizes.push_back(shape.dimensions[dim]);
|
||||
}
|
||||
return flatToTensor<DecryptedTensor>(values, sizes);
|
||||
return flatToTensor<DecryptedTensor>(values, sizes.data());
|
||||
}
|
||||
|
||||
outcome::checked<decrypted_tensor_1_t, StringError>
|
||||
|
||||
@@ -82,10 +82,11 @@ std::ostream &operator<<(std::ostream &ostream, const ClientParameters &cp) {
|
||||
std::istream &operator>>(std::istream &istream, ClientParameters ¶ms) {
|
||||
size_t size;
|
||||
readSize(istream, size);
|
||||
char buffer[size + 1];
|
||||
char *buffer = new char[size + 1];
|
||||
buffer[size] = '\0'; // llvm::json::parse requires \0 ended buffer.
|
||||
istream.read(buffer, size);
|
||||
auto paramsOrErr = llvm::json::parse<ClientParameters>(buffer);
|
||||
delete[] buffer;
|
||||
if (auto err = paramsOrErr.takeError()) {
|
||||
llvm::errs() << "Parsing client parameters error: " << std::move(err)
|
||||
<< "\n";
|
||||
|
||||
@@ -61,8 +61,8 @@ encrypted_scalars_and_sizes_t encrypted_scalars_and_sizes_t_from_MemRef(
|
||||
for (size_t r = 0; r < memref_rank; r++) {
|
||||
result.sizes[r] = sizes[r];
|
||||
}
|
||||
size_t
|
||||
index[memref_rank]; // ephemeral multi dim index to compute global strides
|
||||
size_t *index = new size_t[memref_rank]; // ephemeral multi dim index to
|
||||
// compute global strides
|
||||
for (size_t r = 0; r < memref_rank; r++) {
|
||||
index[r] = 0;
|
||||
}
|
||||
@@ -74,6 +74,7 @@ encrypted_scalars_and_sizes_t encrypted_scalars_and_sizes_t_from_MemRef(
|
||||
result.values[i] = aligned[offset + g_index];
|
||||
next_coord_index(index, sizes, memref_rank);
|
||||
}
|
||||
delete[] index;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user