Skip to content

Commit 7c0fc69

Browse files
committed
Fix incompatible types in assignment
Fix: ms_mo/quant/quantizers.py:3933: error: Incompatible types in assignment (expression has type "int | float", variable has type "Tensor") [assignment] fms_mo/quant/quantizers.py:3945: error: Incompatible types in assignment (expression has type "float", variable has type "Tensor | None") [assignment] fms_mo/quant/quantizers.py:3947: error: Incompatible types in assignment (expression has type "Any | int", variable has type "Tensor | None") [assignment] fms_mo/quant/quantizers.py:4190: error: Incompatible types in assignment (expression has type "Parameter", variable has type "None") [assignment] fms_mo/quant/quantizers.py:4196: error: Incompatible types in assignment (expression has type "Size", variable has type "list[Any]") [assignment] fms_mo/modules/linear.py:1341: error: Incompatible types in assignment (expression has type "tuple[int, int]", variable has type "tuple[int, int, int]") [assignment] fms_mo/utils/torchscript_utils.py:58: error: Incompatible types in assignment (expression has type "list[str] | None", variable has type "list[str]") [assignment] fms_mo/utils/qconfig_utils.py:167: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:168: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:169: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:170: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:171: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:172: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:173: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:174: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:175: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:176: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:178: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:179: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:180: error: Incompatible types in assignment (expression has type "tuple[float, float]", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:183: error: Incompatible types in assignment (expression has type "list[Never]", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:184: error: Incompatible types in assignment (expression has type "list[Never]", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:188: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:189: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:190: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:191: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:192: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:193: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:194: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:195: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:196: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:197: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:199: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:203: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:204: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:205: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:206: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:207: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:208: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:210: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:213: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:214: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:215: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:216: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:217: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:218: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:219: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:220: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:221: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:222: error: Incompatible types in assignment (expression has type "float", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:223: error: Incompatible types in assignment (expression has type "float", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:224: error: Incompatible types in assignment (expression has type "float", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:226: error: Incompatible types in assignment (expression has type "list[Never]", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:227: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:228: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:229: error: Incompatible types in assignment (expression has type "str", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:230: error: Incompatible types in assignment (expression has type "list[Never]", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:237: error: Incompatible types in assignment (expression has type "None", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:238: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:239: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:240: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:243: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:244: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:245: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:246: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:247: error: Incompatible types in assignment (expression has type "list[Never]", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:248: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:249: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:250: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:251: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:252: error: Incompatible types in assignment (expression has type "bool", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:253: error: Incompatible types in assignment (expression has type "int", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/utils/qconfig_utils.py:257: error: Incompatible types in assignment (expression has type "float", target has type "dict[type, dict[str, type]]") [assignment] fms_mo/quant/ptq.py:2646: error: Incompatible types in assignment (expression has type "tuple[type[Conv2d], type[Linear]]", variable has type "tuple[type[Conv2d], type[Linear], type[DetQConv2d]]") [assignment] Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
1 parent 7f748af commit 7c0fc69

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

fms_mo/quant/ptq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2643,7 +2643,7 @@ def reset_bn(module: nn.BatchNorm2d):
26432643
bn_affine = True # FrozenBN doesn't have .affine property
26442644
except:
26452645
BNofInteret = (nn.BatchNorm2d, nn.BatchNorm1d)
2646-
AbsorbLayers = (nn.Conv2d, nn.Linear)
2646+
AbsorbLayers = (nn.Conv2d, nn.Linear) # type: ignore[assignment]
26472647

26482648

26492649
def search_fold_and_remove_bn(model, mod_folded):

fms_mo/quant/quantizers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4035,7 +4035,7 @@ def __init__(
40354035
self.reset_ReSig_param(multimodal)
40364036

40374037
self.beta = 2 / 3
4038-
self.Wshape: list[Any] = list()
4038+
self.Wshape: list[int] = list()
40394039
self.reshape2: list[Any] = list()
40404040

40414041
def forward(self, x):

fms_mo/utils/qconfig_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Standard
1717
from pathlib import Path
18-
from typing import Any
18+
from typing import Any, Dict
1919
import json
2020
import logging
2121
import os
@@ -149,7 +149,7 @@ def qconfig_init(recipe: str = None, args: Any = None):
149149
otherwise use constantLR as default
150150
"""
151151

152-
qcfg = {}
152+
qcfg: Dict[str, Any] = {}
153153
# 1. create a dict with default values
154154
qcfg["mapping"] = {
155155
nn.Conv2d: {"from": nn.Conv2d, "to": QConv2d, "otherwise": QConv2d},

fms_mo/utils/torchscript_utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def parse_operation(op_str: str):
5555
operands = op_str[
5656
last_open_parenthesis_index + 1 : last_close_parenthesis_index
5757
].split(",")
58-
operands = [operand.strip() for operand in operands] if operands != [""] else None
58+
# pylint: disable=line-too-long
59+
operands = [operand.strip() for operand in operands] if operands != [""] else None # type: ignore[assignment]
5960
return operator, operands
6061

6162

0 commit comments

Comments
 (0)