From 5c79b676279b4b1a6707cb8259c46fffe35e541f Mon Sep 17 00:00:00 2001 From: Nolwen Date: Fri, 15 Dec 2023 16:36:47 +0100 Subject: [PATCH] Xfail pytorch tests with conv2d/maxpooling + float16 + CPU --- tests/test_backward_conv.py | 4 ++++ tests/test_conv.py | 8 ++++++++ tests/test_pooling.py | 5 +++++ tests/test_utils_conv.py | 11 +++++++++-- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/test_backward_conv.py b/tests/test_backward_conv.py index 788b84f1..f51c031f 100644 --- a/tests/test_backward_conv.py +++ b/tests/test_backward_conv.py @@ -10,6 +10,10 @@ def test_Decomon_conv_box(data_format, padding, use_bias, mode, floatx, decimal, helpers): + # xfail unavailable combinations + if floatx == 16 and keras_config.backend() == "torch": + pytest.xfail("Pytorch does not implement conv2d for float16") + if data_format == "channels_first" and not helpers.in_GPU_mode(): pytest.skip("data format 'channels first' is possible only in GPU mode") diff --git a/tests/test_conv.py b/tests/test_conv.py index 5f98ccbb..24518b5f 100644 --- a/tests/test_conv.py +++ b/tests/test_conv.py @@ -12,6 +12,10 @@ def test_Decomon_conv_box(data_format, mode, dc_decomp, floatx, decimal, helpers): + # xfail unavailable combinations + if floatx == 16 and keras_config.backend() == "torch": + pytest.xfail("Pytorch does not implement conv2d for float16") + if data_format == "channels_first" and not helpers.in_GPU_mode(): pytest.skip("data format 'channels first' is possible only in GPU mode") @@ -63,6 +67,10 @@ def test_Decomon_conv_box(data_format, mode, dc_decomp, floatx, decimal, helpers def test_Decomon_conv_to_decomon_box(shared, floatx, dc_decomp, helpers): + # xfail unavailable combinations + if floatx == 16 and keras_config.backend() == "torch": + pytest.xfail("Pytorch does not implement conv2d for float16") + data_format = "channels_last" odd, m_0, m_1 = 0, 0, 1 dc_decomp = True diff --git a/tests/test_pooling.py b/tests/test_pooling.py index f87cbfad..a0cdf295 100644 --- a/tests/test_pooling.py +++ b/tests/test_pooling.py @@ -1,10 +1,15 @@ import keras.config as keras_config +import pytest from keras.layers import MaxPooling2D from decomon.layers.maxpooling import DecomonMaxPooling2D def test_MaxPooling2D_box(mode, floatx, decimal, helpers): + # xfail unavailable combinations + # if floatx == 16 and keras_config.backend() == "torch": + # pytest.xfail("Pytorch does not implement maxpooling for float16") + odd, m_0, m_1 = 0, 0, 1 data_format = "channels_last" dc_decomp = True diff --git a/tests/test_utils_conv.py b/tests/test_utils_conv.py index 0f0979d3..7d9beb1a 100644 --- a/tests/test_utils_conv.py +++ b/tests/test_utils_conv.py @@ -1,6 +1,5 @@ # Test unit for decomon with Dense layers - - +import keras.config import keras.ops as K import numpy as np import pytest @@ -13,6 +12,10 @@ def test_toeplitz_from_Keras(channels, filter_size, strides, flatten, data_format, padding, floatx, decimal, helpers): + # xfail unavailable combinations + if floatx == 16 and keras.config.backend() == "torch": + pytest.xfail("Pytorch does not implement conv2d for float16") + # filter_size, strides, flatten, if floatx == 16: decimal = 0 @@ -67,6 +70,10 @@ def test_toeplitz_from_Keras(channels, filter_size, strides, flatten, data_forma def test_toeplitz_from_Decomon( floatx, decimal, mode, channels, filter_size, strides, flatten, data_format, padding, helpers ): + # xfail unavailable combinations + if floatx == 16 and keras.config.backend() == "torch": + pytest.xfail("Pytorch does not implement conv2d for float16") + if data_format == "channels_first" and not helpers.in_GPU_mode(): pytest.skip("data format 'channels first' is possible only in GPU mode")