Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

4,060 changes: 0 additions & 4,060 deletions tests/torch/data/fx/dynamic_shapes/post_quantization_compressed/swin_v2_t.dot

This file was deleted.

1,440 changes: 1,440 additions & 0 deletions tests/torch/data/fx/dynamic_shapes/quantized/swin_v2_single_block.dot

Large diffs are not rendered by default.

4,166 changes: 0 additions & 4,166 deletions tests/torch/data/fx/dynamic_shapes/quantized/swin_v2_t.dot

This file was deleted.

1,128 changes: 1,128 additions & 0 deletions tests/torch/data/fx/post_quantization_compressed/swin_v2_single_block.dot

Large diffs are not rendered by default.

3,630 changes: 0 additions & 3,630 deletions tests/torch/data/fx/post_quantization_compressed/swin_v2_t.dot

This file was deleted.

1,170 changes: 1,170 additions & 0 deletions tests/torch/data/fx/quantized/swin_v2_single_block.dot

Large diffs are not rendered by default.

3,736 changes: 0 additions & 3,736 deletions tests/torch/data/fx/quantized/swin_v2_t.dot

This file was deleted.

375 changes: 375 additions & 0 deletions tests/torch/data/fx/reference_metatypes/swin_v2_single_block.json

Large diffs are not rendered by default.

1,312 changes: 0 additions & 1,312 deletions tests/torch/data/fx/reference_metatypes/swin_v2_t.json

This file was deleted.

788 changes: 788 additions & 0 deletions tests/torch/data/fx/swin_v2_single_block.dot

Large diffs are not rendered by default.

2,746 changes: 0 additions & 2,746 deletions tests/torch/data/fx/swin_v2_t.dot

This file was deleted.

9 changes: 5 additions & 4 deletions tests/torch/fx/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from tests.torch.test_models.synthetic import MultiBranchesConnectedModel
from tests.torch.test_models.synthetic import ShortTransformer
from tests.torch.test_models.synthetic import SplitCatModel
from tests.torch.test_models.synthetic import SwinV2SingleBlock
from tests.torch.test_models.synthetic import TopKModel
from tests.torch.test_models.synthetic import YOLO11N_SDPABlock

Expand Down Expand Up @@ -73,7 +74,7 @@ def torchvision_model_case(model_id: str, input_shape: tuple[int,]):
torchvision_model_case("resnet18", (1, 3, 224, 224)),
torchvision_model_case("mobilenet_v3_small", (1, 3, 224, 224)),
torchvision_model_case("vit_b_16", (1, 3, 224, 224)),
torchvision_model_case("swin_v2_t", (1, 3, 224, 224)),
ModelCase(SwinV2SingleBlock, "swin_v2_single_block", SwinV2SingleBlock.INPUT_SHAPE),
ModelCase(test_models.UNet, "unet", [1, 3, 224, 224]),
ModelCase(partial(ShortTransformer, 5, 10), "synthetic_transformer", [5]),
ModelCase(YOLO11N_SDPABlock, "yolo11n_sdpa_block", YOLO11N_SDPABlock.INPUT_SIZE),
Expand Down Expand Up @@ -173,11 +174,11 @@ def test_model(test_case: ModelCase, regen_ref_data: bool):
[Dim.AUTO, Dim.STATIC, Dim.STATIC, Dim.STATIC], # This ViT Model is not eligible for dynamic shape capability
),
(
torchvision_model_case("swin_v2_t", (1, 3, 224, 224)),
ModelCase(SwinV2SingleBlock, "swin_v2_single_block", SwinV2SingleBlock.INPUT_SHAPE),
{"model_type": nncf.ModelType.TRANSFORMER},
[
(130, 130),
(77, 77),
(50, 50),
(29, 29),
],
[Dim.AUTO, Dim.STATIC, Dim.AUTO, Dim.AUTO],
Comment thread
daniil-lyakhov marked this conversation as resolved.
),
Expand Down
26 changes: 26 additions & 0 deletions tests/torch/test_models/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from torch.nn import BatchNorm2d
from torch.nn import Dropout
from torch.nn import Parameter
from torchvision.models.swin_transformer import PatchMergingV2
from torchvision.models.swin_transformer import SwinTransformer
from torchvision.models.swin_transformer import SwinTransformerBlockV2
from torchvision.transforms.functional import normalize

from tests.torch.helpers import create_bn
Expand Down Expand Up @@ -690,3 +693,26 @@ def __init__(self) -> None:
def forward(self, x):
# input_shape = [1, 3, 32, 32]
return self.depthwise_conv(x)


class SwinV2SingleBlock(nn.Module):
"""Minimal Swin Transformer V2 model with a single block for testing."""

INPUT_SHAPE = (1, 3, 224, 224)

def __init__(self):
super().__init__()
self.model = SwinTransformer(
patch_size=[4, 4],
embed_dim=96,
depths=[1, 1, 1, 1],
num_heads=[3, 6, 12, 24],
window_size=[8, 8],
stochastic_depth_prob=0.2,
num_classes=10,
block=SwinTransformerBlockV2,
downsample_layer=PatchMergingV2,
Comment thread
daniil-lyakhov marked this conversation as resolved.
)

def forward(self, x: torch.Tensor) -> torch.Tensor:
return self.model(x)