| @@ -1 +1 @@ | |||||
| Subproject commit 94cb709ecaf5d1d869883dfe80cee7497dd0692c | |||||
| Subproject commit e2a0a264a0be549b51a035e5f783927052f8ead8 | |||||
| @@ -297,10 +297,14 @@ install( | |||||
| if((ENABLE_D OR ENABLE_GPU) AND ENABLE_AKG) | if((ENABLE_D OR ENABLE_GPU) AND ENABLE_AKG) | ||||
| set (AKG_PATH ${CMAKE_SOURCE_DIR}/build/mindspore/akg) | set (AKG_PATH ${CMAKE_SOURCE_DIR}/build/mindspore/akg) | ||||
| file(REMOVE_RECURSE ${AKG_PATH}/_akg) | |||||
| file(MAKE_DIRECTORY ${AKG_PATH}/_akg) | |||||
| file(TOUCH ${AKG_PATH}/_akg/__init__.py) | |||||
| install(DIRECTORY "${AKG_PATH}/akg" DESTINATION "${AKG_PATH}/_akg") | |||||
| install( | install( | ||||
| DIRECTORY | DIRECTORY | ||||
| ${AKG_PATH}/akg | |||||
| DESTINATION ${INSTALL_PY_DIR}/.. | |||||
| ${AKG_PATH}/_akg | |||||
| DESTINATION ${INSTALL_PY_DIR}/ | |||||
| COMPONENT mindspore | COMPONENT mindspore | ||||
| ) | ) | ||||
| endif() | endif() | ||||
| @@ -18,6 +18,22 @@ import shutil | |||||
| import subprocess | import subprocess | ||||
| import sys | import sys | ||||
| from multiprocessing import Pool, cpu_count | from multiprocessing import Pool, cpu_count | ||||
| import importlib | |||||
| def get_akg_path(): | |||||
| """get akg directory base path""" | |||||
| search_res = importlib.util.find_spec("mindspore") | |||||
| if search_res is None: | |||||
| raise RuntimeError("Cannot find mindspore module!") | |||||
| res_path = search_res.origin | |||||
| find_pos = res_path.find("__init__.py") | |||||
| if find_pos == -1: | |||||
| raise RuntimeError("Find module mindspore origin file failed!") | |||||
| akg_path = "{}_akg".format(res_path[:find_pos]) | |||||
| if not os.path.isdir(akg_path): | |||||
| raise RuntimeError("Cannot find akg from mindspore module!") | |||||
| return akg_path | |||||
| def copy_json(pid_path, ppid_path): | def copy_json(pid_path, ppid_path): | ||||
| """ | """ | ||||
| @@ -36,7 +52,7 @@ def _compile_akg_task_gpu(*json_strs): | |||||
| Parameters: | Parameters: | ||||
| json_strs: list. List contains multiple kernel infos, suitable for json compile api. | json_strs: list. List contains multiple kernel infos, suitable for json compile api. | ||||
| """ | """ | ||||
| sys.path.insert(0, get_akg_path()) | |||||
| p = __import__("akg", globals(), locals(), ['ms'], 0) | p = __import__("akg", globals(), locals(), ['ms'], 0) | ||||
| func = getattr(p.ms, "compilewithjson") | func = getattr(p.ms, "compilewithjson") | ||||
| @@ -13,7 +13,25 @@ | |||||
| # limitations under the License. | # limitations under the License. | ||||
| # ============================================================================ | # ============================================================================ | ||||
| """Providing akg compile with json""" | """Providing akg compile with json""" | ||||
| import importlib | |||||
| import os | |||||
| import sys | import sys | ||||
| def get_akg_path(): | |||||
| """get akg directory base path""" | |||||
| search_res = importlib.util.find_spec("mindspore") | |||||
| if search_res is None: | |||||
| raise RuntimeError("Cannot find mindspore module!") | |||||
| res_path = search_res.origin | |||||
| find_pos = res_path.find("__init__.py") | |||||
| if find_pos == -1: | |||||
| raise RuntimeError("Find module mindspore origin file failed!") | |||||
| akg_path = "{}_akg".format(res_path[:find_pos]) | |||||
| if not os.path.isdir(akg_path): | |||||
| raise RuntimeError("Cannot find akg from mindspore module!") | |||||
| return akg_path | |||||
| def run_compiler(op_json): | def run_compiler(op_json): | ||||
| """ | """ | ||||
| Run AKG compiler to compile op with subprocess, if this process of | Run AKG compiler to compile op with subprocess, if this process of | ||||
| @@ -25,6 +43,7 @@ def run_compiler(op_json): | |||||
| Returns: | Returns: | ||||
| None | None | ||||
| """ | """ | ||||
| sys.path.insert(0, get_akg_path()) | |||||
| p = __import__("akg", globals(), locals(), ['ms'], 0) | p = __import__("akg", globals(), locals(), ['ms'], 0) | ||||
| func = getattr(p.ms, "compilewithjson") | func = getattr(p.ms, "compilewithjson") | ||||
| res = func(op_json) | res = func(op_json) | ||||
| @@ -179,7 +179,7 @@ class BuildPy(build_py): | |||||
| super().run() | super().run() | ||||
| mindspore_dir = os.path.join(pkg_dir, 'build', 'lib', 'mindspore') | mindspore_dir = os.path.join(pkg_dir, 'build', 'lib', 'mindspore') | ||||
| update_permissions(mindspore_dir) | update_permissions(mindspore_dir) | ||||
| mindspore_dir = os.path.join(pkg_dir, 'build', 'lib', 'akg') | |||||
| mindspore_dir = os.path.join(pkg_dir, 'build', 'lib', 'mindspore', '_akg') | |||||
| update_permissions(mindspore_dir) | update_permissions(mindspore_dir) | ||||