All models

shvit_s2

A memory-efficient vision transformer with a 16x16 stem, three stages and single-head partial-channel attention.

Image classification · 391 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (31 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
shvit
Parameters
11.5M
Operations
391
Framework
PyTorch
Recurrent
No
Published
CVPR (arXiv 2024)
Cited by
181 (as of 9 October 2026)
Authors
Seokju Yun, Youngmin Ro
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m9185
Graph hash
63369c832fe61b1980917549498dcc68d9bc073fa2d3f5b9442015ecab958330
Skeleton hash
7d5a3c4f400734342b09cbbc5241941354b97f6e2fd39446c4abf35c1d7b9766
Architecture hash
7b86c8a7683f59761eba6b776462b0169959d9d41a62a919edb14efa48e458bb
Diagram SHA-256
b1d81829077bfa6bfbeb2e59a1c438367397814304183d269407474a90ffff9b
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

timm.create_model('shvit_s2', pretrained=False)

What it is

About this model's family

SHViT, the Single-Head Vision Transformer, is an efficient vision transformer built around removing computational redundancy at all design levels in a memory-efficient manner. Where conventional efficient ViTs use 4 by 4 patch embeddings and a 4-stage structure, SHViT adopts a 16 by 16 patchify stem and a 3-stage design. The authors find that a larger-stride patchify stem reduces memory access costs and stays competitive by leveraging token representations with reduced spatial redundancy from the early stages.

At the micro level, Single-Head Self-Attention applies an attention layer with a single head on only a part of the input channels and leaves the remaining channels untouched. The partial ratio r defaults to 1/4.67. This removes the redundancy of the multi-head mechanism and reduces memory access cost by processing partial channels. A SHViT block has three parts: a depthwise convolution for local feature aggregation, the SHSA layer for modeling global contexts, and a feed-forward network. The first stage uses no SHSA layer at all, following the finding that early-stage attention can be substituted with convolutions.

Layer Normalization is used only for the SHSA layer, with Batch Normalization elsewhere so it can be merged into adjacent convolution or linear layers. Four variants, S1 to S4, differ in depth and width, and all four are captured here. SHViT-S4 reaches 79.4% top-1 on ImageNet at 14283 images per second on an Nvidia A100 GPU and 509 images per second on an Intel Xeon Gold 5218R CPU.

Key idea. SHViT-S4 is 3.3x, 8.1x and 2.4x faster than MobileViTv2 x1.0 on GPU, CPU and iPhone 12 while being 1.3% more accurate, by using single-head attention on partial channels and a 16 by 16 stem with three stages.

  • shvit
  • single-head vision transformer
  • single head attention
  • shsa
  • shvit_s1
  • shvit_s2
  • shvit_s3
  • shvit_s4
  • efficient vit
  • mobile vit
  • image classification

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{yun2024shvitsingleheadvisiontransformer,
      title={SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design}, 
      author={Seokju Yun and Youngmin Ro},
      year={2024},
      eprint={2401.16456},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2401.16456}, 
}