Commit a59774e3 by Tianqi Chen Committed by GitHub

[BUILD] Simplify build process (#326)

parent cbdd14f1
...@@ -4,6 +4,8 @@ This module provides the functions to transform schedule to ...@@ -4,6 +4,8 @@ This module provides the functions to transform schedule to
LoweredFunc and compiled Module. LoweredFunc and compiled Module.
""" """
from __future__ import absolute_import as _abs from __future__ import absolute_import as _abs
import warnings
from . import api from . import api
from . import tensor from . import tensor
from . import schedule from . import schedule
...@@ -324,29 +326,28 @@ def build(sch, ...@@ -324,29 +326,28 @@ def build(sch,
raise ValueError("unknown function type %d" % func.func_type) raise ValueError("unknown function type %d" % func.func_type)
if not target.startswith("llvm") and target != "stackvm" and not fdevice: 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) "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 = "cpu" if target.startswith("llvm") or target == "stackvm" else target
device_type = ndarray.context(device, 0).device_type device_type = ndarray.context(device, 0).device_type
fhost = [ir_pass.BindDeviceType(x, device_type) for x in fhost] fhost = [ir_pass.BindDeviceType(x, device_type) for x in fhost]
fhost = [ir_pass.LowerTVMBuiltin(x) 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: if not target_host:
fdevice = [ir_pass.LowerIntrin(x, target) for x in fdevice] if device == "cpu":
fhost = [ir_pass.LowerIntrin(x, target_host) for x in fhost] target_host = target
else: assert not fdevice
fhost = [ir_pass.LowerIntrin(x, target) for x in fhost] 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] fhost = [ir_pass.CombineContextCall(x) for x in fhost]
mhost = codegen.build_module(fhost, target_host)
if fdevice: if fdevice:
mhost = codegen.build_module(fhost, target_host) mdev = codegen.build_module(fdevice, target_device)
if target: mhost.import_module(mdev)
mdev = codegen.build_module(fdevice, target) return mhost
mhost.import_module(mdev)
return mhost
else:
return codegen.build_module(fhost, target)
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