-
Notifications
You must be signed in to change notification settings - Fork 870
Remove extern "C" wrapping and fix format specifiers for ARM embedded builds #18000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,12 +16,12 @@ | |||||||||||||||||||||
| #include <executorch/kernels/portable/cpu/util/kernel_ops_util.h> | ||||||||||||||||||||||
| #include <executorch/runtime/platform/assert.h> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #include <cinttypes> | ||||||||||||||||||||||
| #include <limits> | ||||||||||||||||||||||
| #include <optional> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| extern "C" { | ||||||||||||||||||||||
| #include "arm_nn_types.h" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| #include "arm_nnfunctions.h" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+19
to
25
|
||||||||||||||||||||||
| using Tensor = torch::executor::Tensor; | ||||||||||||||||||||||
| using ScalarType = executorch::aten::ScalarType; | ||||||||||||||||||||||
|
|
@@ -47,19 +47,19 @@ inline void validate_cmsis_nn_tensor_requirements( | |||||||||||||||||||||
| // Basic dtype validation | ||||||||||||||||||||||
| ET_CHECK_MSG( | ||||||||||||||||||||||
| input1.scalar_type() == expected_dtype, | ||||||||||||||||||||||
| "Input1 dtype must be %hhd, got %hhd", | ||||||||||||||||||||||
| expected_dtype, | ||||||||||||||||||||||
| input1.scalar_type()); | ||||||||||||||||||||||
| "Input1 dtype must be %d, got %d", | ||||||||||||||||||||||
| static_cast<int>(expected_dtype), | ||||||||||||||||||||||
| static_cast<int>(input1.scalar_type())); | ||||||||||||||||||||||
| ET_CHECK_MSG( | ||||||||||||||||||||||
| input2.scalar_type() == expected_dtype, | ||||||||||||||||||||||
| "Input2 dtype must be %hhd, got %hhd", | ||||||||||||||||||||||
| expected_dtype, | ||||||||||||||||||||||
| input2.scalar_type()); | ||||||||||||||||||||||
| "Input2 dtype must be %d, got %d", | ||||||||||||||||||||||
| static_cast<int>(expected_dtype), | ||||||||||||||||||||||
| static_cast<int>(input2.scalar_type())); | ||||||||||||||||||||||
| ET_CHECK_MSG( | ||||||||||||||||||||||
| output.scalar_type() == expected_dtype, | ||||||||||||||||||||||
| "Output dtype must be %hhd, got %hhd", | ||||||||||||||||||||||
| expected_dtype, | ||||||||||||||||||||||
| output.scalar_type()); | ||||||||||||||||||||||
| "Output dtype must be %d, got %d", | ||||||||||||||||||||||
| static_cast<int>(expected_dtype), | ||||||||||||||||||||||
| static_cast<int>(output.scalar_type())); | ||||||||||||||||||||||
| if (require_same_sizes) { | ||||||||||||||||||||||
| ET_CHECK_MSG( | ||||||||||||||||||||||
| input1.sizes() == input2.sizes(), | ||||||||||||||||||||||
|
|
@@ -78,16 +78,17 @@ inline void validate_single_quant_params( | |||||||||||||||||||||
| const int64_t multiplier, | ||||||||||||||||||||||
| const int64_t shift, | ||||||||||||||||||||||
| const char* param_name) { | ||||||||||||||||||||||
| (void)zero_point; | ||||||||||||||||||||||
| ET_CHECK_MSG( | ||||||||||||||||||||||
|
Comment on lines
+81
to
82
|
||||||||||||||||||||||
| (void)zero_point; | |
| ET_CHECK_MSG( | |
| ET_CHECK_MSG( | |
| zero_point >= std::numeric_limits<int8_t>::min() && | |
| zero_point <= std::numeric_limits<int8_t>::max(), | |
| "%s zero_point must be in int8 range [-128, 127] [Value: %" PRIi64 "]", | |
| param_name, | |
| zero_point); | |
| ET_CHECK_MSG( |
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In validate_single_quant_params, the zero_point parameter is unused. If this header is compiled with -Wall, this can trigger -Wunused-parameter (often fatal with -Werror on embedded toolchains). Consider removing the parameter, marking it ET_UNUSED, or implementing the intended zero-point range validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that
cortex_m_ops_common.hincludes CMSIS-NN headers, this file’s direct#include "arm_nnfunctions.h"is redundant and also puts CMSIS includes before the common header (which may introduce ordering issues depending on CMSIS header dependencies). Prefer relying oncortex_m_ops_common.halone, or include it first and drop the standalone CMSIS include.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed OOB, we typically follow the Google C++ style guide, which recommends against transitive includes.