SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.06124 · ECCV · 2022

DynaST: Dynamic Sparse Transformer for Exemplar-Guided Image Generation

Xinchao Wang, Sucheng Ren, Songhua Liu, Jingwen Ye

arXiv · PDF · Open in the Atlas

Code that ran

5 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 2 failures of our instrument; 3 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/2207.06124.json · badge: /api/ran/2207.06124.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
huage001/dynast marked official in Papers with Code
Papers with Code archive
5 ran · 3 no recorded run
FunctionStatusWhere it lives
SPADE Ran
ran on a synthesized input · constructed an object; no result was computed
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("98f313b85608aafc")
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, SPADE: 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 stand-in signal tensor that will be processed by SPADE
# Signal shape: (batch=2, channels=3, height=8, width=8)
signal = torch.randn(2, 3, 8, 8)

# Create a small stand-in x tensor that will be normalized and scaled
# x shape: (batch=2, channels=4, height=8, width=8)
x = torch.randn(2, 4, 8, 8)

ARGS = {
    'dim': 4,        # hidden dimension for MLP
    'ic': 3,         # input channels of signal
    'ks': 3          # kernel 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 SPADE — 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 SPADE 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
_SynchronizedBatchNorm Ran
ran on a synthesized input · constructed an object; no result was computed
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("f8d0c394ed57e1f0")
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, _SynchronizedBatchNorm: 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)

# The _SynchronizedBatchNorm requires ReduceAddCoalesced and Broadcast to be defined
# We need to create mock implementations or stubs

class ReduceAddCoalesced:
    @staticmethod
    def apply(target_gpu, num_tensors, *tensors):
        # Mock implementation: just return the sum of pairs
        sum_result = sum(tensors[::2])
        ssum_result = sum(tensors[1::2])
        return sum_result, ssum_result

class Broadcast:
    @staticmethod
    def apply(target_gpus, mean, inv_std):
        # Mock implementation: replicate for each target GPU
        result = []
        for _ in target_gpus:
            result.extend([mean, inv_std])
        return result

class SyncMaster:
    def __init__(self, master_func):
        self.master_func = master_func
    
    def run_master(self, child_message):
        # Mock: just return dummy mean and inv_std
        mean = torch.zeros(4)
        inv_std = torch.ones(4)
        return mean, inv_std
    
    def register_slave(self, copy_id):
        return SlavePipe()

class SlavePipe:
    def run_slave(self, child_message):
        mean = torch.zeros(4)
        inv_std = torch.ones(4)
        return mean, inv_std

# Patch the globals so the class can find these
import sys
current_module = sys.modules[__name__]
setattr(current_module, 'ReduceAddCoalesced', ReduceAddCoalesced)
setattr(current_module, 'Broadcast', Broadcast)
setattr(current_module, 'SyncMaster', SyncMaster)

ARGS = {
    'num_features': 4,
    'eps': 1e-05,
    'momentum': 0.1,
    'affine': True,
    'track_running_stats': 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 _SynchronizedBatchNorm — 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 _SynchronizedBatchNorm 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
_unsqueeze_ft Ran
ran, honoured the contract we drafted
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("e185a8fcdcbab43f")
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 (1, 2, 4, 1) 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 tensor with shape (2, 4)
tensor = torch.randn(2, 4)

ARGS = {
    "tensor": tensor
}
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 (1, 2, 4, 1) — shape (1, 2, 4, 1) 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
inner_scale_dynamic_sparse_attention Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("9fe0655522228a35")
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 tuple. 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)

b = 2  # batch size
c_qk = 4  # channel dimension
H_q = 3  # query height
W_q = 3  # query width
H_k = 5  # key height
W_k = 5  # key width
top_k = 2  # top-k value
c_v = 6  # value channel dimension

# Construct q: (b, c_qk, H_q, W_q)
q = torch.randn(b, c_qk, H_q, W_q)

# Construct k: (b, c_qk, H_k, W_k)
k = torch.randn(b, c_qk, H_k, W_k)

# Construct q_prune: (b, 1, H_q, W_q) - pruning scores for query
q_prune = torch.randn(b, 1, H_q, W_q)

# Construct k_prune: (b, 1, H_k, W_k) - pruning scores for key
k_prune = torch.randn(b, 1, H_k, W_k)

# Construct v: (b, c_v, H_k, W_k)
v = torch.randn(b, c_v, H_k, W_k)

# Construct prev_attn_top_k_idx: (b, H_q * W_q, top_k)
# This contains indices into the flattened key dimension [0, H_k*W_k)
prev_attn_top_k_idx = torch.randint(0, H_k * W_k, (b, H_q * W_q, top_k))

# Optional parameters
need_idx = True
smooth = None  # Will default to c_qk ** 0.5 in the function
v2 = torch.randn(b, 7, H_k, W_k)  # Different channel size from v

ARGS = {
    'q': q,
    'k': k,
    'q_prune': q_prune,
    'k_prune': k_prune,
    'v': v,
    'prev_attn_top_k_idx': prev_attn_top_k_idx,
    'need_idx': need_idx,
    'smooth': smooth,
    'v2': v2,
}
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 tuple — a tuple output has no array shape of its own; none is 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
inter_scale_dynamic_sparse_attention Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("a5fffce03d7edcd3")
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 tuple. 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.functional as F

torch.manual_seed(0)

# Small tensor dimensions: batch=2, channels=4, spatial dims that work with unfold(kernel_size=2, stride=2)
# Need H_q, W_q divisible by 2, and H_k, W_k divisible by 2
b = 2
c_qk = 4
H_q = 4
W_q = 4
H_k = 4
W_k = 4
top_k = 3
v_channels = 5

# q: (b, c_qk, H_q, W_q)
q = torch.randn(b, c_qk, H_q, W_q)

# k: (b, c_qk, H_k, W_k)
k = torch.randn(b, c_qk, H_k, W_k)

# q_prune: (b, ?, H_q, W_q) - used with unfold, needs to match q spatial dims
# The code does F.unfold(q_prune, ...) so it needs shape (b, channels, H_q, W_q)
q_prune = torch.randn(b, 1, H_q, W_q)

# k_prune: (b, ?, H_k, W_k) - used with unfold
k_prune = torch.randn(b, 1, H_k, W_k)

# v: (b, v_channels, H_k, W_k) - used with unfold, different channel dim for distinction
v = torch.randn(b, v_channels, H_k, W_k)

# prev_attn_top_k_idx: (b, H_q//2 * W_q//2, top_k) - indices into k spatial dimension
# Values should be in range [0, H_k//2 * W_k//2)
prev_attn_top_k_idx = torch.randint(0, (H_k // 2) * (W_k // 2), (b, (H_q // 2) * (W_q // 2), top_k))

# need_idx: boolean
need_idx = True

# smooth: optional, can be None (will use c_qk ** 0.5)
smooth = None

# v2: optional second value tensor, can be None or a tensor like v
v2 = torch.randn(b, v_channels, H_k, W_k)

ARGS = {
    'q': q,
    'k': k,
    'q_prune': q_prune,
    'k_prune': k_prune,
    'v': v,
    'prev_attn_top_k_idx': prev_attn_top_k_idx,
    'need_idx': need_idx,
    'smooth': smooth,
    'v2': v2,
}
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 tuple — a tuple output has no array shape of its own; none is 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
DynamicSparseTransformerBlock Not yet run
unverified (harvested, no recorded run)
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("7976cd9b3bbe5998")
How it ran

no invocation recorded.

ResidualBlock Not yet run
unverified (harvested, no recorded run)
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("67f416d92289a7b5")
How it ran

no invocation recorded.

SynchronizedBatchNorm2d Not yet run
unverified (harvested, no recorded run)
huage001/dynast/models/networks/dynast_transformer.py
code served (permissive licence) · get_code("b5692d4688d3d881")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 1 later) and 6 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
_unsqueeze_ft
brick of this paper's assembly: helper
15 other papers
12 dated earlier, 3 later · 14 only as an assembly brick
1802.02611 (2018-02)
Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation
2012.04781 (2020-12)
You Only Need Adversarial Supervision for Semantic Image Synthesis
2101.10979 (2021-01)
Prototypical Pseudo Label Denoising and Target Structure Learning for Domain Adaptive Semantic Segmentation
and 12 more not named here
SynchronizedBatchNorm2d
brick of this paper's assembly: helper
2 other papers
2 dated earlier · 1 only as an assembly brick
2012.04781 (2020-12)
You Only Need Adversarial Supervision for Semantic Image Synthesis
2203.16898 (2022-03)
Semantic-shape Adaptive Feature Modulation for Semantic Image Synthesis

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

One key challenge of exemplar-guided image generation lies in establishing fine-grained correspondences between input and guided images. Prior approaches, despite the promising results, have relied on either estimating dense attention to compute per-point matching, which is limited to only coarse scales due to the quadratic memory cost, or fixing the number of correspondences to achieve linear complexity, which lacks flexibility. In this paper, we propose a dynamic sparse attention based Transformer model, termed Dynamic S parse T ransformer (Dy-naST ), to achieve fine-level matching with favorable efficiency. The heart of our approach is a novel dynamic-attention unit, dedicated to covering the variation on the optimal number of tokens one position should focus on. Specifically, DynaST leverages the multi-layer nature of Transformer structure, and performs the dynamic attention scheme in a cascaded manner to refine matching results and synthesize visually-pleasing outputs. In addition, we introduce a unified training objective for Dy-naST, making it a versatile reference-based image translation framework for both supervised and unsupervised scenarios. Extensive experiments on three applications, pose-guided person image generation, edge-based face synthesis, and undistorted image style transfer, demonstrate that DynaST achieves superior performance in local details, outperforming the state of the art while reducing the computational cost significantly. Our code is available here.

For agents

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

get_harvested_code_for_paper("2207.06124")
get_code_for_paper("2207.06124")
have("2207.06124")

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

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

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

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

Connect an agent — have() is free.