aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_graph_optimiser.py
diff options
context:
space:
mode:
authorJohan Alfven <johan.alfven@arm.com>2023-02-02 14:59:03 +0100
committerJohan Alfven <johan.alfven@arm.com>2023-03-16 07:24:42 +0100
commita5e1b6224d8436365e7f0bdb0afef060423fba57 (patch)
tree37feca38dd91375ff3cd2f7cffad1ab18b458d90 /ethosu/vela/tflite_graph_optimiser.py
parent90724965751e882c58de74a044cc7adab307bc55 (diff)
downloadethos-u-vela-a5e1b6224d8436365e7f0bdb0afef060423fba57.tar.gz
MLBEDSW-7312: Refactoring bypass_memory_only_ops
- The logic when bypassing memory only ops is complicated and it still does not fix all corner cases. - This patch simplifies the logic by always bypassing the op by replacing the IFM with the OFM. If that is not possible the memory only op is changed to an memcpy op. - The bypassing was previously done in two steps but is now reduced to one. Change-Id: I545dd65e0ec77c70be479a5ada2d277cac3a027c Signed-off-by: Johan Alfven <johan.alfven@arm.com>
Diffstat (limited to 'ethosu/vela/tflite_graph_optimiser.py')
-rw-r--r--ethosu/vela/tflite_graph_optimiser.py15
1 files changed, 2 insertions, 13 deletions
diff --git a/ethosu/vela/tflite_graph_optimiser.py b/ethosu/vela/tflite_graph_optimiser.py
index 3a49309d..a1cbb3e2 100644
--- a/ethosu/vela/tflite_graph_optimiser.py
+++ b/ethosu/vela/tflite_graph_optimiser.py
@@ -35,7 +35,6 @@ from .graph_optimiser_util import bypass_memory_only_ops
from .graph_optimiser_util import calc_explicit_padding
from .graph_optimiser_util import convert_depthwise_to_conv
from .graph_optimiser_util import convert_to_lut
-from .graph_optimiser_util import fix_sg_input_output
from .graph_optimiser_util import memory_only_ops
from .graph_optimiser_util import move_splitsliceread_to_consumer
from .graph_optimiser_util import needed_total_padding
@@ -1362,11 +1361,6 @@ def convert_tanh_sigmoid_to_lut(op, arch, nng):
return op
-def remove_memory_only_ops(op, arch):
- if op.run_on_npu and op.type in memory_only_ops:
- bypass_memory_only_ops(op)
-
-
def fuse_activation_function_with_prev(op, arch, nng):
# if op is a no-op: attempts to move the activation function to the preceding op
if not op.attrs.get("is_nop", False) or op.activation is None:
@@ -1954,22 +1948,17 @@ def tflite_optimise_graph(nng, arch, force_symmetric_int_weights):
rewrite_unsupported=False,
)
- # Handle sg input output
+ # Bypass or rewrite memory only operators
for idx, sg in enumerate(nng.subgraphs):
nng.subgraphs[idx] = rewrite_graph.rewrite_graph_pre_order(
nng,
sg,
arch,
[],
- [fix_sg_input_output],
+ [bypass_memory_only_ops],
rewrite_unsupported=False,
)
- # Removal of memory only operators
- for sg in nng.subgraphs:
- rewrite_graph.visit_graph_post_order(sg.output_tensors, arch, [], [remove_memory_only_ops])
- sg.refresh_after_modification()
-
# Rewrite of operators
op_rewrite_list = [
set_tensor_equivalence,