Take the model input as NHWC - #26
Merged
Merged
Conversation
MatthiasHertelArm
force-pushed
the
nhwc-input
branch
from
September 30, 2026 13:38
25812e5 to
e7a3939
Compare
MatthiasHertelArm
marked this pull request as ready for review
September 30, 2026 13:42
MatthiasHertelArm
force-pushed
the
nhwc-input
branch
from
September 30, 2026 14:22
e7a3939 to
1ca84f5
Compare
TinyCNN took its image as NCHW. The Ethos-U computes on NHWC feature maps, so the command stream began with an operation that only reorders the input. The model now takes NHWC, the layout of a camera frame, and permutes it to NCHW itself; Vela folds that into the first convolution. The layout conversion is gone from the command stream, the program is 8720 bytes instead of 8784, and the Ethos-U scratch 5376 bytes instead of 8704. The runner declares its input as 1x16x16x3; its ramp now fills the image in that order, so the logits differ from the ones before.
MatthiasHertelArm
force-pushed
the
nhwc-input
branch
from
September 30, 2026 14:22
1ca84f5 to
97e6bdd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TinyCNN takes its image as NCHW. The Ethos-U computes on NHWC feature maps, so the command stream of the exported program begins with an operation that does nothing but reorder the input:
On a small model this is cheap. On an image model of realistic size it is not: for a 224x224 SqueezeNet 1.1 the same operation is 15% of the inference cycles Vela estimates, and it was 7.8% of the NPU cycles measured on the Corstone-320 FVP. The example should show the layout that avoids it.
Change
model/model.py:INPUT_SHAPEis(1, 16, 16, 3).TinyCNN.forward()permutes the input to the NCHW its convolutions take; Vela folds that into the first convolution.src/app_main.cpp: the input tensor is1x16x16x3.Effect
The runner's ramp now fills the image in NHWC order, so the logits change; the README shows the new ones.
Checked
ai_layer/is committed; the first NPU operation is the convolution, reading the NHWC input directly.Note for merging
This PR regenerates
ai_layer/model_pte.c. Any other open PR that regenerates the layer needs it regenerated again after this one merges.