SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2204.03645 · ECCV · 2022

DaViT: Dual Attention Vision Transformers

Ping Luo, Hong Kong, Lu Yuan, Mingyu Ding, Jingdong Wang, Noel Codella

arXiv · PDF · Open in the Atlas

Code that ran

8 of 15 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 2 failures of our instrument; 7 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2204.03645.json · badge: /api/ran/2204.03645.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
dingmyu/davit marked official in Papers with Code
Papers with Code archive
8 ran · 7 no recorded run
FunctionStatusWhere it lives
ChannelAttention Ran
ran on a synthesized input · constructed an object; no result was computed
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("ae32983bf5de53c3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, ChannelAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a small input tensor with shape (B, N, C)
# B=2 (batch), N=3 (sequence length), C=4 (channels)
x = torch.randn(2, 3, 4)

ARGS = {
    'dim': 4,
    'num_heads': 2,
    'qkv_bias': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ChannelAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ChannelAttention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ChannelBlock Ran
ran on a synthesized input · constructed an object; no result was computed
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("98189454f1018bed")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, ChannelBlock: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'dim': 4,
    'num_heads': 2,
    'mlp_ratio': 4.0,
    'qkv_bias': False,
    'drop_path': 0.1,
    'act_layer': nn.GELU,
    'norm_layer': nn.LayerNorm,
    'ffn': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ChannelBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ChannelBlock output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ConvPosEnc Ran
ran on a synthesized input
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("c6ff164380e31b6a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from typing import Tuple
from itertools import repeat
import collections.abc

def _ntuple(n):
    def parse(x):
        if isinstance(x, collections.abc.Iterable):
            return x
        return tuple(repeat(x, n))
    return parse

to_2tuple = _ntuple(2)

class ConvPosEnc(nn.Module):
    """Depth-wise convolution to get the positional information.
    """

    def __init__(self, dim, k=3):
        super(ConvPosEnc, self).__init__()
        self.proj = nn.Conv2d(dim, dim, to_2tuple(k), to_2tuple(1), to_2tuple(k // 2), groups=dim)

    def forward(self, x, size: Tuple[int, int]):
        B, N, C = x.shape
        H, W = size
        assert N == H * W
        feat = x.transpose(1, 2).view(B, C, H, W)
        feat = self.proj(feat)
        feat = feat.flatten(2).transpose(1, 2)
        x = x + feat
        return x


INIT_ARGS = {
    'dim': 4,
    'k': 3,
}

ARGS = {
    'x': torch.randn(2, 12, 4),
    'size': (3, 4),
}

if __name__ == '__main__':
    model = ConvPosEnc(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Mlp Ran
ran on a synthesized input · constructed an object; no result was computed
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("c1395a46164d140a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Mlp: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Analyze the Mlp.__init__ signature:
# - in_features: int, required
# - hidden_features: int or None, optional
# - out_features: int or None, optional
# - act_layer: class/callable, defaults to nn.GELU

# The forward method expects:
# - x: tensor to pass through fc1 (Linear layer)
# Linear layers are called with tensors of shape (..., in_features)

# Build a small test input tensor
# Shape: (batch=2, in_features=4)
test_input = torch.randn(2, 4)

ARGS = {
    'in_features': 4,
    'hidden_features': 8,
    'out_features': 3,
    'act_layer': nn.GELU
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Mlp — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Mlp output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
PatchEmbed Ran
ran on a synthesized input · constructed an object; no result was computed
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("dc8f008b6667e65a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, PatchEmbed: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "patch_size": 4,
    "in_chans": 3,
    "embed_dim": 96,
    "overlapped": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PatchEmbed — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PatchEmbed output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
WindowAttention Ran
ran on a synthesized input · constructed an object; no result was computed
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("5091ab6c514932c4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, WindowAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "dim": 4,
    "window_size": (2, 2),
    "num_heads": 2,
    "qkv_bias": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type WindowAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a WindowAttention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
window_partition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("80c66c535be6f491")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (12, 2, 2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a small tensor with shape (B, H, W, C)
# B=2 (batch), H=4 (height), W=6 (width), C=3 (channels)
# Choose window_size=2 so that H and W are divisible by it
x = torch.randn(2, 4, 6, 3)

# Define window_size parameter
window_size = 2

ARGS = {
    'x': x,
    'window_size': window_size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (12, 2, 2, 3) — shape (12, 2, 2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
window_reverse Ran
ran; our contract draft was wrong, not the code
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("b83f31fb8b7c976a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 8, 8, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Parameters for window_reverse function
# windows: (num_windows*B, window_size, window_size, C)
# window_size: int
# H: int (Height of image)
# W: int (Width of image)

window_size = 4
H = 8
W = 8
C = 3  # number of channels
B = 2  # batch size

# Calculate num_windows = (H // window_size) * (W // window_size)
num_windows = (H // window_size) * (W // window_size)
num_windows_B = num_windows * B

# Create windows tensor with shape (num_windows*B, window_size, window_size, C)
windows = torch.randn(num_windows_B, window_size, window_size, C)

ARGS = {
    "windows": windows,
    "window_size": window_size,
    "H": H,
    "W": W,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 8, 8, 3) — shape (2, 8, 8, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
DaViT Not yet run
unverified (harvested, no recorded run)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("ceb98806b990f4e0")
How it ran

no invocation recorded.

MySequential Not yet run
unverified (harvested, no recorded run)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("5066418c2fb3b6c8")
How it ran

no invocation recorded.

SpatialBlock Not yet run
unverified (harvested, no recorded run)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("dad192f68c8848d9")
How it ran

no invocation recorded.

_init_conv_weights Not yet run
unverified (harvested, no recorded run)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("266d4f400940d7a0")
How it ran

no invocation recorded.

_init_vit_weights Not yet run
unverified (harvested, no recorded run)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("62d0b713fcda8506")
How it ran

no invocation recorded.

lecun_normal_ Not yet run
unverified (harvested, no recorded run)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("ef7b648f5c9e3de2")
How it ran

no invocation recorded.

variance_scaling_ Not yet run
unverified (harvested, no recorded run)
dingmyu/davit/timm/models/davit.py
code served (permissive licence) · get_code("2f6bf4b4b7d2ba1c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 5 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 3 the same month, 4 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
window_partition
brick of this paper's assembly: helper
31 other papers
2 dated earlier, 29 later
2111.11418 (2021-11)
MetaFormer Is Actually What You Need for Vision
2203.12119 (2022-03)
Visual Prompt Tuning
2210.04135 (2022-10)
VoLTA: Vision-Language Transformer with Weakly-Supervised Local-Feature Alignment
and 28 more not named here
window_reverse
brick of this paper's assembly: helper
14 other papers
1 dated earlier, 13 later
1706.03762 (2017-06)
Attention Is All You Need
2210.04135 (2022-10)
VoLTA: Vision-Language Transformer with Weakly-Supervised Local-Feature Alignment
Li_I-ViT_Integer-only_Quantization_for_Efficient_Vision_Transformer_Inference_ICCV_2023_paper (2023 (year only))
I-ViT: Integer-only Quantization for Efficient Vision Transformer Inference
and 11 more not named here
lecun_normal_
brick of this paper's assembly: helper
4 other papers
2 dated earlier, 1 the same month, 1 later
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2201.04850 (2022-01)
Bridging Video-text Retrieval with Multiple Choice Questions
2204.07683 (2022-04)
Safe Self-Refinement for Transformer-based Domain Adaptation
and 1 more not named here
_init_vit_weights
brick of this paper's assembly: helper
3 other papers
1 the same month, 2 later · 1 only as an assembly brick
2204.07683 (2022-04)
Safe Self-Refinement for Transformer-based Domain Adaptation
2307.15324 (2023-07)
TaskExpert: Dynamically Assembling Multi-Task Representations with Memorial Mixture-of-Experts
2403.17749 (2024-03)
Multi-Task Dense Prediction via Mixture of Low-Rank Experts
variance_scaling_
brick of this paper's assembly: helper
3 other papers
2 dated earlier, 1 the same month
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2201.04850 (2022-01)
Bridging Video-text Retrieval with Multiple Choice Questions
2204.07683 (2022-04)
Safe Self-Refinement for Transformer-based Domain Adaptation

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In this work, we introduce Dual Attention Vision Transformers (DaViT), a simple yet effective vision transformer architecture that is able to capture global context while maintaining computational efficiency. We propose approaching the problem from an orthogonal angle: exploiting self-attention mechanisms with both "spatial tokens" and "channel tokens". With spatial tokens, the spatial dimension defines the token scope, and the channel dimension defines the token feature dimension. With channel tokens, we have the inverse: the channel dimension defines the token scope, and the spatial dimension defines the token feature dimension. We further group tokens along the sequence direction for both spatial and channel tokens to maintain the linear complexity of the entire model. We show that these two self-attentions complement each other: (i) since each channel token contains an abstract representation of the entire image, the channel attention naturally captures global interactions and representations by taking all spatial positions into account when computing attention scores between channels; (ii) the spatial attention refines the local representations by performing fine-grained interactions across spatial locations, which in turn helps the global information modeling in channel attention. Extensive experiments show DaViT backbones achieve state-of-the-art performance on four different tasks. Specially, DaViT-Tiny, DaViT-Small, and DaViT-Base achieve 82.8%, 84.2%, and 84.6% top-1 accuracy on ImageNet-1K without extra training data, using 28.3M, 49.7M, and 87.9M parameters, respectively. When we further scale up DaViT with 1.5B weakly supervised image and text pairs, DaViT-Giant reaches 90.4% top-1 accuracy on ImageNet-1K.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2204.03645")
get_code_for_paper("2204.03645")
have("2204.03645")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2204.03645.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2204.03645.svg)](https://syntology.ai/paper/2204.03645)

Connect an agent — have() is free.