| FusionLayer |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("25a94899a6383a68") How it ranRan 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
# INIT_ARGS for FusionLayer.__init__(embed_dim, fusion_dim)
INIT_ARGS = {
'embed_dim': 8,
'fusion_dim': 12
}
# ARGS for FusionLayer.forward(states)
# states: list of tensors, each of shape (B, NUM_POINTS, EMBED_DIM)
# The forward method concatenates states along dim=2, so if we have 2 states,
# the concatenated tensor will have shape (B, NUM_POINTS, EMBED_DIM * 2)
# Then it concatenates with global_feat, doubling the last dim again to EMBED_DIM * 4
# The fusion_linear expects input of size embed_dim * 2 (from the doubled concatenation)
# Looking at the forward method:
# 1. state = torch.cat(states, dim=2) -> (B, NUM_POINTS, sum of all EMBED_DIMs)
# 2. global_feat has same shape as state
# 3. fused = torch.cat([state, global_feat], dim=2) -> (B, NUM_POINTS, 2 * sum of EMBED_DIMs)
# 4. fusion_linear expects input of embed_dim * 2
# So: sum of all EMBED_DIMs in states = embed_dim
# If we have 2 states each with EMBED_DIM = 4, sum = 8 = embed_dim ✓
ARGS = {
'states': [
torch.randn(2, 5, 4), # (B=2, NUM_POINTS=5, EMBED_DIM=4)
torch.randn(2, 5, 4) # (B=2, NUM_POINTS=5, EMBED_DIM=4)
]
}
- 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)
|
| PatchEmbed |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("327417879fa4f7c7") How it ranRan 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 4, dtype family float, shape (2, 8, 4, 6) 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
import torch.nn.functional as F
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
class PatchEmbed(nn.Module):
"""Image to Patch Embedding
Args:
patch_size (int): Patch token size. Default: 4.
in_chans (int): Number of input image channels. Default: 3.
embed_dim (int): Number of linear projection output channels. Default: 96.
norm_layer (nn.Module, optional): Normalization layer. Default: None
"""
def __init__(self, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None):
super().__init__()
patch_size = to_2tuple(patch_size)
self.patch_size = patch_size
self.in_chans = in_chans
self.embed_dim = embed_dim
self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)
if norm_layer is not None:
self.norm = norm_layer(embed_dim)
else:
self.norm = None
def forward(self, x):
"""Forward function."""
_, _, H, W = x.size()
if W % self.patch_size[1] != 0:
x = F.pad(x, (0, self.patch_size[1] - W % self.patch_size[1]))
if H % self.patch_size[0] != 0:
x = F.pad(x, (0, 0, 0, self.patch_size[0] - H % self.patch_size[0]))
x = self.proj(x)
if self.norm is not None:
Wh, Ww = (x.size(2), x.size(3))
x = x.flatten(2).transpose(1, 2)
x = self.norm(x)
x = x.transpose(1, 2).view(-1, self.embed_dim, Wh, Ww)
return x
INIT_ARGS = {
'patch_size': 2,
'in_chans': 3,
'embed_dim': 8,
'norm_layer': nn.LayerNorm
}
ARGS = {
'x': torch.randn(2, 3, 8, 12)
}
if __name__ == '__main__':
model = PatchEmbed(**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
- timm, 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, 4, 6) — shape (2, 8, 4, 6) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| PatchMerging |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("d0a21c32ae0a99e5") How it ranRan 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, shape (2, 4, 8) 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
import torch.nn.functional as F
class PatchMerging(nn.Module):
"""Patch Merging Layer
Args:
dim (int): Number of input channels.
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
"""
def __init__(self, dim, norm_layer=nn.LayerNorm):
super().__init__()
self.dim = dim
self.reduction = nn.Linear(4 * dim, 2 * dim, bias=False)
self.norm = norm_layer(4 * dim)
def forward(self, x, H, W):
"""Forward function.
Args:
x: Input feature, tensor size (B, H*W, C).
H, W: Spatial resolution of the input feature.
"""
B, L, C = x.shape
assert L == H * W, 'input feature has wrong size'
x = x.view(B, H, W, C)
pad_input = H % 2 == 1 or W % 2 == 1
if pad_input:
x = F.pad(x, (0, 0, 0, W % 2, 0, H % 2))
x0 = x[:, 0::2, 0::2, :]
x1 = x[:, 1::2, 0::2, :]
x2 = x[:, 0::2, 1::2, :]
x3 = x[:, 1::2, 1::2, :]
x = torch.cat([x0, x1, x2, x3], -1)
x = x.view(B, -1, 4 * C)
x = self.norm(x)
x = self.reduction(x)
return x
INIT_ARGS = {
'dim': 4,
'norm_layer': nn.LayerNorm
}
ARGS = {
'x': torch.randn(2, 12, 4),
'H': 3,
'W': 4
}
if __name__ == '__main__':
module = PatchMerging(**INIT_ARGS)
output = module(**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, shape (2, 4, 8) — shape (2, 4, 8) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| PositionalEncoding |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("68af15dd6ddc70a4") How it ranRan 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, shape (2, 8, 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
import torch.nn as nn
import math
class PositionalEncoding(nn.Module):
def __init__(self, embed_dim, max_len=1024):
super(PositionalEncoding, self).__init__()
pe = torch.zeros(max_len, embed_dim)
position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
div_term = torch.exp(torch.arange(0, embed_dim, 2).float() * (-math.log(10000.0) / embed_dim))
pe[:, 0::2] = torch.sin(position * div_term)
pe[:, 1::2] = torch.cos(position * div_term)
pe = pe.unsqueeze(0)
self.register_buffer('pe', pe)
def forward(self, x):
"""
x: (B, NUM_POINTS, EMBED_DIM)
"""
x = x + self.pe[:, :x.size(1), :]
return x
INIT_ARGS = {
'embed_dim': 4,
'max_len': 16
}
ARGS = {
'x': torch.randn(2, 8, 4)
}
if __name__ == '__main__':
model = PositionalEncoding(**INIT_ARGS)
output = model(**ARGS)
print(f"Input shape: {ARGS['x'].shape}")
print(f"Output shape: {output.shape}")
print(f"Output:\n{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, shape (2, 8, 4) — shape (2, 8, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| PredictionLayer |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("6ee9dfdfb8071f75") How it ranRan 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, shape (2, 3, 2) 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
class PredictionLayer(nn.Module):
def __init__(self, input_dim, hidden_dim=256, output_dim=2):
super(PredictionLayer, self).__init__()
self.prediction = nn.Sequential(nn.Linear(input_dim, hidden_dim), nn.ReLU(inplace=True), nn.Linear(hidden_dim, 64), nn.ReLU(inplace=True), nn.Linear(64, output_dim))
def forward(self, x):
"""
x: (B, NUM_POINTS, input_dim)
"""
x = self.prediction(x)
return x
INIT_ARGS = {
'input_dim': 4,
'hidden_dim': 128,
'output_dim': 2
}
ARGS = {
'x': torch.randn(2, 3, 4)
}
if __name__ == '__main__':
model = PredictionLayer(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 3, 2)")
assert output.shape == (2, 3, 2), f"Shape mismatch: got {output.shape}"
print("Test passed!")
- 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, shape (2, 3, 2) — shape (2, 3, 2) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| TransformerBlock |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("786b3229be60ffc1") How it ranRan 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, shape (2, 3, 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
import torch.nn as nn
import torch.nn.functional as F
class TransformerBlock(nn.Module):
def __init__(self, embed_dim, num_heads, dim_feedforward=2048, dropout=0.1):
super(TransformerBlock, self).__init__()
self.self_attn = nn.MultiheadAttention(embed_dim, num_heads, dropout=dropout)
self.linear1 = nn.Linear(embed_dim, dim_feedforward)
self.dropout = nn.Dropout(dropout)
self.linear2 = nn.Linear(dim_feedforward, embed_dim)
self.norm1 = nn.LayerNorm(embed_dim)
self.norm2 = nn.LayerNorm(embed_dim)
self.dropout1 = nn.Dropout(dropout)
self.dropout2 = nn.Dropout(dropout)
self.activation = F.relu
def forward(self, x):
"""
x: (B, NUM_POINTS, EMBED_DIM)
"""
x = x.permute(1, 0, 2)
attn_output, _ = self.self_attn(x, x, x)
attn_output = attn_output.permute(1, 0, 2)
x = self.norm1(x.permute(1, 0, 2) + self.dropout1(attn_output))
ff_output = self.linear2(self.dropout(self.activation(self.linear1(x))))
x = self.norm2(x + self.dropout2(ff_output))
return x
INIT_ARGS = {
'embed_dim': 4,
'num_heads': 2,
'dim_feedforward': 8,
'dropout': 0.1
}
ARGS = {
'x': torch.randn(2, 3, 4)
}
if __name__ == '__main__':
model = TransformerBlock(**INIT_ARGS)
output = model(**ARGS)
print(f"Input shape: {ARGS['x'].shape}")
print(f"Output shape: {output.shape}")
print("TransformerBlock executed successfully")
- 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, shape (2, 3, 4) — shape (2, 3, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| VLRCls |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("ad9ebfa5399101aa") How it ranRan 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 2, dtype family float, shape (2, 8) 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
import torch.nn.functional as F
import math
class PositionalEncoding(nn.Module):
def __init__(self, embed_dim, max_len=1024):
super(PositionalEncoding, self).__init__()
pe = torch.zeros(max_len, embed_dim)
position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
div_term = torch.exp(torch.arange(0, embed_dim, 2).float() * (-math.log(10000.0) / embed_dim))
pe[:, 0::2] = torch.sin(position * div_term)
pe[:, 1::2] = torch.cos(position * div_term)
pe = pe.unsqueeze(0)
self.register_buffer('pe', pe)
def forward(self, x):
"""
x: (B, NUM_POINTS, EMBED_DIM)
"""
x = x + self.pe[:, :x.size(1), :]
return x
class TransformerBlock(nn.Module):
def __init__(self, embed_dim, num_heads, dim_feedforward=2048, dropout=0.1):
super(TransformerBlock, self).__init__()
self.self_attn = nn.MultiheadAttention(embed_dim, num_heads, dropout=dropout)
self.linear1 = nn.Linear(embed_dim, dim_feedforward)
self.dropout = nn.Dropout(dropout)
self.linear2 = nn.Linear(dim_feedforward, embed_dim)
self.norm1 = nn.LayerNorm(embed_dim)
self.norm2 = nn.LayerNorm(embed_dim)
self.dropout1 = nn.Dropout(dropout)
self.dropout2 = nn.Dropout(dropout)
self.activation = F.relu
def forward(self, x):
"""
x: (B, NUM_POINTS, EMBED_DIM)
"""
x = x.permute(1, 0, 2)
attn_output, _ = self.self_attn(x, x, x)
attn_output = attn_output.permute(1, 0, 2)
x = self.norm1(x.permute(1, 0, 2) + self.dropout1(attn_output))
ff_output = self.linear2(self.dropout(self.activation(self.linear1(x))))
x = self.norm2(x + self.dropout2(ff_output))
return x
class VLRCls(nn.Module):
def __init__(self, state_dim, feature_dim, num_layers=3, num_heads=8, dim_feedforward=512, dropout=0.1, num_points=64):
super(VLRCls, self).__init__()
self.embed_dim = state_dim
self.num_points = num_points
self.input_linear = nn.Linear(feature_dim, self.embed_dim)
self.positional_encoding = PositionalEncoding(self.embed_dim, max_len=num_points)
self.transformer_blocks = nn.ModuleList([TransformerBlock(self.embed_dim, num_heads, dim_feedforward, dropout) for _ in range(num_layers)])
self.classifier = nn.Sequential(nn.Linear(self.embed_dim, 256), nn.ReLU(inplace=True), nn.Dropout(dropout), nn.Linear(256, 1))
def forward(self, x, valid_mask=None):
"""
x: (B, E, N)
valid_mask: (B, N) Optional, 1 indicates valid, 0 indicates invalid
"""
x = x.permute(0, 2, 1)
B, N, E = x.size()
x = self.input_linear(x)
x = self.positional_encoding(x)
for block in self.transformer_blocks:
x = block(x)
logits = self.classifier(x).squeeze(-1)
return logits
INIT_ARGS = {
'state_dim': 16,
'feature_dim': 4,
'num_layers': 2,
'num_heads': 2,
'dim_feedforward': 32,
'dropout': 0.1,
'num_points': 8,
}
ARGS = {
'x': torch.randn(2, 4, 8),
'valid_mask': None,
}
- 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 2, dtype family float, shape (2, 8) — shape (2, 8) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| WindowAttention |
Ran ran on a synthesized input |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("29f2571a39169e89") How it ranRan 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, shape (2, 6, 8) 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
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
class WindowAttention(nn.Module):
"""Window based multi-head self attention (W-MSA) module with relative position bias.
It supports both of shifted and non-shifted window.
Args:
dim (int): Number of input channels.
window_size (tuple[int]): The height and width of the window.
num_heads (int): Number of attention heads.
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set
attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0
proj_drop (float, optional): Dropout ratio of output. Default: 0.0
"""
def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0.0, proj_drop=0.0):
super().__init__()
self.dim = dim
self.window_size = window_size
self.num_heads = num_heads
head_dim = dim // num_heads
self.scale = qk_scale or head_dim ** (-0.5)
self.relative_position_bias_table = nn.Parameter(torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads))
coords_h = torch.arange(self.window_size[0])
coords_w = torch.arange(self.window_size[1])
coords = torch.stack(torch.meshgrid([coords_h, coords_w]))
coords_flatten = torch.flatten(coords, 1)
relative_coords = coords_flatten[:, :, None] - coords_flatten[:, None, :]
relative_coords = relative_coords.permute(1, 2, 0).contiguous()
relative_coords[:, :, 0] += self.window_size[0] - 1
relative_coords[:, :, 1] += self.window_size[1] - 1
relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1
relative_position_index = relative_coords.sum(-1)
self.register_buffer('relative_position_index', relative_position_index)
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
self.attn_drop = nn.Dropout(attn_drop)
self.proj = nn.Linear(dim, dim)
self.proj_drop = nn.Dropout(proj_drop)
trunc_normal_(self.relative_position_bias_table, std=0.02)
self.softmax = nn.Softmax(dim=-1)
def forward(self, x, mask=None):
"""Forward function.
Args:
x: input features with shape of (num_windows*B, N, C)
mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None
"""
B_, N, C = x.shape
qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
q, k, v = (qkv[0], qkv[1], qkv[2])
q = q * self.scale
attn = q @ k.transpose(-2, -1)
relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view(self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1)
relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous()
attn = attn + relative_position_bias.unsqueeze(0)
if mask is not None:
nW = mask.shape[0]
attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0)
attn = attn.view(-1, self.num_heads, N, N)
attn = self.softmax(attn)
else:
attn = self.softmax(attn)
attn = self.attn_drop(attn)
x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
x = self.proj(x)
x = self.proj_drop(x)
return x
INIT_ARGS = {
'dim': 8,
'window_size': (2, 3),
'num_heads': 2,
'qkv_bias': True,
'qk_scale': None,
'attn_drop': 0.0,
'proj_drop': 0.0,
}
ARGS = {
'x': torch.randn(2, 6, 8),
'mask': None,
}
if __name__ == '__main__':
module = WindowAttention(**INIT_ARGS)
output = module(**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
- timm, 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 (2, 6, 8) — shape (2, 6, 8) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| compute_polygon_angles_with_loop_n_neighbors |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("25f0811daa7a2823") How it ranRan 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 2, dtype family float, shape (2, 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 small polygon points: (B=2, N=4, 2D coordinates)
# Batch 0: all valid points forming a simple quadrilateral
# Batch 1: some invalid points (marked in valid_mask)
points = torch.tensor([
[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]], # Batch 0: square
[[0.0, 0.0], [2.0, 0.0], [2.0, 2.0], [0.0, 2.0]] # Batch 1: larger square
], dtype=torch.float32)
# Valid mask: (B=2, N=4)
# Batch 0: all points valid (triggers non-circular processing)
# Batch 1: some points invalid (triggers circular processing)
valid_mask = torch.tensor([
[1, 1, 1, 1], # All valid
[1, 0, 1, 1] # Point 1 is invalid
], dtype=torch.int32)
# Number of neighbors to consider
n = 1
ARGS = {
"points": points,
"valid_mask": valid_mask,
"n": n
}
- 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 2, dtype family float, shape (2, 4) — shape (2, 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
|
| get_points_feature |
Ran ran; our contract draft was wrong, not the code |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("b7746c1db4def022") How it ranRan 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 (2, 4, 5) 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.functional as F
torch.manual_seed(0)
# img_feature: shape (batch_size, num_channels, height, width)
# Used in: img_feature[i].unsqueeze(0) and img_feature.size()
batch_size = 2
num_channels = 4
feature_height = 8
feature_width = 8
img_feature = torch.randn(batch_size, num_channels, feature_height, feature_width)
# img_poly: shape (num_polygons, num_points, 2)
# Used in: img_poly.clone(), img_poly[..., 0], img_poly[..., 1], img_poly.size(), img_poly[i], img_poly.device
num_polygons = 3
num_points = 5
img_poly = torch.randn(num_polygons, num_points, 2) * 10 # Random coordinates in image space
# h: image height (scalar)
# Used in: h / 2.0 for normalization
h = 16
# w: image width (scalar)
# Used in: w / 2.0 for normalization
w = 16
ARGS = {
"img_feature": img_feature,
"img_poly": img_poly,
"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 3, dtype family float, shape (2, 4, 5) — shape (2, 4, 5) 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
|
| img_poly_to_can_poly |
Ran ran; our contract draft was wrong, not the code |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("7508f27fe7a9c78d") How it ranRan 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 (2, 4, 2) 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 small tensors for testing
# img_poly: shape (B, num_points, 2) - batch of 2, 4 points, 2 coordinates (x, y)
img_poly = torch.tensor([
[[10.0, 20.0], [15.0, 25.0], [12.0, 22.0], [18.0, 28.0]],
[[5.0, 10.0], [8.0, 12.0], [6.0, 11.0], [9.0, 13.0]]
], dtype=torch.float32)
# valid_mask: shape (B, num_points) - 1 for valid, 0 for invalid
valid_mask = torch.tensor([
[1, 1, 1, 0],
[1, 1, 0, 1]
], dtype=torch.float32)
ARGS = {
"img_poly": img_poly,
"valid_mask": valid_mask
}
- 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 (2, 4, 2) — shape (2, 4, 2) 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
|
| BasicLayer |
Not yet run unverified (harvested, no recorded run) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("5c7c6cc7711156e2") How it ran |
| SwinTransformer |
Not yet run unverified (harvested, no recorded run) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("043c455a7077575f") How it ran |
| SwinTransformerBlock |
Not yet run unverified (harvested, no recorded run) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("afc9d517285768aa") How it ran |
| VLRAsModel |
Not yet run unverified (harvested, no recorded run) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("62c4c1b352fb7070") How it ran |
| VLROffset |
Not yet run unverified (harvested, no recorded run) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("34aeae946e9f4535") How it ran |
| load_checkpoint |
Not yet run unverified (harvested, no recorded run) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("183d40d097a305c4") How it ran |
| swin_l |
Not yet run unverified (harvested, no recorded run) |
vvangfaye/HoliTracer/holitracer/vector/models/base.py code served (permissive licence) · get_code("6134b7f76051d2d7") How it ran |