Skip to content

Commit

Permalink
universal init
Browse files Browse the repository at this point in the history
  • Loading branch information
mryzhov committed Nov 20, 2023
1 parent d25a17a commit 372819e
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import openvino
from openvino.runtime.utils.node_factory import NodeFactory

Expand All @@ -10,13 +11,24 @@
from .str_pack import pack_strings, unpack_strings
from .utils import add_greedy_decoding, connect_models

_extension_path = os.path.join(os.path.dirname(__file__), "libs", "libuser_ov_extensions.so")
_ext_libs_path = os.path.join(os.path.dirname(__file__), "libs")
_ext_path = os.path.join(_ext_libs_path, "libuser_ov_extensions.so")

if sys.platform == "win32":
_ext_path = os.path.join(_ext_libs_path, "libuser_ov_extensions.dll")
if os.path.isdir(_ext_libs_path):
# On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.
os.add_dll_directory(os.path.abspath(_ext_path))
else:
sys.exit(f'Error: extention libriary path {_ext_libs_path} not found')
elif sys.platform == "darwin":
_ext_path = os.path.join(_ext_libs_path, "libuser_ov_extensions.dylib")

old_core_init = openvino.runtime.Core.__init__
def new_core_init(self, *k, **kw):
old_core_init(self, *k, **kw)
self.add_extension(_extension_path)
self.add_extension(_ext_path)
openvino.runtime.Core.__init__ = new_core_init

_factory = NodeFactory()
_factory.add_extension(_extension_path)
_factory.add_extension(_ext_path)

0 comments on commit 372819e

Please sign in to comment.