forked from mindspore-Ecosystem/mindspore
!27027 [GraphKernel] fix python path for ascend compiler.
Merge pull request !27027 from chenlei_autodiff/gk_lite
This commit is contained in:
commit
4fdcb21f06
|
@ -27,7 +27,7 @@ def run_compiler(op_json, attrs=None):
|
|||
Returns:
|
||||
None
|
||||
"""
|
||||
from .get_file_path import get_akg_path
|
||||
from get_file_path import get_akg_path
|
||||
sys.path.insert(0, get_akg_path())
|
||||
p = __import__("akg", globals(), locals(), ['ms'], 0)
|
||||
func = getattr(p.ms, "compilewithjson")
|
||||
|
@ -35,18 +35,6 @@ def run_compiler(op_json, attrs=None):
|
|||
if not res:
|
||||
raise ValueError("Compile error")
|
||||
|
||||
def run_compiler_with_json_name(op_json_name, attrs=None):
|
||||
"""
|
||||
Run AKG compiler with json file name
|
||||
|
||||
Args:
|
||||
op_json_name (str): json file name of the op
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
with open(op_json_name, 'r') as f:
|
||||
return run_compiler(f.read().strip(), attrs)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 2:
|
||||
|
|
|
@ -35,8 +35,12 @@ namespace mindspore::graphkernel {
|
|||
bool CompileSingleJson(const std::string &json_name) {
|
||||
std::string attrs = "None";
|
||||
std::ostringstream py_cmd;
|
||||
py_cmd << "from mindspore._extends.parallel_compile.akg_compiler.compiler import run_compiler_with_json_name\n";
|
||||
py_cmd << "run_compiler_with_json_name(\'" << json_name << "\', " << attrs << ")";
|
||||
py_cmd << "from mindspore._extends.parallel_compile.akg_compiler.get_file_path import get_akg_path\n";
|
||||
py_cmd << "import sys\n";
|
||||
py_cmd << "sys.path.insert(0, get_akg_path())\n";
|
||||
py_cmd << "from akg.ms import compilewithjsonname\n";
|
||||
py_cmd << "if not compilewithjsonname(\'" << json_name << "\', " << attrs << "):\n";
|
||||
py_cmd << " raise RuntimeError(\'Compile fail for json: " << json_name << "\')";
|
||||
std::string cmd = "python -c \"" + py_cmd.str() + "\"";
|
||||
auto ret = system(cmd.c_str());
|
||||
if (!WIFEXITED(ret)) {
|
||||
|
|
Loading…
Reference in New Issue