diff options
author | Louis Verhaard <louis.verhaard@arm.com> | 2021-01-27 15:57:57 +0100 |
---|---|---|
committer | patrik.gustavsson <patrik.gustavsson@arm.com> | 2021-02-01 16:44:39 +0000 |
commit | ebf4af6a45c60d3f75ccd6019612a7f8b6552d72 (patch) | |
tree | 79a84e13a59ee8c0c4e11aa7bb0fe008f4a4ab29 /ethosu/vela/test/test_graph_optimiser.py | |
parent | 189f748e1a79ed88044efbe7137963bca830cbb5 (diff) | |
download | ethos-u-vela-ebf4af6a45c60d3f75ccd6019612a7f8b6552d72.tar.gz |
MLBEDSW-3903: Bug fix PAD operator
- Added checks for unsupported pad sizes in PAD operator
- Bug fix right pad/bottom pad calculation when replacing PAD operator
by hardware padding
Change-Id: Ib84be711277d987052f14352ab386e0e0b774987
Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
Diffstat (limited to 'ethosu/vela/test/test_graph_optimiser.py')
-rw-r--r-- | ethosu/vela/test/test_graph_optimiser.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ethosu/vela/test/test_graph_optimiser.py b/ethosu/vela/test/test_graph_optimiser.py index 55980e3d..4281d314 100644 --- a/ethosu/vela/test/test_graph_optimiser.py +++ b/ethosu/vela/test/test_graph_optimiser.py @@ -17,8 +17,10 @@ # Description: # Unit tests for graph_optimiser import numpy as np +import pytest from ethosu.vela.data_type import DataType +from ethosu.vela.graph_optimiser import calc_explicit_padding from ethosu.vela.graph_optimiser import convert_batched_fc_shape from ethosu.vela.graph_optimiser import optimise_graph_a from ethosu.vela.graph_optimiser import optimise_pad @@ -82,6 +84,38 @@ def test_convert_batched_fc(): assert conv_op.ifm.shape == conv_op.ofm.shape +explicit_padding_test_data = [ + # Kernel size 2 + [(17, 1, 2, 1, 1), (1, 1)], + [(18, 1, 2, 0, 1), (0, 1)], + [(18, 1, 2, 1, 0), (1, 0)], + # Kernel size 3 + [(18, 2, 3, 1, 1), (1, 0)], + [(25, 2, 3, 1, 1), (1, 1)], + # Kernel size 4 + [(18, 1, 4, 1, 2), (1, 2)], + [(18, 1, 4, 2, 1), (2, 1)], + [(19, 1, 4, 2, 2), (2, 2)], + # Kernel size 5 + [(19, 1, 5, 1, 2), (1, 2)], + [(19, 1, 5, 0, 2), (0, 2)], + [(19, 1, 5, 1, 0), (1, 0)], + # Kernel size 21 + [(41, 2, 21, 8, 10), (8, 10)], + [(41, 3, 21, 10, 10), (10, 9)], + [(42, 3, 21, 10, 10), (10, 8)], + [(42, 3, 21, 9, 10), (9, 9)], + [(41, 3, 21, 10, 6), (10, 6)], +] + + +@pytest.mark.parametrize("test_input, expected_result", explicit_padding_test_data) +def test_calc_explicit_padding(test_input, expected_result): + input_size, stride, filter_size, explicit_pad_before, explicit_pad_after = test_input + before, after = calc_explicit_padding(input_size, stride, filter_size, explicit_pad_before, explicit_pad_after) + assert (before, after) == expected_result + + def test_optimise_pad(): """ Tests that the PAD operator is bypassed when followed by a convolution operator, |