Commit 413e2b7a by Tianqi Chen Committed by GitHub

Better error message handling for contrib (#946)

* Better error message handling for contrib

* fix lint

* fix testcase

* fix test
parent e3f6938a
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
from __future__ import absolute_import as _abs from __future__ import absolute_import as _abs
import sys import sys
import subprocess import subprocess
import os import os
from .._ffi.base import py_str
from .util import tempdir from .util import tempdir
...@@ -53,7 +54,7 @@ def _linux_shared(output, objects, options, cc="g++"): ...@@ -53,7 +54,7 @@ def _linux_shared(output, objects, options, cc="g++"):
(out, _) = proc.communicate() (out, _) = proc.communicate()
if proc.returncode != 0: if proc.returncode != 0:
msg = "Compilation error:\n" msg = "Compilation error:\n"
msg += str(out) msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
...@@ -88,7 +89,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,\ ...@@ -88,7 +89,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,\
"please run this in Vistual Studio Command Prompt.") "please run this in Vistual Studio Command Prompt.")
if proc.returncode != 0: if proc.returncode != 0:
msg = "Compilation error:\n" msg = "Compilation error:\n"
msg += str(out) msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
link_cmd = ["link"] link_cmd = ["link"]
link_cmd += ["-dll", "-FORCE:MULTIPLE"] link_cmd += ["-dll", "-FORCE:MULTIPLE"]
...@@ -114,6 +115,6 @@ BOOL APIENTRY DllMain( HMODULE hModule,\ ...@@ -114,6 +115,6 @@ BOOL APIENTRY DllMain( HMODULE hModule,\
"please run this in Vistual Studio Command Prompt.") "please run this in Vistual Studio Command Prompt.")
if proc.returncode != 0: if proc.returncode != 0:
msg = "Compilation error:\n" msg = "Compilation error:\n"
msg += str(out) msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
"""Util to invoke emscripten compilers in the system.""" """Util to invoke emscripten compilers in the system."""
# pylint: disable=invalid-name # pylint: disable=invalid-name
from __future__ import absolute_import as _abs from __future__ import absolute_import as _abs
import subprocess import subprocess
from .._ffi.base import py_str
from .._ffi.libinfo import find_lib_path from .._ffi.libinfo import find_lib_path
def create_js(output, def create_js(output,
...@@ -58,7 +60,7 @@ def create_js(output, ...@@ -58,7 +60,7 @@ def create_js(output,
if proc.returncode != 0: if proc.returncode != 0:
msg = "Compilation error:\n" msg = "Compilation error:\n"
msg += out msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
create_js.object_format = "bc" create_js.object_format = "bc"
"""Util to invoke NDK compiler toolchain.""" """Util to invoke NDK compiler toolchain."""
# pylint: disable=invalid-name # pylint: disable=invalid-name
from __future__ import absolute_import as _abs from __future__ import absolute_import as _abs
import subprocess import subprocess
import os import os
from .._ffi.base import py_str
def create_shared(output, def create_shared(output,
objects, objects,
...@@ -43,5 +45,5 @@ def create_shared(output, ...@@ -43,5 +45,5 @@ def create_shared(output,
if proc.returncode != 0: if proc.returncode != 0:
msg = "Compilation error:\n" msg = "Compilation error:\n"
msg += out msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
...@@ -72,7 +72,7 @@ def compile_cuda(code, ...@@ -72,7 +72,7 @@ def compile_cuda(code,
if proc.returncode != 0: if proc.returncode != 0:
msg = "Compilation error:\n" msg = "Compilation error:\n"
msg += out msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
return bytearray(open(file_target, "rb").read()) return bytearray(open(file_target, "rb").read())
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import subprocess import subprocess
from os.path import join from os.path import join
from . import util from . import util
from .._ffi.base import py_str
from ..api import register_func, convert from ..api import register_func, convert
def rocm_link(in_file, out_file): def rocm_link(in_file, out_file):
...@@ -24,7 +25,7 @@ def rocm_link(in_file, out_file): ...@@ -24,7 +25,7 @@ def rocm_link(in_file, out_file):
if proc.returncode != 0: if proc.returncode != 0:
msg = "Linking error using ld.lld:\n" msg = "Linking error using ld.lld:\n"
msg += str(out) msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import subprocess import subprocess
import os import os
from . import util from . import util
from .._ffi.base import py_str
def optimize(spv_bin): def optimize(spv_bin):
"""Optimize SPIRV using spirv-opt via CLI """Optimize SPIRV using spirv-opt via CLI
...@@ -37,7 +37,7 @@ def optimize(spv_bin): ...@@ -37,7 +37,7 @@ def optimize(spv_bin):
if proc.returncode != 0: if proc.returncode != 0:
msg = "Opitmizationerror using spirv-opt:\n" msg = "Opitmizationerror using spirv-opt:\n"
msg += str(out) msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
return bytearray(open(tmp_out, "rb").read()) return bytearray(open(tmp_out, "rb").read())
...@@ -6,6 +6,7 @@ import os ...@@ -6,6 +6,7 @@ import os
import shutil import shutil
import subprocess import subprocess
from . import util from . import util
from .._ffi.base import py_str
def tar(output, files): def tar(output, files):
"""Create tarball containing all files in root. """Create tarball containing all files in root.
...@@ -38,7 +39,7 @@ def tar(output, files): ...@@ -38,7 +39,7 @@ def tar(output, files):
if proc.returncode != 0: if proc.returncode != 0:
msg = "Tar error:\n" msg = "Tar error:\n"
msg += out msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
...@@ -64,5 +65,5 @@ def untar(tar_file, directory): ...@@ -64,5 +65,5 @@ def untar(tar_file, directory):
if proc.returncode != 0: if proc.returncode != 0:
msg = "Tar error:\n" msg = "Tar error:\n"
msg += out msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
# pylint: disable=invalid-name # pylint: disable=invalid-name
"""Utility to invoke Xcode compiler toolchain""" """Utility to invoke Xcode compiler toolchain"""
from __future__ import absolute_import as _abs from __future__ import absolute_import as _abs
import os import os
import sys import sys
import subprocess import subprocess
from .._ffi.base import py_str
from . import util from . import util
def xcrun(cmd): def xcrun(cmd):
...@@ -49,7 +51,7 @@ def codesign(lib): ...@@ -49,7 +51,7 @@ def codesign(lib):
(out, _) = proc.communicate() (out, _) = proc.communicate()
if proc.returncode != 0: if proc.returncode != 0:
msg = "Codesign error:\n" msg = "Codesign error:\n"
msg += out msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
...@@ -92,7 +94,7 @@ def create_dylib(output, objects, arch, sdk="macosx"): ...@@ -92,7 +94,7 @@ def create_dylib(output, objects, arch, sdk="macosx"):
if proc.returncode != 0: if proc.returncode != 0:
msg = "Compilation error:\n" msg = "Compilation error:\n"
msg += out msg += py_str(out)
raise RuntimeError(msg) raise RuntimeError(msg)
......
...@@ -22,7 +22,10 @@ from . import cuda ...@@ -22,7 +22,10 @@ from . import cuda
from . import rasp from . import rasp
from . import mali from . import mali
from . import opengl from . import opengl
from . import testing
from . import util from . import util
from . import rocm from . import rocm
from . import cpp from . import cpp
# not import testing by default
# because testing can have extra deps that are not necessary
# we can import them from test cases explicitly
# from . import testing
import tvm import tvm
import topi import topi
import topi.testing
import numpy as np import numpy as np
......
...@@ -3,6 +3,7 @@ import os ...@@ -3,6 +3,7 @@ import os
import numpy as np import numpy as np
import tvm import tvm
import topi import topi
import topi.testing
import logging import logging
from topi.util import get_const_tuple from topi.util import get_const_tuple
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import numpy as np import numpy as np
import tvm import tvm
import topi import topi
import topi.testing
import math import math
def verify_upsampling(batch, in_channel, in_height, in_width, scale): def verify_upsampling(batch, in_channel, in_height, in_width, scale):
......
import tvm import tvm
import topi import topi
import topi.testing
import numpy as np import numpy as np
def test_dilate(): def test_dilate():
......
...@@ -4,6 +4,7 @@ import numpy as np ...@@ -4,6 +4,7 @@ import numpy as np
import tvm import tvm
import topi import topi
import logging import logging
import topi.testing
from topi.util import get_const_tuple from topi.util import get_const_tuple
def verify_softmax(m, n): def verify_softmax(m, n):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment