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
25 changes: 24 additions & 1 deletion backends/arm/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,30 @@ def pytest_configure(config):


def pytest_collection_modifyitems(config, items):
pass
from executorch.backends.arm.test import common
from executorch.backends.arm.test.runner_utils import model_converter_installed
Comment thread
psiddh marked this conversation as resolved.

skip_marker = getattr(
common.SkipIfNoModelConverter, "mark", common.SkipIfNoModelConverter
)

if not model_converter_installed():
deselected = []
remaining = []
for item in items:
for marker in item.iter_markers("skipif"):
if (
marker.name == skip_marker.name
and marker.args == skip_marker.args
and marker.kwargs == skip_marker.kwargs
):
deselected.append(item)
break
else:
remaining.append(item)
if deselected:
config.hook.pytest_deselected(items=deselected)
items[:] = remaining


def pytest_addoption(parser):
Expand Down
47 changes: 35 additions & 12 deletions backends/vulkan/test/test_vulkan_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# pyre-unsafe

import ctypes
import os
import unittest
from typing import Tuple

Expand Down Expand Up @@ -38,10 +39,35 @@

try:
ctypes.CDLL("libvulkan.so.1")
except:
except OSError:
pass


def _is_using_swiftshader() -> bool:
try:
if os.environ.get("ETVK_USING_SWIFTSHADER", "0") in ("1", "True"):
return True
vk_icd = os.environ.get("VK_ICD_FILENAMES", "")
if "swiftshader" in vk_icd.lower():
return True
RTLD_NOLOAD = 4
for lib_name in ("libvk_swiftshader.so", "libvk_swiftshader_fbcode.so"):
try:
ctypes.CDLL(lib_name, mode=RTLD_NOLOAD)
return True
Comment thread
psiddh marked this conversation as resolved.
except Exception:
continue
return False
except Exception:
return True
Comment thread
psiddh marked this conversation as resolved.


skip_if_swiftshader = unittest.skipIf(
_is_using_swiftshader(),
"Not compatible with swiftshader",
)


def lower_module(
model: torch.nn.Module, sample_inputs: Tuple[torch.Tensor], dynamic_shapes=None
) -> EdgeProgramManager:
Expand Down Expand Up @@ -590,6 +616,7 @@ def forward(self, x):

self.lower_unary_module_and_test_output(SqrtModule())

@skip_if_swiftshader
def test_vulkan_backend_hardshrink(self):
class HardshrinkModule(torch.nn.Module):
def __init__(self):
Expand Down Expand Up @@ -1028,7 +1055,7 @@ def forward(self, x):
sample_inputs,
)

@unittest.skip("layer norm compute shader not working with swiftshader")
@skip_if_swiftshader
def test_vulkan_backend_native_layer_norm(self):
class NativeLayerNormModule(torch.nn.Module):
def __init__(self):
Expand Down Expand Up @@ -1459,9 +1486,7 @@ def forward(self, x):
sample_inputs,
)

@unittest.skip(
"Softmax shader with shared memory does not work with swiftshader due to potential swiftshader bug"
)
@skip_if_swiftshader
def test_vulkan_backend_softmax(self):
class SoftmaxModule(torch.nn.Module):
def __init__(self):
Expand All @@ -1480,9 +1505,7 @@ def forward(self, x):
sample_inputs,
)

@unittest.skip(
"Softmax shader with shared memory does not work with swiftshader due to potential swiftshader bug"
)
@skip_if_swiftshader
def test_vulkan_backend_logsoftmax(self):
class LogSoftmaxModule(torch.nn.Module):
def __init__(self):
Expand Down Expand Up @@ -2364,7 +2387,7 @@ def apply_quantization(self):
quantized_linear_module_gemm, sample_inputs_gemm, atol=1e-2, rtol=1e-2
)

@unittest.skip("Cannot run on swiftshader due to no integer dot product support")
@skip_if_swiftshader
def test_vulkan_backend_xnnpack_pt2e_quantized_linear_sequence(self):
"""
Test a sequence of linear layers quantized with XNNPACK quantization config.
Expand Down Expand Up @@ -2439,7 +2462,7 @@ def forward(self, x):
rtol=1e-1,
)

@unittest.skip("Cannot run on swiftshader due to no integer dot product support")
@skip_if_swiftshader
def test_vulkan_backend_xnnpack_pt2e_quantized_conv_sequence(self):
"""
Test a sequence of convolution layers quantized with PT2E quantization.
Expand Down Expand Up @@ -2530,7 +2553,7 @@ def forward(self, x):
rtol=1e-1,
)

@unittest.skip("Cannot run on swiftshader due to no integer dot product support")
@skip_if_swiftshader
def test_vulkan_backend_xnnpack_pt2e_quantized_conv_sequence_all_reduced(self):
"""
Test a sequence of convolution layers quantized with PT2E quantization.
Expand Down Expand Up @@ -2610,7 +2633,7 @@ def forward(self, x):
rtol=1e-1,
)

@unittest.skip("Cannot run on swiftshader due to no 8-bit int support")
@skip_if_swiftshader
def test_vulkan_backend_torchao_8da4w_quantized_linear(self):
"""
Test TorchAO 8da4w quantization (int8 dynamic activation + int4 weight) with Vulkan backend.
Expand Down
2 changes: 1 addition & 1 deletion exir/backend/test/test_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def partition(

with self.assertRaisesRegex(
AttributeError,
"can't set attribute 'spec'",
"can't set attribute 'spec'|has no setter",
):
my_partitioner.spec = {"new_key": "new_value"}

Expand Down
Loading