diff options
author | Patrik Gustavsson <patrik.gustavsson@arm.com> | 2021-06-30 09:07:16 +0200 |
---|---|---|
committer | Patrik Gustavsson <patrik.gustavsson@arm.com> | 2021-07-09 09:51:44 +0200 |
commit | 5e26eda0e0f359b6e22b1f1eeb9344cd15e0f093 (patch) | |
tree | dce92ab9d8a6ceb261c48353ff7077295efa21da /ethosu/vela/test/test_tflite_reader.py | |
parent | 8f1f9aaa58175b17cd2e505bfcdb0e40c955ea72 (diff) | |
download | ethos-u-vela-5e26eda0e0f359b6e22b1f1eeb9344cd15e0f093.tar.gz |
MLBEDSW-4840 Move setting of input indices to tflite reader
Mapping to internal input indexing has been added to
tflite_reader.py and tosa_reader.py.
And the other way around in tflite_writer.py.
Signed-off-by: Patrik Gustavsson <patrik.gustavsson@arm.com>
Change-Id: I4d8596e747cfa7c4203884c4e785eb1977e2bcc1
Diffstat (limited to 'ethosu/vela/test/test_tflite_reader.py')
-rw-r--r-- | ethosu/vela/test/test_tflite_reader.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/ethosu/vela/test/test_tflite_reader.py b/ethosu/vela/test/test_tflite_reader.py index a69e8d37..664a58c6 100644 --- a/ethosu/vela/test/test_tflite_reader.py +++ b/ethosu/vela/test/test_tflite_reader.py @@ -23,6 +23,8 @@ import pytest from ethosu.vela.operation import Op from ethosu.vela.tflite.TensorType import TensorType +from ethosu.vela.tflite_mapping import TFLITE_CONV2D_BACKPROP_INDICES +from ethosu.vela.tflite_mapping import TFLITE_IFM_WEIGHTS_BIAS_INDICES from ethosu.vela.tflite_reader import TFLiteSubgraph @@ -43,23 +45,25 @@ class TestTFLiteSubgraph: assert output == expected parse_op_testdata = [ - # op_type, opt_serializer, inputs, output, expected - (Op.FullyConnected, None, [0, 1, 2], 3, 3), # FC - (Op.FullyConnected, None, [0, 1, -1], 3, 3), # FC disabled Bias - (Op.FullyConnected, None, [0, 1], 3, 3), # FC no Bias - (Op.Conv2D, None, [2, 1, 3], 0, 3), # Conv2D - (Op.Conv2DBackpropInput, None, [0, 1, 2, 3], 4, 4), # TransposeConv - (Op.Conv2DBackpropInput, None, [0, 1, 2], 4, 4), # TransposeConv no Bias - pytest.param(Op.Conv2D, None, [0, -1, 1], 3, 3, marks=pytest.mark.xfail), # Conv2D no Weights + # op_type, opt_serializer, indices, inputs, output, expected + (Op.FullyConnected, None, TFLITE_IFM_WEIGHTS_BIAS_INDICES, [0, 1, 2], 3, 3), # FC + (Op.FullyConnected, None, TFLITE_IFM_WEIGHTS_BIAS_INDICES, [0, 1, -1], 3, 3), # FC disabled Bias + (Op.FullyConnected, None, TFLITE_IFM_WEIGHTS_BIAS_INDICES, [0, 1], 3, 3), # FC no Bias + (Op.Conv2DBias, None, TFLITE_IFM_WEIGHTS_BIAS_INDICES, [2, 1, 3], 0, 3), # Conv2D + (Op.Conv2DBackpropInput, None, TFLITE_CONV2D_BACKPROP_INDICES, [0, 1, 2, 3], 4, 4), # TransposeConv + (Op.Conv2DBackpropInput, None, TFLITE_CONV2D_BACKPROP_INDICES, [0, 1, 2], 4, 4), # TransposeConv no Bias + pytest.param( + Op.Conv2DBias, None, TFLITE_IFM_WEIGHTS_BIAS_INDICES, [0, -1, 1], 3, 3, marks=pytest.mark.xfail + ), # Conv2D no Weights ] - @pytest.mark.parametrize("op_type, opt_serializer, inputs, output, expected", parse_op_testdata) - def test_parse_operator(self, op_type, opt_serializer, inputs, output, expected): + @pytest.mark.parametrize("op_type, opt_serializer, indices, inputs, output, expected", parse_op_testdata) + def test_parse_operator(self, op_type, opt_serializer, indices, inputs, output, expected): with patch.object(TFLiteSubgraph, "__init__", lambda self, graph, subraph: None): # Mock a TFLiteSubGraph sg = TFLiteSubgraph(None, None) sg.graph = MagicMock() - sg.graph.operator_codes = [(op_type, opt_serializer, "")] + sg.graph.operator_codes = [(op_type, opt_serializer, "", indices)] # Mock a couple of tensors sg.tensors = [MagicMock() for _ in range(5)] |