aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/softmax.py
diff options
context:
space:
mode:
authorLouis Verhaard <louis.verhaard@arm.com>2021-02-09 16:08:26 +0100
committerLouis Verhaard <louis.verhaard@arm.com>2021-02-17 16:29:20 +0100
commit1a92f78e14f31f1423824228deb0628b7a9a9071 (patch)
tree4e0de9a2e6b5b7d9159b25cbfead4a625c134a3c /ethosu/vela/softmax.py
parent8d0f4890aa0ceae92a33ebb789701ff644a6fcaa (diff)
downloadethos-u-vela-1a92f78e14f31f1423824228deb0628b7a9a9071.tar.gz
MLBEDSW-4022: support PAD followed by pool operator
PAD followed by max/average pool is run on NPU if NPU padding can be used. Average pool is converted to depthwise. Change-Id: Icc3652e6d9ecff5ac3dc7d92080313d90c245404 Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
Diffstat (limited to 'ethosu/vela/softmax.py')
-rw-r--r--ethosu/vela/softmax.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/ethosu/vela/softmax.py b/ethosu/vela/softmax.py
index 4418f011..520ec23e 100644
--- a/ethosu/vela/softmax.py
+++ b/ethosu/vela/softmax.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
+# Copyright (C) 2020-2021 Arm Limited or its affiliates. All rights reserved.
#
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
@@ -287,11 +287,9 @@ class SoftMax:
shift = create_const_tensor(
f"{name}_const", [1, 1, 1, 1], DataType.int32, [12], np.int32, quantization=no_scale_quant
)
- rescaled_exp = add_op_get_ofm(
- create_shr(
- name, ifm_exp, shift, no_scale_quant, activation, attrs={"rounding_mode": NpuRoundingMode.NATURAL},
- )
- )
+ shr_op = create_shr(name, ifm_exp, shift, no_scale_quant, activation)
+ shr_op.rounding_mode = NpuRoundingMode.NATURAL
+ rescaled_exp = add_op_get_ofm(shr_op)
# PASS 3 - Reduce sum
sum_of_exp = add_op_get_ofm(
@@ -421,7 +419,7 @@ class SoftMax:
# PASS 30 - SHR
shr30_op = Operation(Op.SHR, f"{self.op.name}_shr{pass_number}")
- shr30_op.attrs["rounding_mode"] = NpuRoundingMode.NATURAL
+ shr30_op.rounding_mode = NpuRoundingMode.NATURAL
shr30_op.add_input_tensor(scaled_exp)
shr30_op.add_input_tensor(right_shift)
shr30_op.set_output_tensor(ofm)