aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/register_command_stream_generator.py
diff options
context:
space:
mode:
authorFredrik Svedberg <fredrik.svedberg@arm.com>2020-09-29 10:00:39 +0200
committerpatrik.gustavsson <patrik.gustavsson@arm.com>2020-09-30 07:52:39 +0000
commit0f98b361288c71fca327969346db32de098c797b (patch)
tree8b2905a6e763832a0029179d655c481b14e0a8a1 /ethosu/vela/register_command_stream_generator.py
parent0265f402c7ae1e875470298b4130fcc2f7ab4e23 (diff)
downloadethos-u-vela-0f98b361288c71fca327969346db32de098c797b.tar.gz
[MLBEDSW-2802] Fix 5D tensor crash
Fixed crash in networks with 5D tensors. Fixed crash for (int32) tensors without quantization. Added validity checks for concatenation. Moved unfusing of activation function from tflite_reader to graph_optimiser. Signed-off-by: Fredrik Svedberg <fredrik.svedberg@arm.com> Change-Id: Ib9ba8891dc95ef5491e15d0feedef44331a26393
Diffstat (limited to 'ethosu/vela/register_command_stream_generator.py')
-rw-r--r--ethosu/vela/register_command_stream_generator.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py
index acfd25a2..da9be668 100644
--- a/ethosu/vela/register_command_stream_generator.py
+++ b/ethosu/vela/register_command_stream_generator.py
@@ -483,9 +483,9 @@ def generate_register_command_stream(nng, sg, arch, verbose=False):
# Calculate scales needed for arithmetic elementwise operators
if primary_op.type in set(("AddAct", "MulAct", "SubAct",)):
- input_scale = cmd.ifm_tensor.quantization.scale_f32
- input2_scale = cmd.ifm2_tensor.quantization.scale_f32
- output_scale = ofm_quant.scale_f32
+ input_scale = cmd.ifm_tensor.quantization.scale_f32 if cmd.ifm_tensor.quantization else None
+ input2_scale = cmd.ifm2_tensor.quantization.scale_f32 if cmd.ifm2_tensor.quantization else None
+ output_scale = ofm_quant.scale_f32 if ofm_quant else None
use_global_scale = True
if output_scale is not None and faf in ("Sigmoid", "Tanh"):
@@ -803,10 +803,10 @@ def generate_register_command_stream(nng, sg, arch, verbose=False):
scale_region = base_ptr_idx_map[cmd.scale_tensor.mem_type]
emit.cmd0_with_param(cmd0.NPU_SET_SCALE_REGION, scale_region)
- ofm_quant_qmin = ofm_quant.quant_min
- ofm_quant_qmax = ofm_quant.quant_max
- ifm_min = cmd.ifm_tensor.quantization.min
- ifm_max = cmd.ifm_tensor.quantization.max
+ ofm_quant_qmin = ofm_quant.quant_min if ofm_quant else np.iinfo(np.int16).min
+ ofm_quant_qmax = ofm_quant.quant_max if ofm_quant else np.iinfo(np.int16).max
+ ifm_min = cmd.ifm_tensor.quantization.min if cmd.ifm_tensor.quantization else np.iinfo(np.int16).min
+ ifm_max = cmd.ifm_tensor.quantization.max if cmd.ifm_tensor.quantization else np.iinfo(np.int16).max
# Emit commands for any fused activation function
if faf is None: