Skip to content

Commit 9d4e1ee

Browse files
authored
Arm backend: mypy fixes (#8092)
Fix mypy warnings in arm_vela.py In arm_vela.py, function vela_compile() there is a reuse of the variable block_length that was of different type between uses and mypy complained. Change name of block_length that is used inside the loop to block_length_bytes since its not a int. Fix mypy warnings in arm_model_evaluator.py Annotate a dict to fix mypy warning.
1 parent ce93291 commit 9d4e1ee

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

backends/arm/arm_vela.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ def vela_compile(tosa_graph, args: List[str], shape_order=None):
9696
block_name = block_name + b"\x00" * (16 - len(block_name))
9797

9898
# We need the acual unpadded block lengths for hw setup
99-
block_length = struct.pack("<iiii", len(bin_blocks[key]), 0, 0, 0) # type: ignore[assignment]
99+
block_length_bytes = struct.pack("<iiii", len(bin_blocks[key]), 0, 0, 0)
100100

101101
# Pad block data to multiple of 16 bytes
102102
block_data = bin_blocks[key]
103103
block_data = block_data + b"\x00" * (15 - (len(block_data) - 1) % 16)
104104

105-
block = block_name + block_length + block_data # type: ignore[operator]
105+
block = block_name + block_length_bytes + block_data
106106
blocks = blocks + block
107107

108108
return blocks

backends/arm/operators/node_visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def define_node(
4444

4545

4646
# container for all node visitors
47-
_node_visitor_dicts = { # type: ignore[var-annotated]
47+
_node_visitor_dicts: Dict[TosaSpecification, Dict] = {
4848
TosaSpecification.create_from_string("TOSA-0.80+BI"): {},
4949
TosaSpecification.create_from_string("TOSA-0.80+MI"): {},
5050
}

backends/arm/util/arm_model_evaluator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(
5959
if tosa_output_path:
6060
self.tosa_output_path = tosa_output_path
6161
else:
62-
self.tosa_output_path = None # type: ignore[assignment]
62+
self.tosa_output_path = ""
6363

6464
def get_model_error(self) -> defaultdict:
6565
"""
@@ -104,7 +104,7 @@ def get_compression_ratio(self) -> float:
104104

105105
return compression_ratio
106106

107-
def evaluate(self) -> dict[Any]: # type: ignore[type-arg]
107+
def evaluate(self) -> dict[str, Any]:
108108
model_error_dict = self.get_model_error()
109109

110110
output_metrics = {"name": self.model_name, "metrics": dict(model_error_dict)}

0 commit comments

Comments
 (0)