I propose to rename the TVMContext to TVMDevice. Currently, TVMContext is used to represent a device that the model is executed on. Two main reasons for this change:
the name of TVMContext doesn’t intuitively reflect its semantics of a device.
mainstream frameworks including TensorFlow and PyTorch both uses device to represent the device to run. I think it’d be good that we use the similar terminology to reduce the confusion.
Context is indeed a bad name when it is used to indicate a certain device, because its meaning really varies depending on the “context”. In this case, “device” is certainly an acceptable name and is a lot better than “context”.
Two thoughts:
when referring to a remote device in TVM RPC, what word should we use? Right now we still use ctx.
in dlpack, we still use DLContext, so are we going to propose a name change in dlpack as well?
Yeah this change sounds quite reasonable to me. BTW, the DLPack case might be a bit intricate, because it needs consensus across different frameworks, but let’s leave the discussion to DLPack RFC
Agree on this change. Context is more like a region or environment for certain processes. For example, “DispatchContext” and “PassContext” are reasonable naming because they are usually used with with. On the other hand, TVMContext includes just the device information, so it is more like just a data structure.
Yeah, there are different uses of context in the codebase. Device makes more sense to me as well. Would the change to DLPack break other projects that take it as a submodule?
I don’t know much about µTVM. Need to take a look to comment on this.
I think we can make the change in TVM first and change again after the change is pushed to DLPack. Because there’ll be more dependencies in DLPack, it’ll probably take longer time to change in DLPack.
You can also check out and comment on the RFC to DLPack now.
I’m not worried about the µTVM case especially if that’s the only concern. The main thing I’m wondering about is whether it makes sense to let the DLPack RFC get accepted before we make changes here.
I agree with the change, internally it would be nice to drop the TVM prefix as well and just refer to it as a tvm::Device like we do with almost every other data structure in the code base.
My take on dropping the TVM prefix: given DLTensor/DLContext is the de facto standard, we do not really need to define their TVM alias (e.g. TVMContext) and can just use them directly
I think we can keep TVMDevice in the C++ and backend, but use tvm.device in the python frontend. It can reduce the confusion when integrating TVM into other frameworks if we keep TVM prefix.
All other TVM primitive types are not prefixed by TVM, it is actually less consistent to use TVM in front of them, currently we have the DL* convention for the low level types and we have tvm::Type for all the high level types including DataType and others.
I think we should prioritize clarity in our code base over integration into others.
Because right now TVMContext sits under the global scope(not inside the tvm namespace), as it is needed in the C API.
Another thought is that we could simply use DLDevice instead of TVMDevice to avoid such indirection as apparently we are not introduce a top level abstraction here.
Proposal A0:
Use DLDevice in the C API. Under tvm namespace provid the alias, so we can use Device to refer to it.
// device_api.h
namespace tvm {
using Device = DLDevice;
}
Alternatively, we can simply use DLDevice inside the c++
I vote for less aliases, so that’d be using DLDevice everywhere. In the python API, we could call it tvm.runtime.DLDevice to avoid the impression we are renaming it underneath the tvm namespace.