MLBEDSW-3367 Add mypy to pre-commit
Add mypy to pre-commit and clean up all reported errors.
Signed-off-by: Jonas Ohlsson <jonas.ohlsson@arm.com>
Change-Id: If7dc869f5fecdb0e2db40f14e7d9db21aa33df71
diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py
index fd32b65..3be2898 100644
--- a/ethosu/vela/register_command_stream_generator.py
+++ b/ethosu/vela/register_command_stream_generator.py
@@ -21,6 +21,7 @@
from collections import defaultdict
from enum import Enum
from enum import IntEnum
+from typing import cast
from typing import Dict
from typing import List
from typing import Optional
@@ -319,7 +320,7 @@
quantized_min = max(-128, quantized_min)
quantized_max = min(127, quantized_max)
else:
- activation_value = activation_op_map[act.op_type]
+ activation_value = cast(int, activation_op_map[act.op_type])
emit.cmd0_with_param(cmd0.NPU_SET_ACTIVATION, activation_value)
emit.cmd0_with_param(cmd0.NPU_SET_ACTIVATION_MIN, quantized_min)
emit.cmd0_with_param(cmd0.NPU_SET_ACTIVATION_MAX, quantized_max)
@@ -584,7 +585,7 @@
block_config,
arch,
block_type,
- npu_op.ofm.shape,
+ shape3d_to_block(npu_op.ofm.shape),
ifm_shape,
ifm2_shape,
uses_scalar,
@@ -741,6 +742,8 @@
ofm_scale, shift = scaling.elementwise_mul_scale(input_scale, input2_scale, output_scale)
emit.cmd1_with_offset(cmd1.NPU_SET_OFM_SCALE, ofm_scale, shift)
else: # Add/Sub
+ opa_scale: float
+ opb_scale: float
bitdepth = npu_op.ifm.data_type.size_in_bits()
use_advanced_scaling = False
if None in (input_scale, input2_scale, output_scale):
@@ -799,7 +802,7 @@
# -------------------------------------------------------------------
-def print_feature_map(fm: NpuFeatureMap, name: str):
+def print_feature_map(fm: Optional[NpuFeatureMap], name: str):
if fm is not None:
q = (
"no quantization"