| Attention |
Ran ran on a synthesized input · constructed an object; no result was computed |
rishikksh20/CrossViT-pytorch/crossvit.py code served (permissive licence) · get_code("411c4d270072eb2e") How it ranRan 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, Attention: 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 Attention module expects:
# - dim: input dimension
# - heads: number of attention heads (default 8)
# - dim_head: dimension per head (default 64)
# - dropout: dropout rate (default 0.0)
# For forward(), it expects:
# - x: tensor of shape (batch, sequence_length, dim)
ARGS = {
"dim": 64,
"heads": 4,
"dim_head": 16,
"dropout": 0.1,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Attention — 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 Attention 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
|
| Attention |
Ran ran on a synthesized input |
ahmedelmahy/myownvit/vit_pytorch/cross_vit.py code served (permissive licence) · get_code("39b524cdd79f5d2e") 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, 5, 16) 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
from torch import nn, einsum
from einops import rearrange, repeat
def default(val, d):
return val if exists(val) else d
def exists(val):
return val is not None
class Attention(nn.Module):
def __init__(self, dim, heads=8, dim_head=64, dropout=0.0):
super().__init__()
inner_dim = dim_head * heads
self.heads = heads
self.scale = dim_head ** (-0.5)
self.attend = nn.Softmax(dim=-1)
self.to_q = nn.Linear(dim, inner_dim, bias=False)
self.to_kv = nn.Linear(dim, inner_dim * 2, bias=False)
self.to_out = nn.Sequential(nn.Linear(inner_dim, dim), nn.Dropout(dropout))
def forward(self, x, context=None, kv_include_self=False):
b, n, _, h = (*x.shape, self.heads)
context = default(context, x)
if kv_include_self:
context = torch.cat((x, context), dim=1)
qkv = (self.to_q(x), *self.to_kv(context).chunk(2, dim=-1))
q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=h), qkv)
dots = einsum('b h i d, b h j d -> b h i j', q, k) * self.scale
attn = self.attend(dots)
out = einsum('b h i j, b h j d -> b h i d', attn, v)
out = rearrange(out, 'b h n d -> b n (h d)')
return self.to_out(out)
INIT_ARGS = {
'dim': 16,
'heads': 2,
'dim_head': 8,
'dropout': 0.1,
}
ARGS = {
'x': torch.randn(2, 5, 16),
'context': None,
'kv_include_self': False,
}
if __name__ == '__main__':
attention = Attention(**INIT_ARGS)
output = attention(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 5, 16)")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- einops, 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, 5, 16) — shape (2, 5, 16) 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)
|
| CrossAttention |
Ran ran on a synthesized input |
rishikksh20/CrossViT-pytorch/crossvit.py code served (permissive licence) · get_code("8abca80f7f8a5dda") 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 numpy as np
# INIT_ARGS for CrossAttention.__init__
INIT_ARGS = {
'dim': 16,
'heads': 4,
'dim_head': 8,
'dropout': 0.1
}
# ARGS for CrossAttention.forward
# The forward method expects x_qkv with shape (batch, sequence_length, dim)
# The query is extracted from x_qkv[:, 0], so we need at least 1 token
ARGS = {
'x_qkv': torch.randn(2, 5, 16) # batch=2, seq_len=5, dim=16
}
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- einops, numpy, 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)
|
| CrossAttention |
Ran ran on a synthesized input · constructed an object; no result was computed |
IBM/CrossViT/models/crossvit.py code served (permissive licence) · get_code("9811d06fb8557fa5") How it ranRan 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, CrossAttention: 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 minimal valid input tensor
# Shape: (batch_size=2, num_tokens=5, dim=4)
x = torch.randn(2, 5, 4)
# Define ARGS dict with all parameters for CrossAttention.__init__
ARGS = {
'dim': 4,
'num_heads': 2,
'qkv_bias': False,
'qk_scale': None,
'attn_drop': 0.0,
'proj_drop': 0.0,
}
- 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 CrossAttention — 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 CrossAttention 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
|
| CrossAttentionBlock |
Ran ran on a synthesized input · constructed an object; no result was computed |
IBM/CrossViT/models/crossvit.py code served (permissive licence) · get_code("185cacf0bed5e23b") How it ranRan 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, CrossAttentionBlock: 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
from timm.models.layers import DropPath
from timm.models.vision_transformer import Mlp
torch.manual_seed(0)
ARGS = {
"dim": 64,
"num_heads": 8,
"mlp_ratio": 4.0,
"qkv_bias": False,
"qk_scale": None,
"drop": 0.1,
"attn_drop": 0.1,
"drop_path": 0.1,
"act_layer": nn.GELU,
"norm_layer": nn.LayerNorm,
"has_mlp": True,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type CrossAttentionBlock — 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 CrossAttentionBlock 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
|
| CrossTransformer |
Ran ran on a synthesized input |
ahmedelmahy/myownvit/vit_pytorch/cross_vit.py code served (permissive licence) · get_code("7909555e0d7a8a93") 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 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
from torch import nn, einsum
from einops import rearrange, repeat
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
class Attention(nn.Module):
def __init__(self, dim, heads=8, dim_head=64, dropout=0.0):
super().__init__()
inner_dim = dim_head * heads
self.heads = heads
self.scale = dim_head ** (-0.5)
self.attend = nn.Softmax(dim=-1)
self.to_q = nn.Linear(dim, inner_dim, bias=False)
self.to_kv = nn.Linear(dim, inner_dim * 2, bias=False)
self.to_out = nn.Sequential(nn.Linear(inner_dim, dim), nn.Dropout(dropout))
def forward(self, x, context=None, kv_include_self=False):
b, n, _, h = (*x.shape, self.heads)
context = default(context, x)
if kv_include_self:
context = torch.cat((x, context), dim=1)
qkv = (self.to_q(x), *self.to_kv(context).chunk(2, dim=-1))
q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=h), qkv)
dots = einsum('b h i d, b h j d -> b h i j', q, k) * self.scale
attn = self.attend(dots)
out = einsum('b h i j, b h j d -> b h i d', attn, v)
out = rearrange(out, 'b h n d -> b n (h d)')
return self.to_out(out)
class PreNorm(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.norm = nn.LayerNorm(dim)
self.fn = fn
def forward(self, x, **kwargs):
return self.fn(self.norm(x), **kwargs)
class ProjectInOut(nn.Module):
def __init__(self, dim_in, dim_out, fn):
super().__init__()
self.fn = fn
need_projection = dim_in != dim_out
self.project_in = nn.Linear(dim_in, dim_out) if need_projection else nn.Identity()
self.project_out = nn.Linear(dim_out, dim_in) if need_projection else nn.Identity()
def forward(self, x, *args, **kwargs):
x = self.project_in(x)
x = self.fn(x, *args, **kwargs)
x = self.project_out(x)
return x
class CrossTransformer(nn.Module):
def __init__(self, sm_dim, lg_dim, depth, heads, dim_head, dropout):
super().__init__()
self.layers = nn.ModuleList([])
for _ in range(depth):
self.layers.append(nn.ModuleList([ProjectInOut(sm_dim, lg_dim, PreNorm(lg_dim, Attention(lg_dim, heads=heads, dim_head=dim_head, dropout=dropout))), ProjectInOut(lg_dim, sm_dim, PreNorm(sm_dim, Attention(sm_dim, heads=heads, dim_head=dim_head, dropout=dropout)))]))
def forward(self, sm_tokens, lg_tokens):
(sm_cls, sm_patch_tokens), (lg_cls, lg_patch_tokens) = map(lambda t: (t[:, :1], t[:, 1:]), (sm_tokens, lg_tokens))
for sm_attend_lg, lg_attend_sm in self.layers:
sm_cls = sm_attend_lg(sm_cls, context=lg_patch_tokens, kv_include_self=True) + sm_cls
lg_cls = lg_attend_sm(lg_cls, context=sm_patch_tokens, kv_include_self=True) + lg_cls
sm_tokens = torch.cat((sm_cls, sm_patch_tokens), dim=1)
lg_tokens = torch.cat((lg_cls, lg_patch_tokens), dim=1)
return (sm_tokens, lg_tokens)
INIT_ARGS = {
'sm_dim': 4,
'lg_dim': 6,
'depth': 2,
'heads': 2,
'dim_head': 3,
'dropout': 0.1,
}
ARGS = {
'sm_tokens': torch.randn(2, 5, 4),
'lg_tokens': torch.randn(2, 7, 6),
}
if __name__ == '__main__':
model = CrossTransformer(**INIT_ARGS)
output = model(**ARGS)
print("Output shapes:", output[0].shape, output[1].shape)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- einops, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| ImageEmbedder |
Ran ran on a synthesized input · constructed an object; no result was computed |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("541e36b2edd2e342") How it ranRan 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, ImageEmbedder: 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 jax
import jax.numpy as jnp
from flax import linen as nn
from einops import rearrange, repeat
class ImageEmbedder(nn.Module):
dim: int
image_size: int
patch_size: int
dropout: float = 0.0
@nn.compact
def __call__(self, x):
assert self.image_size % self.patch_size == 0, 'Image dimensions must be divisible by the patch size.'
num_patches = (self.image_size // self.patch_size) ** 2
pos_embedding = self.param('pos_embedding', nn.initializers.zeros, [1, num_patches + 1, self.dim])
cls_token = self.param('cls', nn.initializers.zeros, [1, 1, self.dim])
x = rearrange(x, 'b (h p1) (w p2) c -> b (h w) (p1 p2 c)', p1=self.patch_size, p2=self.patch_size)
x = nn.Dense(features=self.dim)(x)
b, n, d = x.shape
cls_tokens = repeat(cls_token, '() n d -> b n d', b=b)
x = jnp.concatenate([cls_tokens, x], axis=1)
x += pos_embedding[:, :n + 1]
x = nn.Dropout(rate=self.dropout)(x, deterministic=False)
return x
dim = 4
image_size = 8
patch_size = 4
dropout = 0.1
batch_size = 2
channels = 3
x = jnp.ones((batch_size, image_size, image_size, channels))
ARGS = {
'dim': dim,
'image_size': image_size,
'patch_size': patch_size,
'dropout': dropout
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- einops, flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ImageEmbedder — 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 ImageEmbedder 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
|
| ImageEmbedder |
Ran ran on a synthesized input |
ahmedelmahy/myownvit/vit_pytorch/cross_vit.py code served (permissive licence) · get_code("0a16f340785793af") 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, 17, 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
from torch import nn, einsum
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
class ImageEmbedder(nn.Module):
def __init__(self, *, dim, image_size, patch_size, dropout=0.0):
super().__init__()
assert image_size % patch_size == 0, 'Image dimensions must be divisible by the patch size.'
num_patches = (image_size // patch_size) ** 2
patch_dim = 3 * patch_size ** 2
self.to_patch_embedding = nn.Sequential(Rearrange('b c (h p1) (w p2) -> b (h w) (p1 p2 c)', p1=patch_size, p2=patch_size), nn.Linear(patch_dim, dim))
self.pos_embedding = nn.Parameter(torch.randn(1, num_patches + 1, dim))
self.cls_token = nn.Parameter(torch.randn(1, 1, dim))
self.dropout = nn.Dropout(dropout)
def forward(self, img):
x = self.to_patch_embedding(img)
b, n, _ = x.shape
cls_tokens = repeat(self.cls_token, '() n d -> b n d', b=b)
x = torch.cat((cls_tokens, x), dim=1)
x += self.pos_embedding[:, :n + 1]
return self.dropout(x)
INIT_ARGS = {
'dim': 8,
'image_size': 8,
'patch_size': 2,
'dropout': 0.1,
}
ARGS = {
'img': torch.randn(2, 3, 8, 8),
}
if __name__ == '__main__':
model = ImageEmbedder(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 17, 8)")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- einops, 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, 17, 8) — shape (2, 17, 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)
|
| MultiScaleEncoder |
Ran ran on a synthesized input · constructed an object; no result was computed |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("18ea900a9c20be8f") How it ranRan 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, MultiScaleEncoder: 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 jax
import jax.numpy as jnp
from jax import random
# Define helper functions that are used in the code
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
# Create small test inputs
batch_size = 2
sm_seq_len = 5
lg_seq_len = 7
sm_dim = 4
lg_dim = 6
# Small model parameters
sm_enc_params = {
"depth": 1,
"heads": 2,
"dim_head": 2,
"mlp_dim": 8,
}
lg_enc_params = {
"depth": 1,
"heads": 2,
"dim_head": 3,
"mlp_dim": 12,
}
# Create input tensors
# sm_tokens: (batch, seq_len, dim)
sm_tokens = jnp.ones((batch_size, sm_seq_len, sm_dim))
# lg_tokens: (batch, seq_len, dim)
lg_tokens = jnp.ones((batch_size, lg_seq_len, lg_dim))
inputs = (sm_tokens, lg_tokens)
# Define the ARGS dictionary with all parameters for MultiScaleEncoder
ARGS = {
"depth": 2,
"sm_dim": sm_dim,
"lg_dim": lg_dim,
"sm_enc_params": sm_enc_params,
"lg_enc_params": lg_enc_params,
"cross_attn_heads": 2,
"cross_attn_depth": 1,
"cross_attn_dim_head": 2,
"dropout": 0.1,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- einops, flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type MultiScaleEncoder — 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 MultiScaleEncoder 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 |
IBM/CrossViT/models/crossvit.py code served (permissive licence) · get_code("2562a86d027ed434") How it ranRan 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
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
torch.manual_seed(0)
ARGS = {
"img_size": 224,
"patch_size": 16,
"in_chans": 3,
"embed_dim": 768,
"multi_conv": False,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- timm, 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
|
| PreNorm |
Ran ran on a synthesized input · constructed an object; no result was computed |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("d7aaba5132053213") How it ranRan 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, PreNorm: 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 jax
import jax.numpy as jnp
import flax.linen as nn
# Define a simple callable function that will be used as fn in PreNorm
class SimpleMLP(nn.Module):
@nn.compact
def __call__(self, x, **kwargs):
x = nn.Dense(3)(x)
return x
# Create an instance of the callable to pass as fn parameter
fn_instance = SimpleMLP()
# Construct ARGS dict with all parameters of PreNorm
ARGS = {
"fn": fn_instance
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type PreNorm — 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 PreNorm 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
|
| ProjectInOut |
Ran ran on a synthesized input · constructed an object; no result was computed |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("395f410c7cd053df") How it ranRan 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, ProjectInOut: 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 jax
import jax.numpy as jnp
import flax.linen as nn
from typing import Callable
# Define a simple callable function that will be used as fn
class SimpleFn(nn.Module):
@nn.compact
def __call__(self, x, *args, **kwargs):
# Simple identity-like operation that preserves shape
x = nn.Dense(features=x.shape[-1])(x)
return x
# Create instances
dim_in = 4
dim_out = 5
fn = SimpleFn()
ARGS = {
"dim_in": dim_in,
"dim_out": dim_out,
"fn": fn,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ProjectInOut — 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 ProjectInOut 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
|
| ProjectInOut |
Ran ran on a synthesized input |
ahmedelmahy/myownvit/vit_pytorch/cross_vit.py code served (permissive licence) · get_code("5c51a399079da30b") 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, 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
from torch import nn, einsum
class ProjectInOut(nn.Module):
def __init__(self, dim_in, dim_out, fn):
super().__init__()
self.fn = fn
need_projection = dim_in != dim_out
self.project_in = nn.Linear(dim_in, dim_out) if need_projection else nn.Identity()
self.project_out = nn.Linear(dim_out, dim_in) if need_projection else nn.Identity()
def forward(self, x, *args, **kwargs):
x = self.project_in(x)
x = self.fn(x, *args, **kwargs)
x = self.project_out(x)
return x
class SimpleFunction(nn.Module):
def forward(self, x):
return x * 2
INIT_ARGS = {
'dim_in': 4,
'dim_out': 3,
'fn': SimpleFunction()
}
ARGS = {
'x': torch.randn(2, 4)
}
if __name__ == '__main__':
module = ProjectInOut(**INIT_ARGS)
output = module(**ARGS)
print(output.shape)
- 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, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| Transformer |
Ran ran on a synthesized input · constructed an object; no result was computed |
rishikksh20/CrossViT-pytorch/crossvit.py code served (permissive licence) · get_code("45127327251f05d5") How it ranRan 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, Transformer: 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,
'depth': 2,
'heads': 2,
'dim_head': 2,
'mlp_dim': 8,
'dropout': 0.1
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Transformer — 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 Transformer 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
|
| Transformer |
Ran ran on a synthesized input · constructed an object; no result was computed |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("0415c013e361e191") How it ranRan 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, Transformer: 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 jax
import jax.numpy as jnp
# Initialize JAX random key
key = jax.random.PRNGKey(0)
# Define small but distinct dimensions
dim = 4
heads = 2
dim_head = 2
depth = 1
mlp_dim = 8
dropout = 0.1
# Create input tensor: (batch_size=2, sequence_length=3, dim=4)
batch_size = 2
seq_length = 3
x = jnp.ones((batch_size, seq_length, dim), dtype=jnp.float32)
ARGS = {
"dim": dim,
"depth": depth,
"heads": heads,
"dim_head": dim_head,
"mlp_dim": mlp_dim,
"dropout": dropout,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- einops, flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Transformer — 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 Transformer 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
|
| Transformer |
Ran ran on a synthesized input |
ahmedelmahy/myownvit/vit_pytorch/cross_vit.py code served (permissive licence) · get_code("139bcf50e1423e16") 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
from torch import nn, einsum
from einops import rearrange, repeat
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
class Attention(nn.Module):
def __init__(self, dim, heads=8, dim_head=64, dropout=0.0):
super().__init__()
inner_dim = dim_head * heads
self.heads = heads
self.scale = dim_head ** (-0.5)
self.attend = nn.Softmax(dim=-1)
self.to_q = nn.Linear(dim, inner_dim, bias=False)
self.to_kv = nn.Linear(dim, inner_dim * 2, bias=False)
self.to_out = nn.Sequential(nn.Linear(inner_dim, dim), nn.Dropout(dropout))
def forward(self, x, context=None, kv_include_self=False):
b, n, _, h = (*x.shape, self.heads)
context = default(context, x)
if kv_include_self:
context = torch.cat((x, context), dim=1)
qkv = (self.to_q(x), *self.to_kv(context).chunk(2, dim=-1))
q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=h), qkv)
dots = einsum('b h i d, b h j d -> b h i j', q, k) * self.scale
attn = self.attend(dots)
out = einsum('b h i j, b h j d -> b h i d', attn, v)
out = rearrange(out, 'b h n d -> b n (h d)')
return self.to_out(out)
class FeedForward(nn.Module):
def __init__(self, dim, hidden_dim, dropout=0.0):
super().__init__()
self.net = nn.Sequential(nn.Linear(dim, hidden_dim), nn.GELU(), nn.Dropout(dropout), nn.Linear(hidden_dim, dim), nn.Dropout(dropout))
def forward(self, x):
return self.net(x)
class PreNorm(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.norm = nn.LayerNorm(dim)
self.fn = fn
def forward(self, x, **kwargs):
return self.fn(self.norm(x), **kwargs)
class Transformer(nn.Module):
def __init__(self, dim, depth, heads, dim_head, mlp_dim, dropout=0.0):
super().__init__()
self.layers = nn.ModuleList([])
self.norm = nn.LayerNorm(dim)
for _ in range(depth):
self.layers.append(nn.ModuleList([PreNorm(dim, Attention(dim, heads=heads, dim_head=dim_head, dropout=dropout)), PreNorm(dim, FeedForward(dim, mlp_dim, dropout=dropout))]))
def forward(self, x):
for attn, ff in self.layers:
x = attn(x) + x
x = ff(x) + x
return self.norm(x)
INIT_ARGS = {
'dim': 4,
'depth': 2,
'heads': 2,
'dim_head': 2,
'mlp_dim': 8,
'dropout': 0.0
}
ARGS = {
'x': torch.randn(2, 3, 4)
}
if __name__ == '__main__':
model = Transformer(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 3, 4)")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- einops, 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)
|
| _compute_num_patches |
Ran ran, violated the contract we drafted |
IBM/CrossViT/models/crossvit.py code served (permissive licence) · get_code("54f90cefd4fe4358") How it ranRan 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 list, ndim 1, dtype family int; 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
torch.manual_seed(0)
ARGS = {
"img_size": [224, 256],
"patches": [16, 16]
}
- 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 list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
- 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
|
| Attention |
Not yet run unverified (harvested, no recorded run) |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("695e0238d8d29d65") How it ran |
| CrossTransformer |
Not yet run unverified (harvested, no recorded run) |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("fcda9506e4ba0369") How it ran |
| CrossViT |
Not yet run unverified (harvested, no recorded run) |
rishikksh20/CrossViT-pytorch/crossvit.py code served (permissive licence) · get_code("e9810edd3a725477") How it ran |
| CrossViT |
Not yet run unverified (harvested, no recorded run) |
conceptofmind/CrossViT-flax/cross_vit_flax/cross_vit_flax.py code served (permissive licence) · get_code("54eeb67b517aba4e") How it ran |
| CrossViT |
Not yet run unverified (harvested, no recorded run) |
ahmedelmahy/myownvit/vit_pytorch/cross_vit.py code served (permissive licence) · get_code("74763df32bbe08b3") How it ran |
| MultiScaleBlock |
Not yet run unverified (harvested, no recorded run) |
IBM/CrossViT/models/crossvit.py code served (permissive licence) · get_code("6eb91fffc193bc8d") How it ran |
| MultiScaleEncoder |
Not yet run unverified (harvested, no recorded run) |
ahmedelmahy/myownvit/vit_pytorch/cross_vit.py code served (permissive licence) · get_code("6f5a3f2db3ea4ac5") How it ran |
| MultiScaleTransformerEncoder |
Not yet run unverified (harvested, no recorded run) |
rishikksh20/CrossViT-pytorch/crossvit.py code served (permissive licence) · get_code("00453bc8eaf62cc7") How it ran |
| VisionTransformer |
Not yet run unverified (harvested, no recorded run) |
IBM/CrossViT/models/crossvit.py code served (permissive licence) · get_code("b05cff1db97d5001") How it ran |