From 89956b65e39e40b665db8806001cee231b04735a Mon Sep 17 00:00:00 2001 From: Ekaterina Aidova Date: Wed, 16 Aug 2023 11:30:05 +0300 Subject: [PATCH] [PT FE]: fixes type checking for freezing conditions (#19199) --- .../python/src/openvino/frontend/pytorch/ts_decoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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