aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/test/test_graph_optimiser.py
diff options
context:
space:
mode:
authorPatrik Gustavsson <patrik.gustavsson@arm.com>2021-06-28 07:41:58 +0200
committerPatrik Gustavsson <patrik.gustavsson@arm.com>2021-07-08 10:57:25 +0200
commit8f1f9aaa58175b17cd2e505bfcdb0e40c955ea72 (patch)
tree0174f8ef15007f5e220cfc4d283046451282102e /ethosu/vela/test/test_graph_optimiser.py
parent6f4955aa7097b123bbf31aae4654547bb3e3c68c (diff)
downloadethos-u-vela-8f1f9aaa58175b17cd2e505bfcdb0e40c955ea72.tar.gz
MLBEDSW-4838 Added basic TOSA support.
Added basic TOSA support, enabling Vela to read and compile a .tosa file corresponding to CONV2D + Rescale + Clamp, and writing it to an optimized .tflite file. The optimized .tflite file, will in this case, hold a commandstream where the Rescale and Clamp has been fused into the CONV2D. The optimized tflite file is not output from Vela. -Added support to read .tosa file into Vela internal structure. - Added tosa_reader.py, tosa_mapper.py and helper files stored under tosa/ - Support for this limited to ~10 ops -Added reader_util.py for functions common for TOSA and TFLite -Added tosa_graph_optimiser.py -Added support to fuse Rescale into convolution -Modified handling for padding -Added support to fuse Clamp to previous op -Added graph_optimiser_util.py -Moved functions common for TOSA/TFLite graph optimization to this file. -Renamed graph_optimiser.py to tflite_graph_optmiser.py -Added separate tosa_supported_operators.py -Added supported_operator_util.py -For functions in common for TOSA/TFLite Signed-off-by: Patrik Gustavsson <patrik.gustavsson@arm.com> Change-Id: Ic3c540504ec8c5eb4771397fdc6882050ecf33ab
Diffstat (limited to 'ethosu/vela/test/test_graph_optimiser.py')
-rw-r--r--ethosu/vela/test/test_graph_optimiser.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/ethosu/vela/test/test_graph_optimiser.py b/ethosu/vela/test/test_graph_optimiser.py
index 83a3dda6..b37bac80 100644
--- a/ethosu/vela/test/test_graph_optimiser.py
+++ b/ethosu/vela/test/test_graph_optimiser.py
@@ -15,17 +15,14 @@
# limitations under the License.
#
# Description:
-# Unit tests for graph_optimiser
+# Unit tests for tflite_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 replace_pad_by_hw_pad
-from ethosu.vela.graph_optimiser import rewrite_fully_connected_input
+from ethosu.vela.graph_optimiser import optimise_graph
from ethosu.vela.nn_graph import Graph
+from ethosu.vela.nn_graph import NetworkType
from ethosu.vela.operation import Op
from ethosu.vela.operation import Padding
from ethosu.vela.rewrite_graph import verify_graph_health
@@ -33,6 +30,10 @@ from ethosu.vela.tensor import create_const_tensor
from ethosu.vela.tensor import Shape4D
from ethosu.vela.tensor import Tensor
from ethosu.vela.test import testutil
+from ethosu.vela.tflite_graph_optimiser import calc_explicit_padding
+from ethosu.vela.tflite_graph_optimiser import convert_batched_fc_shape
+from ethosu.vela.tflite_graph_optimiser import replace_pad_by_hw_pad
+from ethosu.vela.tflite_graph_optimiser import rewrite_fully_connected_input
def test_convert_batched_fc():
@@ -300,7 +301,7 @@ def test_pad_followed_by_avg_pool(k_size, padding, expect_pad_removed):
pool_op.run_on_npu = True
nng = testutil.create_graph([pad_op, pool_op])
arch = testutil.create_arch()
- nng = optimise_graph_a(nng, arch)
+ nng = optimise_graph(nng, arch, NetworkType.TFLite)
sg = nng.subgraphs[0]
all_ops = sg.get_all_ops()
print("all_ops: ", all_ops)
@@ -382,7 +383,7 @@ def test_remove_reshape():
nng, reshape1_op, conv2d_op, reshape2_op = setup_network()
arch = testutil.create_arch()
assert verify_graph_health(nng)
- nng = optimise_graph_a(nng, arch)
+ nng = optimise_graph(nng, arch, NetworkType.TFLite)
assert verify_graph_health(nng)
# Test2 reshape1 with different quantisation, this Reshape op is expected to remain
@@ -393,5 +394,5 @@ def test_remove_reshape():
quant_zp32.zero_point = 32
reshape1_op.ofm.quantization = quant_zp32
assert verify_graph_health(nng)
- nng = optimise_graph_a(nng, arch)
+ nng = optimise_graph(nng, arch, NetworkType.TFLite)
assert verify_graph_health(nng)