diff --git a/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py index a79892b3e4d..479e1a5cb1c 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py @@ -7,10 +7,9 @@ from openvino.frontend.pytorch.py_pytorch_frontend import _FrontEndPytorchDecoder as Decoder from openvino.frontend.pytorch.py_pytorch_frontend import _Type as DecoderType from openvino.runtime import op, PartialShape, Type as OVType, OVAny, Shape -from openvino.frontend.pytorch.utils import maybe_convert_max_int, make_constant, fetch_attr, pt_to_ov_type_map, ov_to_c_type_map +from openvino.frontend.pytorch.utils import maybe_convert_max_int, make_constant, fetch_attr, pt_to_ov_type_map import torch -import ctypes class TorchFXPythonDecoder (Decoder): @@ -224,11 +223,7 @@ class TorchFXPythonDecoder (Decoder): if self.pt_module.op == 'get_attr': # Extract Constant from FX module field ret = fetch_attr(self.fx_gm, self.pt_module.target) - ovshape = PartialShape(ret.size()) - ovtype = pt_to_ov_type_map[str(ret.type())] - c_type = ctypes.POINTER(ov_to_c_type_map[ovtype]) - data_c_ptr = ctypes.cast(ret.data_ptr(), c_type) - ov_const = op.Constant(ovtype, ovshape.get_shape(), data_c_ptr[:ret.nelement()]) + ov_const = op.Constant(ret.numpy(), shared_memory=True) return ov_const.outputs() diff --git a/src/bindings/python/src/openvino/frontend/pytorch/utils.py b/src/bindings/python/src/openvino/frontend/pytorch/utils.py index 97d237fb0ef..a3ac46e7011 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/utils.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/utils.py @@ -7,7 +7,6 @@ import torch import numpy as np -import ctypes from openvino.runtime import op, Type as OVType, Shape, Tensor from openvino.runtime import opset11 as ops @@ -132,13 +131,6 @@ pt_to_ov_type_map = { "torch.qint32": OVType.i32 } -ov_to_c_type_map = { - OVType.f32: ctypes.c_float, - OVType.f64: ctypes.c_double, - OVType.i32: ctypes.c_int, - OVType.i64: ctypes.c_int64, -} - wrapper_template = """ import torch