wikillm

Paper · 2022-06-21 · cs.CV

EdgeNeXt: Efficiently Amalgamated CNN-Transformer Architecture for Mobile Vision Applications

EdgeNeXt is a mobile hybrid CNN-transformer. Its SDTA block splits channels into groups, applies depth-wise convolutions across them, and runs self-attention across channels, so attention cost grows linearly with image size. Author-reported: 79.4% ImageNet-1K top-1 with 5.6M parameters and 1.3G MAdds at 256px, above MobileViT-S's 78.4%.

Efficient vision backbonesVision Transformer (ViT) backbonesDepthwise separable convolutionSelf-attentionvisionmobilehybrid-architectureimage-classificationefficient-inference

arXivPDFCodeMarkdown16 min read

AI-compiled by claude-haiku-5-5 on 2026-10-31, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Phone and robot cameras need image models that are small and fast. Today the strongest small models are either convolutional networks, which look at neighbouring pixels well but miss the whole picture, or transformers, which see the whole picture but are slow on weak hardware. This paper builds a model that mixes both.

The model is a stack of convolution blocks, with a few special blocks near the end. Each special block splits its channels into groups. Some groups get small convolutions that look at slightly different neighbourhood sizes. The result is then passed through an attention step, but the attention compares channels to channels rather than every pixel to every pixel. That keeps its cost roughly proportional to the image size, which is what makes it usable on mobile devices.

The authors report that this gives better accuracy for a given speed and size than a comparable hybrid model, MobileViT, on image classification, and that the same backbone also helps object detection and segmentation.

TL;DR

EdgeNeXt is a small hybrid CNN-transformer for mobile vision. Its SDTA block combines multi-scale depth-wise convolutions with transposed (channel-wise) self-attention, which is linear in the number of pixels. The authors report 79.4% ImageNet-1K top-1 at 256px for the 5.6M-parameter model, versus 78.4% for MobileViT-S, with 35% fewer MAdds. The official code is MIT-licensed and matches the paper in most places, but it differs in several details that matter for reimplementation (see Paper vs code).

Problem

Self-attention over all pixels is quadratic in the number of tokens, so transformer-style vision models are slow on edge hardware §1. Pure CNNs are cheap but have a local receptive field and fixed weights at inference §1. Earlier hybrids such as MobileViT keep spatial attention and therefore still spend most of their MAdds on attention; the authors argue this is the main bottleneck for mobile inference §2. The goal is a model that is small in parameters and MAdds and still models global context §1, Contributions.

Method

The network is a four-stage hierarchy at strides 4, 8, 16 and 32 [§3 Overall Architecture]. Stage 1 uses a patchify stem and convolution encoders. Stages 2 to 4 start with a 2×2 strided downsampling convolution. The last block of each of stages 2 to 4 is an SDTA encoder; all other blocks are convolution encoders §3 Overall Architecture fig. 2 tab. 1.

1. Convolution encoder §3 Convolution Encoder eq. 1. A depth-wise k×k convolution mixes space, followed by layer norm, two pointwise (1×1) linear layers and a residual connection. The kernel size grows with depth: k = 3, 5, 7, 9 for stages 1 to 4 §3 Convolution Encoder tab. 1. Eq. 1 writes the second pointwise layer together with a GELU and places the activation after it. The residual adds the block input to that output.

2. SDTA encoder §3 SDTA Encoder eq. 2 eq. 3 eq. 4. Three steps.

  • Multi-scale split. The C input channels are split into s subsets of C/s channels each. Subsets are processed in a chain: each depth-wise 3×3 conv gets its own subset plus the previous subset's output eq. 2. The number of subsets s depends on the stage (t ∈ {2, 3, 4}), but the text does not give the values §3 SDTA Encoder.
  • Transposed attention. Query, key and value projections of the normalized tensor are computed with three linear layers. Q and K are L2-normalized. The attention matrix is formed across channels, giving a C×C softmax score, which is multiplied by V and added to the input eq. 3 eq. 4.
  • Light MLP. Two 1×1 convolutions with layer norm and GELU follow the attention output §3 SDTA Encoder.

3. Positional encoding. Added once, before the SDTA block of stage 2 only; adding it in every stage increased latency and hurt dense prediction §3 Overall Architecture.

4. Head. Global average pooling and a linear classifier tab. 1.

Pseudocode
# Convolution encoder  [§3 Convolution Encoder]  [eq. 1]
# Input: x (B, C, H, W); k = kernel size for this stage (3, 5, 7 or 9)
# Output: x (B, C, H, W)

def conv_encoder(x, k):
    # Depth-wise k x k conv for spatial mixing  [eq. 1: Dw]
    mixed = depthwise_conv(x, kernel_size=k)
    # Layer norm, then the first pointwise linear  [eq. 1: LN, Linear]
    hidden = linear_first(layer_norm(mixed))
    # Second pointwise linear followed by GELU  [eq. 1: Linear_G]
    out = gelu(linear_second(hidden))
    # Residual connection  [eq. 1]
    return x + out
Pseudocode
# SDTA encoder  [§3 SDTA Encoder]  [eq. 2] [eq. 3] [eq. 4]
# Input: x (B, C, H, W); s = number of subsets for this stage (not stated)
# Output: x_hat (B, C, H, W)

def sdta_encoder(x, s):
    # Split channels into s subsets of C / s channels  [§3 SDTA Encoder]
    subsets = split_channels(x, s)
    # The first subset is kept as is  [eq. 2, i = 1]
    outputs = [subsets[0]]
    for i in range(2, s + 1):
        # Depth-wise 3x3 conv of this subset plus the previous output  [eq. 2]
        outputs.append(dwconv3x3(subsets[i - 1] + outputs[i - 2]))
    # Put the subsets back together along channels  [§3 SDTA Encoder]
    multi_scale = concat_channels(outputs)
    # Flatten to tokens (B, H*W, C); stage 2 adds a positional encoding
    # before this block  [§3 Overall Architecture]
    tokens = flatten(multi_scale)                  # (B, H*W, C)
    # Linear projections of the normalized tokens  [§3 SDTA Encoder]
    queries = linear_q(layer_norm(tokens))         # (B, H*W, C)
    keys = linear_k(layer_norm(tokens))            # (B, H*W, C)
    values = linear_v(layer_norm(tokens))          # (B, H*W, C)
    # L2-normalize queries and keys  [§3 SDTA Encoder]
    queries = l2_normalize(queries)
    keys = l2_normalize(keys)
    # Channel-by-channel score matrix, softmax over channels  [eq. 4]
    scores = softmax(transpose(queries) @ keys)    # (B, C, C)
    # Weight the values by the scores and add the input  [eq. 3] [eq. 4]
    attended = values @ scores                     # (B, H*W, C)
    x = x + unflatten(attended)
    # Two 1x1 convs with layer norm and GELU  [§3 SDTA Encoder]
    return x + mlp(layer_norm(x))

Overall network. Patchify stem (4×4 non-overlapping conv, then layer norm), then convolution encoders in stage 1 and downsampling plus blocks in stages 2 to 4 §3 Overall Architecture tab. 1. The parameter-size variants XXS, XS and S use the channel widths in tab. 1. The block counts in tab. 1 for XS and S match the official code; the XXS counts do not (see Paper vs code).

Variants and training data. Three sizes: XXS (1.3M parameters, 0.3G MAdds), XS (2.3M, 0.5G), S (5.6M, 1.3G) tab. 1. A larger model, EdgeNeXt-B (18.5M parameters, 3.8G MAdds), is trained on an ImageNet-21K subset §4.4 tab. 4; its layout is not in the paper.

Hyperparameters

Values for the ImageNet-1K classification runs unless marked otherwise. "Code" means the official repository at code_commit; code-only values are flagged because the paper does not state them.

NameValueWhereNotes
Train input resolution256×256§4.2 main.py224×224 also trained for S §4.2
Test preprocessingresize to 292, center crop 256§4.2 datasets.pyMatches the code
Effective batch size4096§4.2 main.py README.mdCode: 256 per GPU × update_freq 2 × 8 GPUs
Epochs300§4.2 main.py
OptimizerAdamW§4.2 main.pyBetas and eps: code defaults only, not in the paper
Learning rate6e-3§4.2 main.pyNot stated whether scaled with batch size
Weight decay0.05§4.2 main.pyWhether it applies to norms and biases: not stated
LR schedulecosine with linear warmup§4.2Warmup 20 epochs; min LR 1e-6 and warmup start 0 are code defaults main.py
Random resized cropused§4.2Scale range: not stated
Horizontal flipused§4.2
RandAugmentS only§4.2 main.pyCode default is rand-m9-mstd0.5-inc1 on for every run unless disabled; the variant comments say XXS and XS trained without it model.py model.py
Colour jitternot in papermain.pyCode default 0.4
Label smoothingnot in papermain.pyCode default 0.1
Mixup / CutMixnot in paper for Smain.py model.pyOff by default; the EdgeNeXt-B comment says on
Multi-scale samplerused§4.2 main.pyCrop sizes: width 160–320 and height 160–320 main.py
Stochastic depth (drop path)0.1, S only§4.2 README.mdCode default is 0.1 for every run main.py; variant comments say 0.0 for XXS and XS
EMA of weightsdecay 0.9995§4.2 main.pyCode default is off; the README training command turns it on README.md
Layer-scale initnot statedmain.pyCode default 1e-6
Classifier dropoutnot statedmain.pyCode default 0.0
Gradient clippingnot statedmain.pyCode default none
Precisionnot statedmain.pyCode default AMP on
Hardware, classification8× A100, about 30 h for S§4.2
Stage widths, XXS24, 48, 88, 168tab. 1 model.pyMatches code
Stage widths, XS32, 64, 100, 192tab. 1 model.pyMatches code
Stage widths, S48, 96, 160, 304tab. 1 model.pyMatches code
Stage widths, Bnot in papermodel.pyCode: 80, 160, 288, 584
Block counts, XXS3, 3, 9, 3 (per table)tab. 1Code: 2, 2, 6, 2 model.py
Block counts, XS and S3, 3, 9, 3tab. 1 model.py model.pyMatch
Kernel sizes per stage3, 5, 7, 9§3 Convolution Encoder tab. 1 model.pyMatch for XXS, XS, S and B
Subsets s per stage (SDTA)not stated in paper§3 SDTA Encoder model.pyCode: 2, 2, 3, 4 for stages 1–4, SDTA only in stages 2–4
XCA headsnot stated in papermodel.py model.pyCode: 4 for XXS and XS; 8 by default for S and B edgenext.py
MLP expansion rationot stated in paperedgenext.pyCode: 4
Positional encodingnot stated in paperlayers.pyCode: 2D Fourier sine/cosine features, hidden dim 32
Detection: frameworkSSDLite, 320×320§4.6Training hyperparameters: "similar to MobileViT" §4.2; not stated here
Segmentation: frameworkDeepLabv3, 512×512§4.7Pascal VOC plus extra data from COCO and Hariharan et al. §4.1
ImageNet-21K-P pretraining10,450 classes, about 11M train and 522K val images§4.4Recipe: "strictly follow" ConvNeXt; initialized from an ImageNet-1K model
ImageNet-1K fine-tune after 21K30 epochs, LR 7.5e-5, batch 512§4.4
Distillation teacher (81.1%)not stated§4.3Paper cites "knowledge distillation following [usi]"; the code README calls the same model a USI training recipe

Results

Author-reported. ImageNet-1K top-1 on the validation set, no retraining by us. Input size varies by row as published: Table 2 lists 224 and 256 px; the MobileViT comparison in Table 3 is at 256 px §4.3. MAdds and latency use the paper's own measurement.

ImageNet-1K classification, state of the art tab. 2:

FamilyModelDateInputParamsMAddsTop-1
ConvNetsMobileNetV2CVPR20182246.9M585M74.7
ConvNetsShuffleNetV2ECCV20182245.5M597M74.5
ConvNetsMobileNetV3ICCV20192245.4M219M75.2
ViTsT2T-ViTICCV20212246.9M1.80G76.5
ViTsDeiT-TICML20212245.7M1.25G72.2
HybridMobileFormerCoRR20212249.4M214M76.7
HybridViT-CNeurIPS20212244.6M1.10G75.3
HybridCoaT-Lite-TICCV20212245.7M1.60G77.5
HybridMobileViT-SICLR20222565.6M2.01G78.4
OursEdgeNeXt-S—2245.6M965M78.8
OursEdgeNeXt-S—2565.6M1.30G79.4

Source: tab. 2. A knowledge-distilled S model reaching 81.1% is mentioned in the text §4.3 and in a commented-out row of tab. 2; it is not in the table.

Against MobileViT at matched size tab. 3, all 256 px:

ModelParamsMAddsTop-1Jetson Nano latency (TensorRT, FP16, batch 1)A100 latency (PyTorch, batch 256, as published)
MobileViT-XXS1.3M364M69.021.0 ms216 µs
MobileViT-XS2.3M886M74.835.1 ms423 µs
MobileViT-S5.6M2.01G78.453.0 ms559 µs
EdgeNeXt-XXS1.3M261M71.219.3 ms142 µs
EdgeNeXt-XS2.3M538M75.031.6 ms227 µs
EdgeNeXt-S5.6M1.30G79.448.8 ms332 µs

Source: tab. 3 §4.5. The text says the XXS model is about 34% faster than MobileViT-XXS on A100 and about 8% faster on Jetson Nano §4.5; these figures match the table.

ImageNet-21K-P pretraining tab. 4:

ModelPretrainingInputParamsMAddsTop-1
ConvNeXt-Tnone22428.6M4.5G82.1
ConvNeXt-TImageNet-21K22428.6M4.5G82.9
MobileViT-V2none25618.5M7.5G81.2
MobileViT-V2ImageNet-21K-P25618.5M7.5G82.4
EdgeNeXt-Bnone25618.5M3.8G82.5
EdgeNeXt-BImageNet-21K-P25618.5M3.8G83.3

Source: tab. 4 §4.4.

COCO object detection, SSDLite at 320×320 tab. 5:

ModelParamsMAddsbox mAP
MobileNetV15.1M1.3G22.2
MobileNetV24.3M800M22.1
MobileNetV35.0M620M22.0
MobileViT-S5.7M3.4G27.7
EdgeNeXt-S6.2M2.1G27.9

Source: tab. 5 §4.6. The table compares against three MobileNets and MobileViT-S only.

Pascal VOC semantic segmentation, DeepLabv3 at 512×512 tab. 6:

ModelParamsMAddsmIoU
MobileNetV111.1M14.2G75.3
MobileNetV24.5M5.8G75.7
MobileViT-S5.7M13.7G79.1
EdgeNeXt-S6.5M8.7G80.2

Source: tab. 6 §4.7.

Ablations (all on EdgeNeXt-S, ImageNet-1K top-1, latency as published).

Components tab. 7 §5:

SettingTop-1Latency
Base EdgeNeXt-S79.4332 µs
w/o SDTA encoders78.3265 µs
+ w/o adaptive kernels77.9301 µs
w/o adaptive branching79.3332 µs
+ w/o PE79.2301 µs

Hybrid placement of SDTA blocks tab. 8 §5:

Conv blocks per stageSDTA blocks per stageTop-1Latency
[3, 3, 9, 0][0, 0, 0, 3]79.3303 µs
[3, 3, 0, 0][0, 0, 9, 3]79.7393 µs
[3, 2, 8, 2] (base)[0, 1, 1, 1]79.4332 µs

Where the single SDTA block goes tab. 9 §5:

ConvSDTATop-1Latency
[3, 3, 9, 3][0, 0, 0, 0]78.3265 µs
[3, 3, 9, 2][0, 0, 0, 1]78.6290 µs
[3, 3, 8, 2][0, 0, 1, 1]79.1310 µs
[3, 2, 8, 2] (base)[0, 1, 1, 1]79.4332 µs
[2, 2, 8, 2][1, 1, 1, 1]79.2387 µs

SDTA at the start versus end of each stage tab. 10 §5: start 79.0, end 79.4, both at 332 µs.

Activation and normalization: replacing GELU with Hard-Swish and LayerNorm with BatchNorm lowers accuracy slightly and cuts latency by a large margin; the numbers exist only in a figure §5 fig. 3 and are not transcribed here. The code's comments for the BN and Hard-Swish models give 70.33, 74.87 and 78.39 top-1 for XXS, XS and S model.py; these are the code's own claims and are not in the paper.

Paper vs code

Code: mmaaz60/EdgeNeXt at commit 388450404fdd6d6e097f1cf94f5afcbbdc352f08, MIT licence (Copyright 2022 Muhammad Maaz) LICENSE. The owner is the first author. The paper's short link t.ly/_Vu9 returned HTTP 403 when we tried to open it, so we could not confirm where it points; the repo was found by GitHub search, and its README names this paper and its arXiv id. Read: models/*.py, the argument list and training loop entry in main.py, the evaluation transform in datasets.py, and the README. Not read: engine.py, sampler.py, utils.py, optim_factory.py. The repo has no detection or segmentation code.

  • XXS block counts. Table 1 gives XXS three, three, nine and three blocks per stage tab. 1. The code's XXS config uses two, two, six and two model.py. XS and S match the table [code: models/model.py#L39-L46] model.py.
  • GELU placement in the convolution encoder. Eq. 1 applies GELU after the second pointwise layer and not after the first eq. 1. The code applies GELU between the two pointwise layers and none after the second conv_encoder.py.
  • Channel split order in SDTA. Eq. 2 keeps the first subset as identity and applies the depth-wise convs to subsets 2 to s eq. 2. The code applies a conv to the first subset and passes the last subset through unchanged, accumulating the outputs in the opposite order sdta_encoder.py.
  • Subset counts. The paper gives no values for s §3 SDTA Encoder. The code uses 2, 2, 3, 4 for stages 1–4 in S, XS, XXS and B alike model.py model.py model.py model.py. Stage 1 has no SDTA block in the code, so its value does not apply.
  • Attention temperature and heads. Eq. 3 and eq. 4 have no temperature and no head split. The code has a learnable temperature per head, initialized to 1, and splits channels into heads (8 by default; 4 for XXS and XS) sdta_encoder.py. Q and K are L2-normalized sdta_encoder.py.
  • Extra normalization. The code adds layer norm before each downsampling convolution and a final layer norm before the classifier edgenext.py edgenext.py. Neither is shown in Table 1 or in the text.
  • Positional encoding type. Not stated in the paper. The code uses a 2D Fourier sine/cosine encoding layers.py, added to the XCA input in stage 2 sdta_encoder.py. This matches the stage placement in the paper.
  • Augmentation defaults. The paper lists random resized crop, flip and RandAugment (S only) §4.2. The code's defaults also turn on colour jitter at 0.4 and label smoothing at 0.1, and RandAugment with magnitude 9 main.py. Neither colour jitter nor label smoothing is mentioned in the paper.
  • EMA. The paper uses EMA with decay 0.9995 §4.2. The code disables EMA by default main.py; the README's training command enables it README.md. Evaluation without the USI flag loads the EMA weights main.py.
  • Stochastic depth. The paper uses 0.1 for S only §4.2. The code's default is 0.1 for every variant main.py, and the variant comments say 0.0 for XXS and XS model.py [code: models/model.py#L36].
  • Mixup and CutMix in the B model. Not in the paper; the code's B comment lists both as used model.py.
  • EdgeNeXt-B architecture. The paper gives only its parameter count and MAdds §4.4 tab. 4. The code's B config uses depths 3, 3, 9, 3 and widths 80, 160, 288, 584 model.py.
  • Distillation. The paper says the 81.1% S model was trained with knowledge distillation §4.3. The code README calls the same model a USI training recipe and provides weights README.md. No distillation training code was found in the repo; the teacher is not named.
  • Eval preprocessing. Matches: resize to 292 and centre crop 256 §4.2 datasets.py.
  • Batch size and optimizer. Matches: 300 epochs, lr 6e-3, weight decay 0.05, 20 warmup epochs, effective batch 4096 (256 × 2 × 8 GPUs) §4.2 main.py README.md.

Pitfalls

  • Subset counts are missing from the text. The paper's SDTA equation leaves out the case i = 2 for stages 3 and 4 (eq. 2 covers i = 2 only for t = 2). The code applies the additive rule to every subset after the first. The caption of fig. 2 mentions branches B3 and B4 but does not define B. Use the code's values, and say so.
  • Equation 3 is incomplete. It has no temperature, no head count, and no explicit L2 normalization, although the text mentions the normalization. A faithful reimplementation needs all three from the code.
  • Table 1's XXS block counts do not match the code's XXS model. The code's comment for the XXS config reports 1.33M parameters and 71.23% top-1 model.py, and that config uses two, two, six, two blocks. The table's three, three, nine, three layout would not give the same model. The depths in the code are the ones tied to the reported XXS number.
  • Naming. The abstract and §3 say "STDA"; the contribution list and most of the text say "SDTA". The card uses SDTA. Tables also contain typos ("MobileViT-XSS", "Model Prameters", "3.8MAdds").
  • Latency figures are not directly comparable. Jetson figures are TensorRT FP16 at batch 1 §4.2 §4.5. A100 figures are PyTorch at batch 256 and are given in µs without saying whether that is per image or per batch §4.2 tab. 3. The A100 measurements may be sensitive to the software version (PyTorch 1.8.1 is stated §4.2).
  • Some comparison claims are stronger than the tables. The text says EdgeNeXt has fewer MAdds and parameters than MobileFormer, ViT-C and CoaT-Lite-T §4.3. In tab. 2, EdgeNeXt-S has more MAdds than MobileFormer (965M or 1.30G against 214M) and more parameters than ViT-C (5.6M against 4.6M). The introduction says EdgeNeXt beats all lightweight models in literature on detection and segmentation with fewer MAdds §1; tab. 5 shows EdgeNeXt using more MAdds than all three MobileNets, and tab. 6 compares only MobileViT and two MobileNets.
  • Table 5 ablation rows are ambiguous. "+ w/o adaptive kernels" and "+ w/o PE" are read here as cumulative (on top of the row above) because the reported numbers are consistent with that reading. The paper does not say so.
  • Input resolution differs across comparison rows. Table 2 mixes 224 and 256 px inputs. The 224-px numbers are the ones the text uses for the ConvNet and ViT comparisons (for example 78.8 against 74.5 gives the stated 4.3% margin) §4.3.
  • Unstated training details. Not stated: cosine schedule details beyond warmup, weight-decay exemptions, drop-path schedule (the code increases it linearly over blocks edgenext.py), layer-scale value, MLP expansion ratio, and the detection and segmentation training schedules. The paper refers to MobileViT for detection and segmentation settings, and to ConvNeXt for the 21K pretraining recipe §4.2 §4.4.
  • Hard-Swish and BatchNorm variant. The paper reports only the qualitative trade-off §5 fig. 3. Its numbers are in the code's comments model.py and the README model zoo README.md.
  • Attention cost hidden in the d² term. The paper states linear complexity in the number of tokens, O(N d²) §3 Overall Architecture. The C×C attention matrix still grows with the square of the channel count, so wider stages are not free.
  • Eval uses EMA weights. A checkpoint evaluated with the default flags uses the EMA state dict main.py. Evaluating the non-EMA weights requires changing the code.

Lineage

  • Builds on: ConvNeXt (block design, training recipe) §3 Overall Architecture §4.4; Res2Net (multi-scale splitting) §3 SDTA Encoder; cross-covariance attention from XCiT (transposed attention) §3 SDTA Encoder.
  • Compared against: MobileViT (main hybrid comparison) tab. 2 tab. 3 tab. 5 tab. 6; MobileNetV1, V2 and V3; ShuffleNetV2; ViT, DeiT, T2T-ViT, MobileFormer, ViT-C, CoaT-Lite-T tab. 2.
  • Superseded by: not known from content in this wiki.

Source and license

Adapted from “EdgeNeXt: Efficiently Amalgamated CNN-Transformer Architecture for Mobile Vision Applications” by Muhammad Maaz, Abdelrahman Shaker, Hisham Cholakkal, Salman Khan, Syed Waqas Zamir, Rao Muhammad Anwer, Fahad Shahbaz Khan (arXiv:2206.10589), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/mmaaz60/EdgeNeXt at commit 388450404fdd (MIT). Any quoted code is shown under that license.