Skip to content

Commit

Permalink
[PT FE] Report about FakeTensor during conversion (#27203)
Browse files Browse the repository at this point in the history
**Details:** Report about FakeTensor during conversion

**Ticket:** 149989

---------

Signed-off-by: Kazantsev, Roman <[email protected]>
Co-authored-by: Maxim Vafin <[email protected]>
  • Loading branch information
rkazants and mvafin authored Oct 23, 2024
1 parent ca926d6 commit 6458855
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bindings/python/src/openvino/frontend/pytorch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def get_type_from_py_type(value):


def torch_tensor_to_ov_const(torch_t: torch.Tensor, shared_memory=True):
is_fake_tensor = False
try:
from torch._prims import FakeTensor
is_fake_tensor = isinstance(torch_t, FakeTensor)
except:
pass
assert not is_fake_tensor, '`FakeTensor` is found in the graph during conversion. ' \
'In order to avoid `FakeTensor` in the traced model, ' \
'try to infer the model before exporting.'
torch_t = torch_t.contiguous()
if torch_t.dtype == torch.bfloat16:
# reinterpret bfloat16 data as float16 to allow conversion to numpy
Expand Down

0 comments on commit 6458855

Please sign in to comment.