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 @@
from __future__ import absolute_import as _abs
import sys
import subprocess
import os
from .._ffi.base import py_str
from .util import tempdir
......@@ -53,7 +54,7 @@ def _linux_shared(output, objects, options, cc="g++"):
(out, _) = proc.communicate()
if proc.returncode != 0:
msg = "Compilation error:\n"
msg += str(out)
msg += py_str(out)
raise RuntimeError(msg)
......@@ -88,7 +89,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,\
"please run this in Vistual Studio Command Prompt.")
if proc.returncode != 0:
msg = "Compilation error:\n"
msg += str(out)
msg += py_str(out)
raise RuntimeError(msg)
link_cmd = ["link"]
link_cmd += ["-dll", "-FORCE:MULTIPLE"]
......@@ -114,6 +115,6 @@ BOOL APIENTRY DllMain( HMODULE hModule,\
"please run this in Vistual Studio Command Prompt.")
if proc.returncode != 0:
msg = "Compilation error:\n"
msg += str(out)
msg += py_str(out)
raise RuntimeError(msg)
"""Util to invoke emscripten compilers in the system."""
# pylint: disable=invalid-name
from __future__ import absolute_import as _abs
import subprocess
from .._ffi.base import py_str
from .._ffi.libinfo import find_lib_path
def create_js(output,
......@@ -58,7 +60,7 @@ def create_js(output,
if proc.returncode != 0:
msg = "Compilation error:\n"
msg += out
msg += py_str(out)
raise RuntimeError(msg)
create_js.object_format = "bc"
"""Util to invoke NDK compiler toolchain."""
# pylint: disable=invalid-name
from __future__ import absolute_import as _abs
import subprocess
import os
from .._ffi.base import py_str
def create_shared(output,
objects,
......@@ -43,5 +45,5 @@ def create_shared(output,
if proc.returncode != 0:
msg = "Compilation error:\n"
msg += out
msg += py_str(out)
raise RuntimeError(msg)
......@@ -72,7 +72,7 @@ def compile_cuda(code,
if proc.returncode != 0:
msg = "Compilation error:\n"
msg += out
msg += py_str(out)
raise RuntimeError(msg)
return bytearray(open(file_target, "rb").read())
......
......@@ -2,6 +2,7 @@
import subprocess
from os.path import join
from . import util
from .._ffi.base import py_str
from ..api import register_func, convert
def rocm_link(in_file, out_file):
......@@ -24,7 +25,7 @@ def rocm_link(in_file, out_file):
if proc.returncode != 0:
msg = "Linking error using ld.lld:\n"
msg += str(out)
msg += py_str(out)
raise RuntimeError(msg)
......
......@@ -2,7 +2,7 @@
import subprocess
import os
from . import util
from .._ffi.base import py_str
def optimize(spv_bin):
"""Optimize SPIRV using spirv-opt via CLI
......@@ -37,7 +37,7 @@ def optimize(spv_bin):
if proc.returncode != 0:
msg = "Opitmizationerror using spirv-opt:\n"
msg += str(out)
msg += py_str(out)
raise RuntimeError(msg)
return bytearray(open(tmp_out, "rb").read())
......@@ -6,6 +6,7 @@ import os
import shutil
import subprocess
from . import util
from .._ffi.base import py_str
def tar(output, files):
"""Create tarball containing all files in root.
......@@ -38,7 +39,7 @@ def tar(output, files):
if proc.returncode != 0:
msg = "Tar error:\n"
msg += out
msg += py_str(out)
raise RuntimeError(msg)
......@@ -64,5 +65,5 @@ def untar(tar_file, directory):
if proc.returncode != 0:
msg = "Tar error:\n"
msg += out
msg += py_str(out)
raise RuntimeError(msg)
# pylint: disable=invalid-name
"""Utility to invoke Xcode compiler toolchain"""
from __future__ import absolute_import as _abs
import os
import sys
import subprocess
from .._ffi.base import py_str
from . import util
def xcrun(cmd):
......@@ -49,7 +51,7 @@ def codesign(lib):
(out, _) = proc.communicate()
if proc.returncode != 0:
msg = "Codesign error:\n"
msg += out
msg += py_str(out)
raise RuntimeError(msg)
......@@ -92,7 +94,7 @@ def create_dylib(output, objects, arch, sdk="macosx"):
if proc.returncode != 0:
msg = "Compilation error:\n"
msg += out
msg += py_str(out)
raise RuntimeError(msg)
......
......@@ -22,7 +22,10 @@ from . import cuda
from . import rasp
from . import mali
from . import opengl
from . import testing
from . import util
from . import rocm
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 topi
import topi.testing
import numpy as np
......
......@@ -3,6 +3,7 @@ import os
import numpy as np
import tvm
import topi
import topi.testing
import logging
from topi.util import get_const_tuple
......
......@@ -2,6 +2,7 @@
import numpy as np
import tvm
import topi
import topi.testing
import math
def verify_upsampling(batch, in_channel, in_height, in_width, scale):
......
import tvm
import topi
import topi.testing
import numpy as np
def test_dilate():
......
......@@ -4,6 +4,7 @@ import numpy as np
import tvm
import topi
import logging
import topi.testing
from topi.util import get_const_tuple
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