diff --git a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py index da4942bb5a7..72b114e9eee 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py @@ -77,7 +77,7 @@ class TorchScriptPythonDecoder (Decoder): preserved_attributes = [] for name, module in model.named_modules(): if hasattr(module, "weight"): - if module.weight.dtype in [torch.int8, torch.uint8]: + if module.weight is not None and module.weight.dtype in [torch.int8, torch.uint8]: preserved_attributes.append(name) return preserved_attributes @@ -176,7 +176,7 @@ class TorchScriptPythonDecoder (Decoder): first_input = next(n.inputs()) if first_input.node().kind() == "prim::Constant": ivalue = first_input.toIValue() - if ivalue is not None and ivalue.dtype in [torch.bfloat16, torch.float16]: + if isinstance(ivalue, torch.Tensor) and ivalue.dtype in [torch.bfloat16, torch.float16]: # do not freeze models with compressed constants skip_freeze = True break