Saved in:
Bibliographic Details
Main Author: Zhang, Zhendong
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2501.06480
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913647503081472
author Zhang, Zhendong
author_facet Zhang, Zhendong
contents To address the high resolution of image pixels, the Swin Transformer introduces window attention. This mechanism divides an image into non-overlapping windows and restricts attention computation to within each window, significantly enhancing computational efficiency. To further optimize this process, one might consider replacing standard attention with flash attention, which has proven to be more efficient in language models. However, a direct substitution is ineffective. Flash attention is designed for long sequences, whereas window attention deals with shorter sequences but must handle numerous of them in parallel. In this report, we present an optimized solution called Flash Window Attention, tailored specifically for window attention. Flash Window Attention improves attention computation efficiency by up to 300% and enhances end-to-end runtime efficiency by up to 30%. Our code is available online.
format Preprint
id arxiv_https___arxiv_org_abs_2501_06480
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Flash Window Attention: speedup the attention computation for Swin Transformer
Zhang, Zhendong
Computer Vision and Pattern Recognition
To address the high resolution of image pixels, the Swin Transformer introduces window attention. This mechanism divides an image into non-overlapping windows and restricts attention computation to within each window, significantly enhancing computational efficiency. To further optimize this process, one might consider replacing standard attention with flash attention, which has proven to be more efficient in language models. However, a direct substitution is ineffective. Flash attention is designed for long sequences, whereas window attention deals with shorter sequences but must handle numerous of them in parallel. In this report, we present an optimized solution called Flash Window Attention, tailored specifically for window attention. Flash Window Attention improves attention computation efficiency by up to 300% and enhances end-to-end runtime efficiency by up to 30%. Our code is available online.
title Flash Window Attention: speedup the attention computation for Swin Transformer
topic Computer Vision and Pattern Recognition
url https://arxiv.org/abs/2501.06480