oliver module loader

pull/2787/head
Vladimir Mandic 2024-02-01 14:54:43 -05:00
parent 48e4a41618
commit a4e1fc7b31
3 changed files with 16 additions and 7 deletions

View File

@ -186,8 +186,6 @@ if __name__ == "__main__":
except Exception:
pass
installer.read_options()
from modules.onnx_impl import initialize_olive
initialize_olive()
if args.skip_all:
args.quick = True
installer.check_python()

View File

@ -22,6 +22,7 @@ try:
errors.log.debug(f'Load IPEX=={ipex.__version__}')
except Exception:
pass
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
warnings.filterwarnings(action="ignore", category=UserWarning, module="torchvision")
import torchvision # pylint: disable=W0611,C0411
@ -36,6 +37,10 @@ if ".dev" in torch.__version__ or "+git" in torch.__version__:
torch.__version__ = re.search(r'[\d.]+[\d]', torch.__version__).group(0)
timer.startup.record("torch")
from modules.onnx_impl import initialize_olive # pylint: disable=ungrouped-imports
initialize_olive()
timer.startup.record("olive")
from fastapi import FastAPI # pylint: disable=W0611,C0411
import gradio # pylint: disable=W0611,C0411
timer.startup.record("gradio")

View File

@ -175,18 +175,24 @@ def initialize():
def initialize_olive():
global run_olive_workflow # pylint: disable=global-statement
from installer import installed, log
if not installed("olive-ai"):
return
global run_olive_workflow # pylint: disable=global-statement
import sys
import importlib
orig_sys_path = sys.path
try:
from olive.workflows import run as run_olive_workflow # pylint: disable=redefined-outer-name
spec = importlib.util.find_spec('onnxruntime.transformers')
sys.path = [d for d in spec.submodule_search_locations + sys.path if sys.path[1] not in d]
from onnxruntime.transformers import convert_generation # pylint: disable=unused-import
spec = importlib.util.find_spec('olive')
sys.path = spec.submodule_search_locations + sys.path
run_olive_workflow = importlib.import_module('olive.workflows').run
except Exception as e:
run_olive_workflow = None
log.error(f'Olive: Failed to load olive-ai: {e}')
sys.path = orig_sys_path
def install_olive():