From f425d08c6d2a83b0bba0ac6acbb2657823df0bdf Mon Sep 17 00:00:00 2001 From: tqchen Date: Mon, 14 Aug 2017 19:07:44 -0700 Subject: [PATCH] [BUILD] Simplify build process --- python/tvm/build_module.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/python/tvm/build_module.py b/python/tvm/build_module.py index 16cd123d93e0..bc8502c443c5 100644 --- a/python/tvm/build_module.py +++ b/python/tvm/build_module.py @@ -4,6 +4,8 @@ LoweredFunc and compiled Module. """ from __future__ import absolute_import as _abs +import warnings + from . import api from . import tensor from . import schedule @@ -324,29 +326,28 @@ def build(sch, raise ValueError("unknown function type %d" % func.func_type) if not target.startswith("llvm") and target != "stackvm" and not fdevice: - raise ValueError( + warnings.warn( "Specified target %s, but cannot find device code, did you do bind?" % target) device = "cpu" if target.startswith("llvm") or target == "stackvm" else target device_type = ndarray.context(device, 0).device_type fhost = [ir_pass.BindDeviceType(x, device_type) for x in fhost] fhost = [ir_pass.LowerTVMBuiltin(x) for x in fhost] - if not target_host and fdevice: - target_host = "llvm" if module.enabled("llvm") else "stackvm" - if fdevice: - fdevice = [ir_pass.LowerIntrin(x, target) for x in fdevice] - fhost = [ir_pass.LowerIntrin(x, target_host) for x in fhost] - else: - fhost = [ir_pass.LowerIntrin(x, target) for x in fhost] + if not target_host: + if device == "cpu": + target_host = target + assert not fdevice + else: + target_host = "llvm" if module.enabled("llvm") else "stackvm" + target_device = target + fdevice = [ir_pass.LowerIntrin(x, target_device) for x in fdevice] + fhost = [ir_pass.LowerIntrin(x, target_host) for x in fhost] fhost = [ir_pass.CombineContextCall(x) for x in fhost] + mhost = codegen.build_module(fhost, target_host) if fdevice: - mhost = codegen.build_module(fhost, target_host) - if target: - mdev = codegen.build_module(fdevice, target) - mhost.import_module(mdev) - return mhost - else: - return codegen.build_module(fhost, target) + mdev = codegen.build_module(fdevice, target_device) + mhost.import_module(mdev) + return mhost