SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.00652 · 2021

CSWin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows

arXiv · PDF · Open in the Atlas

Code that ran

4 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 2 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/2107.00652.json · badge: /api/ran/2107.00652.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
microsoft/CSWin-Transformer canonical (classifier label)
classifier basis: census
2 ran · 2 no recorded run
lyqcom/cswin-transformer reimplementation (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
create_optimizer Ran
ran on a synthesized input
microsoft/CSWin-Transformer/finetune.py
code served (permissive licence) · get_code("3b22aba5effad739")
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 AdamW. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 minimal model with parameters to optimize
model = nn.Linear(4, 3)
parameters = model.parameters()

# Create args object with all required attributes
class Args:
    def __init__(self):
        self.opt = 'adamw'
        self.lr = 0.001
        self.weight_decay = 0.0001
        self.opt_eps = 1e-8
        self.opt_betas = (0.9, 0.999)
        self.opt_args = None
        self.momentum = 0.9

args = Args()

ARGS = {
    'args': args,
    'parameters': parameters,
    'filter_bias_and_bn': 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 AdamW — a AdamW output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a AdamW 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
img2windows Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
lyqcom/cswin-transformer/models/cswin.py
code served (permissive licence) · get_code("39b18f062e0cc6d9")
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) and returned Tensor, ndim 3, dtype family float, shape (16, 6, 4) 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

torch.manual_seed(0)

# Create a small image tensor: B=2, C=4, H=8, W=6
img = torch.randn(2, 4, 8, 6)

# Window dimensions that divide evenly into H and W
H_sp = 2  # H // H_sp = 8 // 2 = 4
W_sp = 3  # W // W_sp = 6 // 3 = 2

ARGS = {
    "img": img,
    "H_sp": H_sp,
    "W_sp": W_sp,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, shape (16, 6, 4) — shape (16, 6, 4) 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
load_img Ran
ran, honoured the contract we drafted
microsoft/CSWin-Transformer/labeled_memcached_dataset.py
code served (permissive licence) · get_code("4d0c2350b24a4430")
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 Image. 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 tempfile
from PIL import Image
import os

# Create a temporary RGB image file
temp_dir = tempfile.mkdtemp()
temp_filepath = os.path.join(temp_dir, "test_image.png")

# Create a small test image
test_img = Image.new('RGB', (10, 10), color=(255, 0, 0))
test_img.save(temp_filepath)

ARGS = {
    'filepath': temp_filepath
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int 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
windows2img Ran
ran; our contract draft was wrong, not the code
lyqcom/cswin-transformer/models/cswin.py
code served (permissive licence) · get_code("ab01fbfe58c75b08")
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) and returned Tensor, ndim 4, dtype family float, shape (2, 8, 6, 12) 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)

# Understand the function:
# - img_splits_hw: shape (B', H, W, C) where B' = B * (H/H_sp) * (W/W_sp)
# - H_sp, W_sp: spatial dimensions of each window/split
# - H, W: original image height and width
# - C: number of channels (inferred from last dim)

# Let's construct valid arguments:
# Choose concrete values:
B = 2  # batch size
H_sp = 4  # height of each split
W_sp = 3  # width of each split
H = 8  # original image height
W = 6  # original image width
C = 3  # channels

# B' = B * (H/H_sp) * (W/W_sp) = 2 * (8/4) * (6/3) = 2 * 2 * 2 = 8
B_prime = B * (H // H_sp) * (W // W_sp)

# img_splits_hw should have shape (B', H, W, C) = (8, 8, 6, 3)
img_splits_hw = torch.randn(B_prime, H, W, C)

ARGS = {
    "img_splits_hw": img_splits_hw,
    "H_sp": H_sp,
    "W_sp": W_sp,
    "H": H,
    "W": W,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, 6, 12) — shape (2, 8, 6, 12) 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
train_epoch Not yet run
unverified (harvested, no recorded run)
microsoft/CSWin-Transformer/finetune.py
code served (permissive licence) · get_code("e3b8df6691b9c559")
How it ran

no invocation recorded.

validate Not yet run
unverified (harvested, no recorded run)
microsoft/CSWin-Transformer/finetune.py
code served (permissive licence) · get_code("e2a98c6a53ded11f")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 4 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 4 later) and 2 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
img2windows 14 other papers
14 later · 1 only as an assembly brick
2208.08630 (2022-08)
Unifying Visual Perception by Dispersible Points Learning
2211.13654 (2022-11)
Cross Aggregation Transformer for Image Restoration
2303.06373 (2023-03)
Recursive Generalization Transformer for Image Super-Resolution
and 11 more not named here
windows2img 14 other papers
14 later · 1 only as an assembly brick
2208.08630 (2022-08)
Unifying Visual Perception by Dispersible Points Learning
2211.13654 (2022-11)
Cross Aggregation Transformer for Image Restoration
2303.06373 (2023-03)
Recursive Generalization Transformer for Image Super-Resolution
and 11 more not named here
validate 9 other papers
1 dated earlier, 8 later
2103.15632 (2021-03)
Regular Polytope Networks
2204.05173 (2022-04)
Machine Learning State-of-the-Art with Uncertainties
2205.12956 (2022-05)
Inception Transformer
and 6 more not named here
load_img 3 other papers
2 dated earlier, 1 later
1803.02735 (2018-03)
Deep Back-Projection Networks For Super-Resolution
1909.07425 (2019-09)
A Characteristic Function Approach to Deep Implicit Generative Modeling
2309.04089 (2023-09)
Toward Sufficient Spatial-Frequency Interaction for Gradient-aware Underwater Image Enhancement

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

We present CSWin Transformer, an efficient and effective Transformer-based backbone for general-purpose vision tasks. A challenging issue in Transformer design is that global self-attention is very expensive to compute whereas local self-attention often limits the field of interactions of each token. To address this issue, we develop the Cross-Shaped Window self-attention mechanism for computing self-attention in the horizontal and vertical stripes in parallel that form a cross-shaped window, with each stripe obtained by splitting the input feature into stripes of equal width. We provide a mathematical analysis of the effect of the stripe width and vary the stripe width for different layers of the Transformer network which achieves strong modeling capability while limiting the computation cost. We also introduce Locally-enhanced Positional Encoding (LePE), which handles the local positional information better than existing encoding schemes. LePE naturally supports arbitrary input resolutions, and is thus especially effective and friendly for downstream tasks. Incorporated with these designs and a hierarchical structure, CSWin Transformer demonstrates competitive performance on common vision tasks. Specifically, it achieves 85.4\% Top-1 accuracy on ImageNet-1K without any extra training data or label, 53.9 box AP and 46.4 mask AP on the COCO detection task, and 52.2 mIOU on the ADE20K semantic segmentation task, surpassing previous state-of-the-art Swin Transformer backbone by +1.2, +2.0, +1.4, and +2.0 respectively under the similar FLOPs setting. By further pretraining on the larger dataset ImageNet-21K, we achieve 87.5% Top-1 accuracy on ImageNet-1K and high segmentation performance on ADE20K with 55.7 mIoU. The code and models are available at https://github.com/microsoft/CSWin-Transformer.

For agents

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

get_harvested_code_for_paper("2107.00652")
get_code_for_paper("2107.00652")
have("2107.00652")

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

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

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

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

Connect an agent — have() is free.