Skip to content

Commit d0f205c

Browse files
NXP Backend: enable CPPCHECK for NXP backend and example (pytorch#20593)
### Summary Enable CPPCHECK for NXP Backend and fix initial findings. Additional fixes in `nxp_executor_runner`: - report error on STDERR, - do not call exit() in function - use C++ import style for C headers. ### Test plan Existing unit test covering. --------- Signed-off-by: Robert Kalmar <robert.kalmar@nxp.com>
1 parent e773a95 commit d0f205c

3 files changed

Lines changed: 123 additions & 50 deletions

File tree

‎.lintrunner.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ exclude_patterns = [
139139
'backends/cuda/**',
140140
'backends/mediatek/**',
141141
'backends/mlx/**',
142-
'backends/nxp/**',
143142
'backends/openvino/**',
144143
'backends/qualcomm/**',
145144
'backends/samsung/**',
@@ -151,7 +150,6 @@ exclude_patterns = [
151150
# Backend-owned examples to onboard with those backends.
152151
'examples/demo-apps/**',
153152
'examples/mediatek/**',
154-
'examples/nxp/**',
155153
'examples/qualcomm/**',
156154
'examples/samsung/**',
157155

‎backends/nxp/runtime/NeutronBackend.cpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ typedef struct {
104104
// Neutron compute has no access to FLASH.
105105
// Prefetch weights from FLASH to SRAM using memcpy.
106106
// For a model converted with --fetch_constants_to_sram.
107-
void copy(void* dst, void* src, uint32_t size, uint32_t channel) {
107+
void copy(void* dst, const void* src, uint32_t size, uint32_t channel) {
108108
memcpy(dst, src, size);
109109
}
110110
void wait(uint32_t channel) {}
@@ -378,8 +378,7 @@ class NeutronBackend final : public PyTorchBackendInterface {
378378
#endif
379379

380380
// Prepare data for through neutron driver.
381-
NeutronError neutronRC =
382-
neutronModelPrepare((const NeutronModelConfig*)&cfg->mcfg, &cfg->nmh);
381+
NeutronError neutronRC = neutronModelPrepare(&cfg->mcfg, &cfg->nmh);
383382
if (neutronRC != ENONE) {
384383
ET_LOG(
385384
Error,
@@ -587,7 +586,7 @@ class NeutronBackend final : public PyTorchBackendInterface {
587586
char* profile_info =
588587
static_cast<char*>(cfg->dcfg.outputs[profiling_index]);
589588
NeutronFullProfilingEvent* neutron_events =
590-
(NeutronFullProfilingEvent*)profile_info;
589+
reinterpreter_cast<NeutronFullProfilingEvent*>(profile_info);
591590
executorch::runtime::EventTracer* tracer = context.event_tracer();
592591
uint32_t start_time = 0;
593592
int index = 0;

0 commit comments

Comments
 (0)