Skip to content

Commit

Permalink
[Codegen] Use "target.build.$TARGET_KIND" for all codegen functions. (#…
Browse files Browse the repository at this point in the history
…8071)

* [Codegen] Use "target.build.$TARGET_KIND" for all codegen functions.

- Removed special case for "micro_dev" target.  Instead, register
  BuildCHost as both "target.build.c" and "target.build.micro_dev".

- Renamed "target.build.build.aocl_sw_emu" to
  "target.build.aocl_sw_emu".  Appears to be a typo introduced in
  #841725cc585

* [micro_dev] Removed references to non-existent micro_dev

device_api.micro_dev was removed in
745e542, but several references still
remained.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
  • Loading branch information
Lunderberg and Lunderberg authored Jun 4, 2021
1 parent 0429c63 commit a74d0fe
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 413 deletions.
2 changes: 0 additions & 2 deletions include/tvm/runtime/device_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ inline const char* DeviceName(int type) {
return "ext_dev";
case kDLWebGPU:
return "webgpu";
case kDLMicroDev:
return "micro_dev";
case kDLHexagon:
return "hexagon";
default:
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# tvm.runtime
from .runtime.object import Object
from .runtime.ndarray import device, cpu, cuda, gpu, opencl, cl, vulkan, metal, mtl
from .runtime.ndarray import vpi, rocm, ext_dev, micro_dev, hexagon
from .runtime.ndarray import vpi, rocm, ext_dev, hexagon
from .runtime import ndarray as nd

# tvm.error
Expand Down
2 changes: 0 additions & 2 deletions python/tvm/_ffi/runtime_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class Device(ctypes.Structure):
9: "vpi",
10: "rocm",
12: "ext_dev",
13: "micro_dev",
14: "hexagon",
15: "webgpu",
}
Expand All @@ -194,7 +193,6 @@ class Device(ctypes.Structure):
"vpi": 9,
"rocm": 10,
"ext_dev": 12,
"micro_dev": 13,
"hexagon": 14,
"webgpu": 15,
}
Expand Down
2 changes: 0 additions & 2 deletions python/tvm/autotvm/measure/measure_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ def get_build_kwargs(self):

if "cuda" in self.task.target.keys:
kwargs["cuda_arch"] = "sm_" + "".join(dev.compute_version.split("."))
if self.task.target.device_name == "micro_dev":
kwargs.setdefault("build_option", {})["tir.disable_vectorize"] = True

return kwargs

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# function exposures
from .object_generic import convert_to_object, convert, const
from .ndarray import device, cpu, cuda, gpu, opencl, cl, vulkan, metal, mtl
from .ndarray import vpi, rocm, ext_dev, micro_dev
from .ndarray import vpi, rocm, ext_dev
from .module import load_module, enabled, system_lib
from .container import String
from .params import save_param_dict, load_param_dict
3 changes: 0 additions & 3 deletions python/tvm/runtime/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,6 @@ def load_module(path, fmt=""):
files = [tar_temp.relpath(x) for x in tar_temp.listdir()]
_cc.create_shared(path + ".so", files, cc=cc)
path += ".so"
# TODO(weberlo): we should probably use a more distinctive suffix for microTVM object files
elif path.endswith(".obj"):
fmt = "micro_dev"
# Redirect to the load API
return _ffi_api.ModuleLoadFromFile(path, fmt)

Expand Down
27 changes: 4 additions & 23 deletions python/tvm/runtime/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,10 @@ def device(dev_type, dev_id=0):
assert tvm.device("cuda", 0) == tvm.cuda(0)
"""
if isinstance(dev_type, string_types):
if "-device=micro_dev" in dev_type:
dev_type = Device.STR2MASK["micro_dev"]
else:
dev_type = dev_type.split()[0]
if dev_type not in Device.STR2MASK:
raise ValueError("Unknown device type %s" % dev_type)
dev_type = Device.STR2MASK[dev_type]
dev_type = dev_type.split()[0]
if dev_type not in Device.STR2MASK:
raise ValueError("Unknown device type %s" % dev_type)
dev_type = Device.STR2MASK[dev_type]
return Device(dev_type, dev_id)


Expand Down Expand Up @@ -510,22 +507,6 @@ def ext_dev(dev_id=0):
return Device(12, dev_id)


def micro_dev(dev_id=0):
"""Construct a micro device
Parameters
----------
dev_id : int, optional
The integer device id
Returns
-------
dev : Device
The created device
"""
return Device(13, dev_id)


def hexagon(dev_id=0):
"""Construct a Hexagon device
Expand Down
2 changes: 0 additions & 2 deletions src/runtime/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ bool RuntimeEnabled(const std::string& target) {
f_name = "target.build.stackvm";
} else if (target == "rpc") {
f_name = "device_api.rpc";
} else if (target == "micro_dev") {
f_name = "device_api.micro_dev";
} else if (target == "hexagon") {
f_name = "device_api.hexagon";
} else if (target.length() >= 5 && target.substr(0, 5) == "nvptx") {
Expand Down
8 changes: 2 additions & 6 deletions src/target/codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@ runtime::Module Build(IRModule mod, Target target) {
.value()) {
mod = tir::transform::SkipAssert()(mod);
}
std::string build_f_name;
if (target->kind->name == "micro_dev") {
build_f_name = "target.build.c";
} else {
build_f_name = "target.build." + target->kind->name;
}

// the build function.
std::string build_f_name = "target.build." + target->kind->name;
const PackedFunc* bf = runtime::Registry::Get(build_f_name);
ICHECK(bf != nullptr) << build_f_name << " is not enabled";
return (*bf)(mod, target);
Expand Down
2 changes: 1 addition & 1 deletion src/target/source/codegen_aocl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TVM_REGISTER_GLOBAL("target.build.aocl")
return BuildAOCL(mod, target, false);
});

TVM_REGISTER_GLOBAL("target.build.build.aocl_sw_emu")
TVM_REGISTER_GLOBAL("target.build.aocl_sw_emu")
.set_body_typed([](IRModule mod, Target target) -> runtime::Module {
return BuildAOCL(mod, target, true);
});
Expand Down
Loading

0 comments on commit a74d0fe

Please sign in to comment.