Skip to content

Add Arduino library support for ExecuTorch#20221

Merged
psiddh merged 2 commits into
pytorch:mainfrom
psiddh:arduino-library-support
Jun 19, 2026
Merged

Add Arduino library support for ExecuTorch#20221
psiddh merged 2 commits into
pytorch:mainfrom
psiddh:arduino-library-support

Conversation

@psiddh

@psiddh psiddh commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Add tooling to package the ExecuTorch runtime as an Arduino library, enabling PyTorch model inference on Arduino microcontrollers. The library vendors ET runtime sources, CMSIS-NN kernels, and portable ops into a self-contained package that compiles under the Arduino build system.

Key components:

  • build_arduino_library.sh assembles the distributable library from repository sources (no vendored copies checked in)
  • ExecuTorchArduino.h configures the build environment for Arduino (fixes for std::variant, cmake_macros.h stub, build defines)
  • platform_stubs.c provides C library stubs for the LLEXT environment
  • Example sketches using the native ExecuTorch C++ API (no wrapper layer)
  • Zephyr board config for Arduino Uno Q (STM32U585, Cortex-M33)

Validated on Arduino Uno Q with DS-CNN keyword spotting model (int8, CMSIS-NN): 390+ source files compile, 106 KB flash (13%), 91 KB RAM.

Copilot AI review requested due to automatic review settings June 11, 2026 16:03
@pytorch-bot

pytorch-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20221

Note: Links to docs will display an error until the docs builds have been completed.

❌ 7 New Failures, 4 Unrelated Failures

As of commit 71df531 with merge base 63b4c4d (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 11, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds tooling and example code to package ExecuTorch as an installable Arduino library, with support for building/running on Arduino-class microcontrollers (including a Zephyr-based Arduino Uno Q configuration).

Changes:

  • Add build_arduino_library.sh to assemble a self-contained Arduino library by copying ExecuTorch sources + required third-party headers.
  • Introduce Arduino library metadata/header glue (library.properties, ExecuTorchArduino.h) plus C-library stubs for the target environment.
  • Add Arduino example sketches and a Zephyr board config tuned for Uno Q.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
zephyr/samples/hello-executorch/boards/arduino_uno_q.conf Adds Uno Q memory sizing defaults for ExecuTorch allocators/stack/heap.
examples/arduino/README.md Documents the Arduino library packaging flow and usage.
examples/arduino/platform_stubs.c Adds libc symbol stubs intended for Zephyr LLEXT-style environments.
examples/arduino/library.properties Defines Arduino library metadata (name/version/architectures/includes).
examples/arduino/ExecuTorchArduino.h Provides Arduino-specific compile configuration and exposes the native ExecuTorch C++ API.
examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino Adds a DS-CNN keyword spotting sketch using the native ExecuTorch API.
examples/arduino/examples/HelloExecuTorch/HelloExecuTorch.ino Adds a minimal “runtime_init()” sanity-check sketch.
examples/arduino/build_arduino_library.sh Adds the library assembly script (copies sources, generates stubs, applies patches).
examples/arduino/.gitignore Ignores generated Arduino library output directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/arduino/platform_stubs.c Outdated
Comment thread examples/arduino/platform_stubs.c Outdated
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino Outdated
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino Outdated
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino Outdated
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino Outdated
Comment thread examples/arduino/build_arduino_library.sh
Comment thread examples/arduino/README.md
Comment thread examples/arduino/README.md Outdated
Copilot AI review requested due to automatic review settings June 15, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Comment thread examples/arduino/platform_stubs.c
Comment thread examples/arduino/build_arduino_library.sh
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino Outdated
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino
Comment thread examples/arduino/README.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.

Comment thread examples/arduino/platform_stubs.c Outdated
Comment thread examples/arduino/platform_stubs.c
Comment thread examples/arduino/platform_stubs.c Outdated
Comment thread examples/arduino/examples/AddModel/AddModel.ino Outdated
Comment thread examples/arduino/examples/AddModel/AddModel.ino
Comment thread examples/arduino/examples/AddModel/AddModel.ino Outdated
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino Outdated
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino
Comment thread examples/arduino/README.md
Comment thread examples/arduino/platform_stubs.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread examples/arduino/platform_stubs.c
Comment thread examples/arduino/examples/AddModel/AddModel.ino
Comment thread examples/arduino/examples/KeywordSpotting/KeywordSpotting.ino

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Comment thread examples/arduino/library.properties Outdated
Comment thread examples/arduino/build_arduino_library.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Comment thread examples/arduino/library.properties Outdated
Comment thread examples/arduino/ExecuTorchArduino.h
@psiddh psiddh force-pushed the arduino-library-support branch from 7e528e1 to 771e65c Compare June 17, 2026 03:50
Copilot AI review requested due to automatic review settings June 17, 2026 06:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Comment thread examples/arduino/export_model.py
Comment thread examples/arduino/README.md Outdated
Comment thread examples/arduino/README.md
Comment thread examples/arduino/ExecuTorchArduino.h
@rascani

rascani commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@claude review this PR

@claude

claude Bot commented Jun 17, 2026

Copy link
Copy Markdown

Claude finished @rascani's task in 3m 29s —— View job


Code Review: Arduino library support for ExecuTorch

  • Read changed files
  • Analyze build script, header glue, and stubs
  • Review example sketches and Python tooling
  • Post review feedback

Nice work — this is a substantial and well-organized contribution, and many of the earlier Copilot comments have already been addressed in the current state (weak stubs, schema fail-fast, architectures=zephyr only, perl for the variant patch, OOM checks, dtype/rank guards). My review focuses on what's still actionable. Most are doc/robustness nits; one build claim is genuinely misleading.


Notable

1. README "selective CMSIS-NN inclusion" contradicts the build script (README.md:313-314, build_arduino_library.sh:186)

The README states:

Selective CMSIS-NN inclusion (~30 compiled files vs 111 total)… Arduino only compiles sources referenced by your sketch; unused CMSIS-NN functions are excluded by the linker.

But the script does cp -r "$CMSIS_NN/Source" ... — the entire tree. Arduino compiles every .c/.cpp found recursively under a library's src/ directory; it does not compile only files "referenced by your sketch." Unused functions are dropped by --gc-sections at link time, but all 111 files are still compiled. So either:

  • the framing is inaccurate and should be corrected (linker GC, not selective compilation), or
  • if selective compilation is actually intended for the LLEXT size budget, the script needs to filter the Source copy — which it currently doesn't.

Given the LLEXT budget table claims the "all CMSIS-NN" build (269 KB) is too large and the "selective" build (112 KB) fits, this matters: as written, the packaged library copies everything, so a user following these steps may not get the size profile the table promises. Worth reconciling the script and the docs.

2. Examples won't compile out-of-the-box — model.h is never provided (AddModel.ino:33, HelloExecuTorch.ino:16, KeywordSpotting.ino:32)

All three example sketches #include "model.h" unconditionally, but no model.h is checked in and build_arduino_library.sh doesn't generate one. For a library destined for the Arduino Library Manager, the bundled examples failing to build is a poor first impression. Consider checking in a small pre-generated model.h for at least AddModel (the x+1 model is tiny), and/or __has_include("model.h") guards with a clear #error telling users what to generate. The header comment in AddModel.ino:18-30 is a good touch but doesn't make the sketch build.


Minor / robustness

3. input_data[490] is hardcoded but the model shape isn't validated against it (KeywordSpotting.ino:116-124)

The sketch checks ndim == 4 and scalar_type == Float, but never checks that product(sizes) == 490. It then builds a TensorImpl claiming imeta->sizes() over a fixed 490-element buffer. If a re-exported model has a different total element count, set_input/execute will read out of bounds. A numel == 490 guard before the memcpy would close that gap.

4. fprintf weak stub returns 0 and silently drops output (platform_stubs.c:21-25)

Acceptable as a weak last-resort stub, but worth a one-line comment noting it intentionally discards output so a future debugger isn't confused why logging vanished on boards that fall through to it.

5. README ↔ PR-description number mismatch (README.md:304-310)

The PR body reports "106 KB flash (13%), 91 KB RAM"; the README's LLEXT table reports the DS-CNN selective build as 87 KB code + 25 KB data = 112 KB into a 131 KB budget. These describe different things (LLEXT partition vs flash/RAM), but a reader can't tell. A one-line note clarifying that the budget is the LLEXT region, not total STM32U585 flash/SRAM, would resolve the recurring confusion the earlier reviews flagged.

6. export_model.py lists cmsis_nn / torchao in requirements (export_model.py:18)

cmsis_nn is not imported anywhere in the script and isn't a pip package in most environments; this can send users chasing a nonexistent dependency during setup. Trim the requirements line to what's actually imported.


Things I checked that look correct now

  • platform_stubs.c — symbols are weak, <stdint.h> is included, __aeabi_f2lz is __ARM_EABI__-guarded, handles negatives, and uses a double intermediate to avoid recursion; the comment matches the code. 👍
  • build_arduino_library.sh:112-115 — fails fast with a clear message when program_generated.h is missing. 👍
  • library.properties:15architectures=zephyr only, so the non-Zephyr/mbed zephyr.cpp compile concern from earlier reviews no longer applies (the README "Planned" rows are clearly aspirational).
  • KeywordSpotting now sets the input tensor, checks Result::ok() on planned-buffer sizing, and checks get_outputs/set_input return values.

Fix model.h + CMSIS-NN doc issues →
· branch arduino-library-support

@psiddh

psiddh commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@claude re-review the PR

@claude

claude Bot commented Jun 17, 2026

Copy link
Copy Markdown

Claude finished @psiddh's task in 1m 25s —— View job


Re-review: Arduino library support for ExecuTorch

  • Read changed files
  • Re-check previously-flagged issues (model.h, CMSIS-NN docs, OOM/dtype guards, stubs)
  • Post review feedback

This is in good shape now — the vast majority of the earlier Copilot and review feedback has been addressed in the current tree. I re-verified each prior concern against the code and only one genuine (cosmetic) bug remains, plus a couple of optional polish items.


Confirmed fixed since the last round

  • OOM checksAddModel.ino and KeywordSpotting.ino now null-check the span array and every planned buffer, and bail with a clear Serial message. ✅
  • memory_planned_buffer_size() / get_method_name() / method_meta() Results — all checked with .ok() before use. ✅
  • get_outputs / set_input — return values captured and checked (KeywordSpotting.ino:135,152, AddModel.ino:127,144). ✅
  • Input is actually setKeywordSpotting builds a TensorImpl from MFCC data and calls set_input before execute. ✅
  • Shape/dtype/rank guardsndim != 4, dim_order().size() != 4, scalar_type() != Float, and numel != 490 are all validated before the memcpy (KeywordSpotting.ino:114-129). ✅
  • const-cast removed — sizes/dim_order are copied into local mutable arrays rather than const_casted. ✅
  • model.h missing — all three sketches now #if __has_include("model.h") with a clear #error. ✅
  • <utility> / <cstring> — explicitly included in both sketches. ✅
  • platform_stubs.c — symbols are weak, <stdint.h> included, __aeabi_f2lz is __ARM_EABI__-guarded, handles negatives, uses a double intermediate to avoid recursion, and the comment matches the code. ✅
  • mfcc_*.h / generated test vectorsstatic const (in flash/rodata). ✅
  • ExecuTorchArduino.h macros — now #ifndef-guarded. ✅
  • architectures=zephyr only — so the unconditional <zephyr/...> include in zephyr.cpp is no longer a cross-arch concern. ✅
  • Schema fail-fastbuild_arduino_library.sh:112-115 errors clearly when program_generated.h is absent. ✅
  • CMSIS-NN doc reconciledREADME.md:317-319 now correctly says all sources compile and --gc-sections drops unused functions (no longer claims selective compilation). ✅
  • --zip-path — README now zips the directory first (README.md:84-85). ✅
  • torchaudio requirement — listed in generate_test_input.py:17; stereo downmix present in both scripts. ✅

Remaining (one real, minor)

1. Duplicated paragraph in README (README.md:206-212) — the "4. Compile-time defines" block appears twice, verbatim, and the list also jumps 1, 2, 3, 4, 4 (no item 5). Delete the second copy.

3. **`platform_stubs.c`** — ...
4. **Compile-time defines** — ...   ← keep
4. **Compile-time defines** — ...   ← duplicate, delete

Fix this →

Optional polish (non-blocking)

  • export_model.py:18 — requirements list executorch soundfile numpy torch, but the script also imports torchao (from torchao.quantization...). torchao ships with an ExecuTorch install in most setups, so this is usually harmless, but listing it (or noting it comes with executorch) would save a user a ModuleNotFoundError.
  • Examples still won't build out-of-the-box for the Library Manager — the __has_include guard is a clean failure, but a bundled pre-generated model.h for the tiny AddModel (x+1) would let at least one example compile with zero setup. Worth considering before Library Manager publication; fine to defer.

Nice work iterating on this — it's a clean, self-contained contribution and the runtime-robustness concerns from the earlier passes are all closed out. Nothing here blocks merge beyond the one-line README dedup.
· branch arduino-library-support

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Comment thread examples/arduino/README.md Outdated
Comment thread examples/arduino/export_model.py Outdated
Comment thread examples/arduino/build_arduino_library.sh Outdated
@psiddh

psiddh commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@claude re review this PR one more time

@claude

claude Bot commented Jun 17, 2026

Copy link
Copy Markdown

Claude finished @psiddh's task in 1m 13s —— View job


Re-review: Arduino library support for ExecuTorch

  • Read current state of changed files
  • Re-check previously-flagged issues
  • Post review feedback

I re-verified the full diff against origin/main. Every concern from the prior rounds (Copilot + my own) is now resolved in the tree — including the items flagged in the most recent passes. Nothing blocks merge.


Confirmed fixed since last review

  • README duplicate paragraph — the doubled "4. Compile-time defines" block is gone; the patches list (README.md:196-208) is now 1, 2, 3, 4 with no repeat. ✅
  • export_model.py requirements — now lists torchao (export_model.py:18), matching the from torchao.quantization... import. ✅
  • Guard surgery → supported APIexport_model.py:135 uses exported_program.module(check_guards=False) instead of the brittle manual _guards-node removal. ✅
  • BufferDataLoader dead copy — the build script now only copies the header-only data loader (build_arduino_library.sh:89-91); no buffer_data_loader.cpp copy with a swallowed failure. ✅
  • CMSIS-NN doc reconciledREADME.md:313-315 correctly states all sources compile and --gc-sections drops unused functions. ✅
  • LLEXT budget clarifiedREADME.md:303-304 now notes the 131 KB is a dedicated SRAM region, "not total flash/SRAM," resolving the recurring percentage confusion. ✅
  • Schema fail-fastbuild_arduino_library.sh:110-113 errors clearly when program_generated.h is missing. ✅
  • Stubsplatform_stubs.c symbols are weak, <stdint.h> included, __aeabi_f2lz is __ARM_EABI__-guarded, handles negatives, uses a double intermediate to avoid recursion, and the fprintf discard is commented. ✅
  • Robustness guards (KeywordSpotting) — OOM null-checks on the span array and each planned buffer, Result::ok() on method_meta/memory_planned_buffer_size/input_tensor_meta/get_method_name, ndim != 4 / dim_order().size() != 4 / scalar_type() != Float / numel != 490 validated before the memcpy, sizes/dim_order copied into local mutable arrays (no const_cast), set_input/get_outputs return values checked. ✅
  • model.h guards — all three sketches #if __has_include("model.h") with a clear #error. ✅
  • <utility> / <cstring> — explicitly included. ✅
  • architectures=zephyr only — the Zephyr PAL cross-arch concern no longer applies. ✅
  • MFCC vectors static const — confirmed (live in flash/rodata). ✅
  • Stereo downmix — present in both export_model.py:44 and generate_test_input.py. ✅

Remaining (optional, non-blocking)

  • Examples still won't build with zero setup for the Library Manager. The __has_include guard is a clean, well-messaged failure, but a bundled pre-generated model.h for the tiny AddModel (x+1) would let at least one example compile out-of-the-box. Worth considering before Library Manager publication; fine to defer to a follow-up.

That's the only outstanding item, and it's an enhancement rather than a defect. This is a clean, self-contained, well-iterated contribution — LGTM from my side. 🚀
· branch arduino-library-support

@psiddh

psiddh commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

For Library Manager publication, we'll check in pre-generated model.h files (both AddModel and KeywordSpotting) in the dedicated meta-pytorch/executorch-arduino repo — that repo is a build artifact, so generated blobs are fine there. The main ET repo stays clean of generated headers.

Both examples will compile out of the box for Library Manager users.

Comment on lines +17 to +30
// To generate model.h from a PyTorch model:
// python -c "
// import torch
// from executorch.exir import to_edge
// from torch.export import export
// class AddModel(torch.nn.Module):
// def forward(self, x): return x + 1.0
// et = to_edge(export(AddModel().eval(), (torch.tensor([1.,2.,3.]),))).to_executorch()
// open('model.h','w').write(
// '#pragma once\n#include <cstdint>\n#include <cstddef>\n'
// + 'alignas(16) static const uint8_t model_pte[] = {'
// + ','.join(f'0x{b:02x}' for b in et.buffer) + '};\n'
// + f'static const size_t model_pte_size = {len(et.buffer)};\n')
// "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have a script capable of generating this? If not, we should. It is a very common approach in firmware. One day we should be able to use #embed too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call ,replaced the inline Python blob with a two-step flow that uses the existing examples/arm/executor_runner/pte_to_header.py.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry about the coupling here between the source tree layout and this packaging script. Long-term, we may want to look at using the cmake query apis to deduce source files we need for given targets rather then a script that copies them. Short-term, is there a way we can test this in CI?

From a repository point of view, my understanding is that we'll use this script to publish another repository. If we're going to be setting up another repository, would it make sense to move this script there, with executorch as a submodule?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on all points. Added a NOTE to the script header acknowledging the coupling and the plan forward:

  • Long-term: cmake query APIs to deduce sources for a given target
  • Short-term: CI smoke test (will add as a follow-up)

# - main stack: 8 KB
# - heap: 16 KB
CONFIG_EXECUTORCH_METHOD_ALLOCATOR_POOL_SIZE=65536
CONFIG_EXECUTORCH_TEMP_ALLOCATOR_POOL_SIZE=8192

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temp allocator pool shouldn't be needed any more, since all of the scratch buffer planning has been moved to AOT.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed CONFIG_EXECUTORCH_TEMP_ALLOCATOR_POOL_SIZE from arduino_uno_q.conf and dropped the temp_pool / temp_allocator from all three Arduino sketches

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Comment thread examples/arduino/README.md Outdated
Comment thread zephyr/samples/hello-executorch/boards/arduino_uno_q.conf
Comment thread examples/arduino/export_model.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Comment on lines +152 to +154
# Export with Cortex-M passes
cpu = CortexM.M33 if "m33" in target else CortexM.M55
edge = to_edge(
Comment on lines +214 to +216
return
model = train_model(args.data_dir, args.samples)
torch.save(model.state_dict(), args.output.replace(".h", ".pth"))
Comment on lines +137 to +148
# Calibrate with real audio
quantizer = CortexMQuantizer()
prepared = prepare_pt2e(captured, quantizer)

print("Calibrating with real audio...")
labels = ["yes", "no", "up", "down", "left", "right", "on", "off", "stop", "go"]
for label in labels:
label_dir = os.path.join(calibration_dir, label)
wavs = sorted(f for f in os.listdir(label_dir) if f.endswith(".wav"))
for wav in wavs[50:55]:
prepared(wav_to_mfcc(os.path.join(label_dir, wav)))

Comment on lines +94 to +97
# Download the dataset (one time, ~2.3 GB) — run from repo root:
python -c "import torchaudio; torchaudio.datasets.SPEECHCOMMANDS(
root='outputs/speech_commands', download=True)"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Comment on lines +207 to +214
if not os.path.isdir(args.data_dir):
print(f"Dataset not found at {args.data_dir}")
print(
'Download: python -c "import torchaudio; '
"torchaudio.datasets.SPEECHCOMMANDS(root='outputs/speech_commands', "
'download=True)"'
)
return
Comment on lines +16 to +20
#if __has_include("model.h")
#include "model.h"
#else
#error "model.h not found. Generate it with export_model.py (see README)."
#endif
Comment on lines +46 to +48
} else {
Serial.println("ERROR: Model load failed");
}
psiddh added 2 commits June 18, 2026 18:23
Package ExecuTorch as an Arduino library installable via Library Manager.
Includes build script that vendors runtime sources, DS-CNN keyword
spotting example with CMSIS-NN acceleration, and pre-generated MFCC
test inputs from Google Speech Commands. Tested on Arduino Uno Q
(STM32U585, Cortex-M33).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants