[mpact][compiler] enable clients to set opt level and support library Done through the enviroment. For example export OPT_LEVEL=3 epport SUPPORT_LIB=<path to lib.so>
diff --git a/python/mpact/mpactbackend.py b/python/mpact/mpactbackend.py index 80b58df..2a01af2 100644 --- a/python/mpact/mpactbackend.py +++ b/python/mpact/mpactbackend.py
@@ -1,5 +1,6 @@ import ctypes import numpy as np +import os import torch from typing import Any, Callable, Optional, Tuple, Dict @@ -17,6 +18,11 @@ LinalgOnTensorsBackend, ) +# One time set up of support library and optimization level. +SUPPORT_LIB = os.getenv("SUPPORT_LIB", default=None) +SHARED_LIBS = [ ] if SUPPORT_LIB is None else [ SUPPORT_LIB ] +OPT_LEVEL = int(os.getenv("OPT_LEVEL", default=2)) + def assert_arg_type_is_supported(ty): SUPPORTED = [ @@ -95,8 +101,10 @@ class MpactBackendInvoker: - def __init__(self, module, opt_level=2, shared_libs=[]): - self.ee = ExecutionEngine(module, opt_level=opt_level, shared_libs=shared_libs) + def __init__(self, module): + self.ee = ExecutionEngine( + module, opt_level=OPT_LEVEL, shared_libs=SHARED_LIBS + ) self.result = None return_funcs = get_return_funcs(module)