Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ endif()
list(APPEND _common_compile_options $<$<CXX_COMPILER_ID:MSVC>:/wd4996>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated-declarations>
)
# GCC checks no format strings by default; enforce them as errors.
list(
APPEND
_common_compile_options
$<$<CXX_COMPILER_ID:GNU>:-Wformat;-Wformat-signedness;-Werror=format;-Werror=format-signedness>
)
# Set default CMAKE_POSITION_INDEPENDENT_CODE behavior if ON or not set
# (default) (and not for MSVC compiler)
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE
Expand Down
2 changes: 1 addition & 1 deletion backends/cadence/cadence_executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int main(int argc, char** argv) {
ET_LOG(Error, "Program::load failed: 0x%" PRIx32, program.error());
return 1;
}
ET_LOG(Info, "Model buffer loaded, has %u methods", program->num_methods());
ET_LOG(Info, "Model buffer loaded, has %zu methods", program->num_methods());

const char* method_name = nullptr;
{
Expand Down
11 changes: 8 additions & 3 deletions backends/nxp/runtime/NeutronBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Implementation of the backend for the NXP Neutron NPU.
*/

#include <cinttypes>

#include <executorch/runtime/backend/interface.h>
#include <executorch/runtime/core/error.h>
#include <executorch/runtime/core/evalue.h>
Expand Down Expand Up @@ -382,15 +384,18 @@ class NeutronBackend final : public PyTorchBackendInterface {
if (neutronRC != ENONE) {
ET_LOG(
Error,
"Neutron model preparation failed with error code %ld",
"Neutron model preparation failed with error code %" PRId32,
neutronRC);
return Error::InvalidProgram;
}

#ifdef EXTERNAL_MEM
neutronRC = neutronSetConfig(&neutronMemCopyConfig);
if (neutronRC != ENONE) {
ET_LOG(Error, "Neutron set config failed with error code %ld", neutronRC);
ET_LOG(
Error,
"Neutron set config failed with error code %" PRId32,
neutronRC);
return Error::InvalidProgram;
}
#endif
Expand Down Expand Up @@ -533,7 +538,7 @@ class NeutronBackend final : public PyTorchBackendInterface {
if (neutronRC != ENONE) {
ET_LOG(
Error,
"Neutron model evaluation failed with error code %ld",
"Neutron model evaluation failed with error code %" PRId32,
neutronRC);
return Error::InvalidProgram;
}
Expand Down
2 changes: 1 addition & 1 deletion backends/samsung/runtime/enn_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class EnnBackend final : public PyTorchBackendInterface {
ET_CHECK_OR_RETURN_ERROR(
args[index]->isTensor(),
InvalidArgument,
"Expected argument to delegate at index %u to be a Tensor, but got %" PRIu32,
"Expected argument to delegate at index %d to be a Tensor, but got %" PRIu32,
index,
static_cast<uint32_t>(args[index]->tag));
Tensor* tensor = &args[index]->toTensor();
Expand Down
6 changes: 3 additions & 3 deletions backends/samsung/runtime/enn_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Error EnnExecutor::initialize(const char* binary_buf_addr, size_t buf_size) {
ET_CHECK_OR_RETURN_ERROR(
ret == ENN_RET_SUCCESS, Internal, "Enn initialize failed.");

ET_LOG(Info, "Start to open model %p, %ld", binary_buf_addr, buf_size);
ET_LOG(Info, "Start to open model %p, %zu", binary_buf_addr, buf_size);
ret = enn_api_inst->EnnOpenModelFromMemory(
binary_buf_addr, buf_size, &model_id_);

Expand Down Expand Up @@ -58,13 +58,13 @@ Error EnnExecutor::eval(
ET_CHECK_OR_RETURN_ERROR(
inputs.size() == getInputSize(),
InvalidArgument,
"Invalid number of inputs, expect %" PRIu32 " while get %ld",
"Invalid number of inputs, expect %" PRId32 " while get %zu",
getInputSize(),
inputs.size());
ET_CHECK_OR_RETURN_ERROR(
outputs.size() == getOutputSize(),
InvalidArgument,
"Invalid number of outputs, expected %" PRIu32 " while get %ld",
"Invalid number of outputs, expected %" PRId32 " while get %zu",
getOutputSize(),
outputs.size());

Expand Down
2 changes: 1 addition & 1 deletion examples/arm/executor_runner/arm_perf_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void StopMeasurements(int num_inferences) {
ET_LOG(Info, "Ethos-U PMU report:");
ET_LOG(
Info,
"ethosu_pmu_cycle_cntr : % " PRIu64 " (%.2f per inference)",
"ethosu_pmu_cycle_cntr : %" PRIu64 " (%.2f per inference)",
ethosu_pmuCycleCount,
(double)ethosu_pmuCycleCount / num_inferences);

Expand Down
8 changes: 4 additions & 4 deletions examples/portable/executor_runner/executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ int main(int argc, char** argv) {

ET_CHECK_MSG(
status == Error::Ok,
"get_program_data() from bundle PTE failed: 0x%x" PRIx32,
"get_program_data() from bundle PTE failed: 0x%" PRIx32,
static_cast<uint32_t>(status));
} else {
ET_LOG(Debug, "PTE Model has no bundled IO");
Expand Down Expand Up @@ -848,7 +848,8 @@ int main(int argc, char** argv) {
i,
j,
tensor.const_data_ptr<int8_t>()[j] ? "true " : "false",
tensor.const_data_ptr<int8_t>()[j]);
static_cast<unsigned int>(
static_cast<uint8_t>(tensor.const_data_ptr<int8_t>()[j])));
}
}
} else {
Expand Down Expand Up @@ -888,8 +889,7 @@ int main(int argc, char** argv) {
} else {
ET_LOG(
Info,
"=== Error calculating stats for testset %zu ERROR: 0x%x" PRIx32
"===",
"=== Error calculating stats for testset %zu ERROR: 0x%" PRIx32 "===",
testset_idx,
static_cast<uint32_t>(stats.status));
}
Expand Down
3 changes: 2 additions & 1 deletion extension/android/jni/jni_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <executorch/runtime/platform/runtime.h>
#include <cassert>
#include <chrono>
#include <cinttypes>
#include <iostream>
#include <memory>
#include <sstream>
Expand Down Expand Up @@ -417,7 +418,7 @@ class ExecuTorchJni : public facebook::jni::HybridClass<ExecuTorchJni> {
auto duration =
std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
.count();
ET_LOG(Debug, "Execution time: %lld ms.", duration);
ET_LOG(Debug, "Execution time: %" PRId64 " ms.", duration);

#else
auto result = module_->execute(method, evalues);
Expand Down
10 changes: 5 additions & 5 deletions extension/data_loader/mmap_data_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Result<MmapDataLoader> MmapDataLoader::from(
return Error::AccessFailed;
}
if ((page_size & ~(page_size - 1)) != page_size) {
ET_LOG(Error, "Page size 0x%ld is not a power of 2", page_size);
ET_LOG(Error, "Page size 0x%lx is not a power of 2", page_size);
return Error::InvalidState;
}

Expand Down Expand Up @@ -211,7 +211,7 @@ Result<FreeableBuffer> MmapDataLoader::load(
ET_CHECK_OR_RETURN_ERROR(
pages != MAP_FAILED,
AccessFailed,
"Failed to map %s: mmap(..., size=%zd, ..., fd=%d, offset=0x%zx)",
"Failed to map %s: mmap(..., size=%zu, ..., fd=%d, offset=0x%zx)",
file_name_,
range.size,
fd_,
Expand All @@ -224,7 +224,7 @@ Result<FreeableBuffer> MmapDataLoader::load(
if (mlock_config_ == MlockConfig::UseMlockIgnoreErrors) {
ET_LOG(
Debug,
"Ignoring mlock error for file %s (off=0x%zd): "
"Ignoring mlock error for file %s (off=0x%zx): "
"mlock(%p, %zu) failed: %s (%d)",
file_name_,
offset,
Expand All @@ -235,7 +235,7 @@ Result<FreeableBuffer> MmapDataLoader::load(
} else {
ET_LOG(
Error,
"File %s (off=0x%zd): mlock(%p, %zu) failed: %s (%d)",
"File %s (off=0x%zx): mlock(%p, %zu) failed: %s (%d)",
file_name_,
offset,
pages,
Expand Down Expand Up @@ -321,7 +321,7 @@ Error MmapDataLoader::load_into(
ET_CHECK_OR_RETURN_ERROR(
pages != MAP_FAILED,
AccessFailed,
"Failed to map %s: mmap(..., size=%zd, ..., fd=%d, offset=0x%zx)",
"Failed to map %s: mmap(..., size=%zu, ..., fd=%d, offset=0x%zx)",
file_name_,
range.size,
fd_,
Expand Down
2 changes: 1 addition & 1 deletion extension/flat_tensor/flat_tensor_data_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Result<const flat_tensor_flatbuffer::NamedData*> get_named_data(
ET_CHECK_OR_RETURN_ERROR(
segment_index >= 0 && segment_index < segments->size(),
InvalidExternalData,
"Segment index %zu for key %.*s is out of bounds for segment size %d. Malformed PTD file.",
"Segment index %zu for key %.*s is out of bounds for segment size %u. Malformed PTD file.",
segment_index,
static_cast<int>(key.size()),
key.data(),
Expand Down
6 changes: 3 additions & 3 deletions extension/llm/runner/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ inline void print_report(const Stats& stats) {

ET_LOG(
Info,
"\tPrompt Tokens: %" PRIu64 " Generated Tokens: %" PRIu64,
"\tPrompt Tokens: %" PRId64 " Generated Tokens: %" PRId64,
stats.num_prompt_tokens,
stats.num_generated_tokens);

Expand Down Expand Up @@ -188,7 +188,7 @@ inline void print_report(const Stats& stats) {
(double)(stats.inference_end_ms - stats.prompt_eval_end_ms);
ET_LOG(
Info,
"\t\tGenerated %" PRIu64
"\t\tGenerated %" PRId64
" tokens:\t%f (seconds)\t\t Rate: \t%f (tokens/second)",
stats.num_generated_tokens,
eval_time / stats.SCALING_FACTOR_UNITS_PER_SECOND,
Expand All @@ -206,7 +206,7 @@ inline void print_report(const Stats& stats) {

ET_LOG(
Info,
"\tSampling time over %" PRIu64 " tokens:\t%f (seconds)",
"\tSampling time over %" PRId64 " tokens:\t%f (seconds)",
stats.num_prompt_tokens + stats.num_generated_tokens,
(double)stats.aggregate_sampling_time_ms /
stats.SCALING_FACTOR_UNITS_PER_SECOND);
Expand Down
10 changes: 5 additions & 5 deletions extension/llm/runner/wav_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ inline std::unique_ptr<WavHeader> load_wav_header(
header->RIFF[1],
header->RIFF[2],
header->RIFF[3]);
ET_LOG(Info, "Chunk Size: %d", header->ChunkSize);
ET_LOG(Info, "Chunk Size: %u", header->ChunkSize);
ET_LOG(
Info,
"WAVE Header: %c%c%c%c",
Expand All @@ -194,14 +194,14 @@ inline std::unique_ptr<WavHeader> load_wav_header(
header->fmt[1],
header->fmt[2],
header->fmt[3]);
ET_LOG(Info, "Format Chunk Size: %d", header->Subchunk1Size);
ET_LOG(Info, "Format Chunk Size: %u", header->Subchunk1Size);
ET_LOG(Info, "Audio Format: %d", header->AudioFormat);
ET_LOG(Info, "Number of Channels: %d", header->NumOfChan);
ET_LOG(Info, "Sample Rate: %d", header->SamplesPerSec);
ET_LOG(Info, "Byte Rate: %d", header->bytesPerSec);
ET_LOG(Info, "Sample Rate: %u", header->SamplesPerSec);
ET_LOG(Info, "Byte Rate: %u", header->bytesPerSec);
ET_LOG(Info, "Block Align: %d", header->blockAlign);
ET_LOG(Info, "Bits per Sample: %d", header->bitsPerSample);
ET_LOG(Info, "Subchunk2Size: %d", header->Subchunk2Size);
ET_LOG(Info, "Subchunk2Size: %u", header->Subchunk2Size);

return header;
}
Expand Down
2 changes: 1 addition & 1 deletion extension/runner_util/inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Result<BufferCleanup> prepare_input_tensors(
ET_CHECK_OR_RETURN_ERROR(
inputs != nullptr,
MemoryAllocationFailed,
"malloc(%zd) failed",
"malloc(%zu) failed",
num_inputs * sizeof(void*));

// Allocate memory for each input tensor.
Expand Down
2 changes: 1 addition & 1 deletion extension/wasm/wasm_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline void assert_valid_numel(
computed_numel.error(), "Invalid tensor sizes: numel computation failed");
THROW_IF_FALSE(
data.size() >= static_cast<size_t>(computed_numel.get()),
"Required %ld elements, given %ld",
"Required %zd elements, given %zu",
computed_numel.get(),
data.size());
}
Expand Down
2 changes: 1 addition & 1 deletion kernels/portable/cpu/op_view_as_real_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Tensor& view_as_real_copy_out(
static_cast<size_t>(self.dim()) < kTensorDimensionLimit,
InvalidArgument,
out,
"Output size buffer is too small. Expected at least %zu, got %zu",
"Output size buffer is too small. Expected at least %zd, got %zu",
self.dim() + 1,
kTensorDimensionLimit);
get_view_as_real_copy_out_target_size(self, expected_output_size);
Expand Down
6 changes: 3 additions & 3 deletions kernels/portable/cpu/util/reduce_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void apply_over_dim(
}
ET_CHECK_MSG(
out_ix < get_out_numel(in, dim),
"Out index %zd is out of bounds",
"Out index %zu is out of bounds",
out_ix);

if (in.numel() == 0) {
Expand Down Expand Up @@ -358,7 +358,7 @@ class ApplyOverDimListPlan {

template <typename Fn>
void execute(const Fn& fn, const size_t out_ix) const {
ET_CHECK_MSG(out_ix < out_numel_, "Out index %zd is out of bounds", out_ix);
ET_CHECK_MSG(out_ix < out_numel_, "Out index %zu is out of bounds", out_ix);

switch (mode_) {
case ExecutionMode::NothingToDo:
Expand Down Expand Up @@ -489,7 +489,7 @@ std::tuple<CTYPE_OUT, long> map_reduce_over_dim(

ET_CHECK_MSG(
out_ix < get_out_numel(in, dim),
"Out index %zd is out of bounds",
"Out index %zu is out of bounds",
out_ix);

ET_CHECK_MSG(in.numel() > 0, "Input tensor must be nonempty");
Expand Down
6 changes: 3 additions & 3 deletions runtime/core/exec_aten/util/tensor_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#define ET_CHECK_NON_ZERO_DIM_SIZE(DIM, T) \
const size_t udim = ET_NORMALIZE_IX(DIM, T.dim()); \
ET_CHECK_MSG( \
T.size(udim) != 0, "Expected dim %zd to have non-zero size.", udim);
T.size(udim) != 0, "Expected dim %zu to have non-zero size.", udim);

/**
* Asserts that all tensors have the same shape.
Expand Down Expand Up @@ -272,7 +272,7 @@
do { \
ET_CHECK_MSG( \
a__.dim() == b__.dim(), \
"Two tensors shall have same number of strides, but not %zu and %zu.", \
"Two tensors shall have same number of strides, but not %zd and %zd.", \
a__.dim(), \
b__.dim()); \
const ::executorch::aten::ArrayRef<executorch::aten::StridesType> \
Expand Down Expand Up @@ -301,7 +301,7 @@
ET_CHECK_MSG( \
a__.dim() == b__.dim() && b__.dim() == c__.dim(), \
"Three tensors shall have same number of strides, " \
"but not %zu, %zu and %zu.", \
"but not %zd, %zd and %zd.", \
a__.dim(), \
b__.dim(), \
c__.dim()); \
Expand Down
2 changes: 1 addition & 1 deletion runtime/executor/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ Method::set_input(const EValue& input_evalue, size_t input_idx) {
!overflow,
InvalidArgument,
"Input %" ET_PRIsize_t
": numel overflowed at dimension %zd with size %zd",
": numel overflowed at dimension %zu with size %zu",
input_idx,
(size_t)i,
(size_t)t_src.size(i));
Expand Down
Loading