Skip to content

Zephyr: report the host reference label alongside the top-5 - #23353

Merged
psiddh merged 1 commit into
pytorch:mainfrom
psiddh:sidart/zephyr-sample-host-reference
Oct 2, 2026
Merged

psiddh merged 1 commit into
pytorch:mainfrom
psiddh:sidart/zephyr-sample-host-reference

Conversation

@psiddh

@psiddh psiddh commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

gen_input.py writes MV2_HOST_TOP1 and MV2_HOST_LABEL into mv2_input.h, but nothing reads them. The sample prints bare class IDs, so a reader cannot interpret the output on target without an ImageNet label table.

This prints the recorded host prediction after the top-5 and states whether the device top-1 agrees:

Top-5 predictions:
  [1] class 258: 6.1895
  [2] class 259: 4.8418
  [3] class 261: 3.4442

host float32 reference: class 258 (Samoyed) -> device top-1 MATCHES

Guarded on both defines, so headers generated before #23300 still build. No label table is added to the target; the single string already comes from the generated header.

Verification

Flashed and run on an Alif Ensemble E8 DevKit (Cortex-M55 HP at 400 MHz + Ethos-U55, 256 MAC) with Zephyr 4.4.0 and Zephyr SDK 1.0.1, using a photograph prepared by gen_input.py and an INT8 model calibrated on 250 ImageNet photos. Inference completed in 28 ms and the device top-1 matched the float32 torchvision reference.

Flash cost is 160 bytes.

Authored with Claude.

gen_input.py writes MV2_HOST_TOP1 and MV2_HOST_LABEL into mv2_input.h, but
nothing reads them. The sample prints bare class IDs, so the output cannot be
interpreted on target without an ImageNet label table.

Print the recorded host prediction after the top-5 and state whether the
device top-1 agrees, which turns the result into something readable:

  host float32 reference: class 258 (Samoyed) -> device top-1 MATCHES

Guarded on both defines, so headers generated before this change still build.
Costs no label table on target.

Verified on an Alif Ensemble E8 DevKit (Cortex-M55 HP + Ethos-U55 256 MAC)
with Zephyr 4.4.0 and Zephyr SDK 1.0.1, classifying a photograph prepared by
gen_input.py.

Authored with Claude.
Copilot AI balanced review requested due to automatic review settings October 2, 2026 07:37
@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 57a3ce8 with merge base 89809c4 (image):

NEW FAILURE - The following job has failed:

  • Cadence Build & Test / Resolve CI docker image / resolve (gh)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.

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 Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

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.

@psiddh
psiddh requested review from digantdesai and rascani October 2, 2026 07:39

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.

Copilot review overview

🟢 Approval recommended

The change is correct, narrowly scoped, and backward compatible.

Review effort: Balanced
Findings: None

What changed in this PR

Adds readable host-reference output to the Zephyr MobileNetV2 sample.

Changes:

  • Prints the host class ID and label after top-5 results.
  • Reports whether device top-1 matches the host prediction.
  • Preserves compatibility with older generated headers.
File Description
zephyr/​samples/​mv2-ethosu/​src/​main.cpp Adds guarded host-reference reporting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@psiddh
psiddh requested a review from JakeStevens October 2, 2026 16:23
@psiddh
psiddh merged commit a78b4da into pytorch:main Oct 2, 2026
364 of 368 checks passed
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