{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/swiftformer-efficient-additive-attention-for","title":"SwiftFormer: Efficient Additive Attention for Transformer-based Real-time Mobile Vision Applications","arxiv_id":"2303.15446","date":"2023-03-27","proceeding":"ICCV 2023 1","authors":["Abdelrahman Shaker","Muhammad Maaz","Hanoona Rasheed","Salman Khan","Ming-Hsuan Yang","Fahad Shahbaz Khan"],"abstract":"Self-attention has become a defacto choice for capturing global context in various vision applications. However, its quadratic computational complexity with respect to image resolution limits its use in real-time applications, especially for deployment on resource-constrained mobile devices. Although hybrid approaches have been proposed to combine the advantages of convolutions and self-attention for a better speed-accuracy trade-off, the expensive matrix multiplication operations in self-attention remain a bottleneck. In this work, we introduce a novel efficient additive attention mechanism that effectively replaces the quadratic matrix multiplication operations with linear element-wise multiplications. Our design shows that the key-value interaction can be replaced with a linear layer without sacrificing any accuracy. Unlike previous state-of-the-art methods, our efficient formulation of self-attention enables its usage at all stages of the network. Using our proposed efficient additive attention, we build a series of models called \"SwiftFormer\" which achieves state-of-the-art performance in terms of both accuracy and mobile inference speed. Our small variant achieves 78.5% top-1 ImageNet-1K accuracy with only 0.8 ms latency on iPhone 14, which is more accurate and 2x faster compared to MobileViT-v2. Code: https://github.com/Amshaker/SwiftFormer","url_abs":"https://arxiv.org/abs/2303.15446v2","url_pdf":"https://arxiv.org/pdf/2303.15446v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"swiftformer-efficient-additive-attention-for","repo_url":"https://github.com/amshaker/swiftformer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"swiftformer-efficient-additive-attention-for","repo_url":"https://github.com/mmaaz60/EdgeNeXt","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"swiftformer-efficient-additive-attention-for","repo_url":"https://github.com/MindCode-4/code-5/tree/main/swiftformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"swiftformer-efficient-additive-attention-for","repo_url":"https://github.com/pwc-1/Paper-10/tree/main/swiftformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"swiftformer-efficient-additive-attention-for","repo_url":"https://github.com/yangyucheng000/University/tree/main/model-3/swiftformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"swiftformer-efficient-additive-attention-for","repo_url":"https://gitlab.com/birder/birder","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[],"methods":[{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"tanh-activation","method_name":"Tanh Activation"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2303.15446","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2303.15446"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/pwc-1/Paper-10/tree/main/swiftformer","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://gitlab.com/birder/birder","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/amshaker/swiftformer","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindCode-4/code-5/tree/main/swiftformer","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mmaaz60/EdgeNeXt","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/yangyucheng000/University/tree/main/model-3/swiftformer","reach":null}],"summary":{"ran":4,"unverified":1},"by_repo_kind":{"official":{"samples":4,"ran":3,"repositories":1},"listed":{"samples":1,"ran":1,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"89118f335469da66","entry":"EfficientAdditiveAttnetion","repo":"amshaker/swiftformer","repo_kind":"official","path":"models/swiftformer.py","file_url":"https://github.com/amshaker/swiftformer/blob/HEAD/models/swiftformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"89118f335469da66"}},{"code_sha256_prefix":"2dc33d1c31b0ba12","entry":"Mlp","repo":"amshaker/swiftformer","repo_kind":"official","path":"models/swiftformer.py","file_url":"https://github.com/amshaker/swiftformer/blob/HEAD/models/swiftformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2dc33d1c31b0ba12"}},{"code_sha256_prefix":"931f6c94679945e2","entry":"SDTAEncoder","repo":"mmaaz60/EdgeNeXt","repo_kind":"listed","path":"models/sdta_encoder.py","file_url":"https://github.com/mmaaz60/EdgeNeXt/blob/HEAD/models/sdta_encoder.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"931f6c94679945e2"}},{"code_sha256_prefix":"be926696e202a1ce","entry":"SwiftFormerLocalRepresentation","repo":"amshaker/swiftformer","repo_kind":"official","path":"models/swiftformer.py","file_url":"https://github.com/amshaker/swiftformer/blob/HEAD/models/swiftformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"be926696e202a1ce"}},{"code_sha256_prefix":"02ce32529d3451dd","entry":"SwiftFormerEncoder","repo":"amshaker/swiftformer","repo_kind":"official","path":"models/swiftformer.py","file_url":"https://github.com/amshaker/swiftformer/blob/HEAD/models/swiftformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"02ce32529d3451dd"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}