You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tvm.apache.org by Haichen Shen via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/02/07 05:56:15 UTC

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice


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:

1. the name of `TVMContext` doesn't intuitively reflect its semantics of a device. 
2. mainstream frameworks including [TensorFlow](https://www.tensorflow.org/api_docs/python/tf/device) and [PyTorch](https://pytorch.org/docs/stable/tensor_attributes.html?highlight=device#torch.torch.device) 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.

Let me know your thoughts.
@tqchen @jroesch @zhiics @comaniac @junrushao1994





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/4da1ce4e88438ecf5b6da367ecde8707139e4d85125b4d70cc6fc2e3326829df).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Andrew Reusch via Apache TVM Discuss <no...@discuss.tvm.ai>.

I think I originally proposed A1 but one thing is that we have the TVM extension device types, so perhaps keeping a separate Device is better. I'm ok w/ A0.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/26) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/fbdcca6752bad5f702fabf8275e5ebfaaa0088f868112d259ebfc48e0abbb12b).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

I vote for A0 after careful consideration. DLDevice requires extra knowledge of DLPack





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/25) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/0b8cb6224d276c9671f9cedbb8b5559d89b92139074fcfe5f60148b10e26fa41).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by "Cody H. Yu via Apache TVM Discuss" <no...@discuss.tvm.ai>.

Vote for A0 +1 to make it more modulized.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/24) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/1a69160d14798cb6c427dff1fd28325a387dab8f996fa188417b9caa90ab7129).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Haichen Shen via Apache TVM Discuss <no...@discuss.tvm.ai>.

1. TVM uses [RPCSession](https://tvm.apache.org/docs/api/python/rpc.html#tvm.rpc.RPCSession.context) to create a remote context/device. We can also change this API to `device`.
2. In fact, I also plan to create a RFC to dlpack for the context name change.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/a78b4b3277dd2b472900ff88acd55d880252e6795c0e9bc89f20395748b3d5e7).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

Thanks for bringing this up!

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:
1) when referring to a remote device in TVM RPC, what word should we use? Right now we still use ctx.
2) in dlpack, we still use DLContext, so are we going to propose a name change in dlpack as well?





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/63bf342dc026bb1a93c9ac66814173b97bcbfb6d37c1341b6cda9426ac0f5262).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Haichen Shen via Apache TVM Discuss <no...@discuss.tvm.ai>.

Since everyone agree on A0, I'll go ahead and prepare the PR in next week.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/27) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/09cb7276a1261b94a1f6b1bdf2b111adc3d8dcfe770b0755ee4695be0f56cbc4).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Haichen Shen via Apache TVM Discuss <no...@discuss.tvm.ai>.

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.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/12) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/2cd4afc627b6282763672e39f3cbe950f0fd0e7c34a5c57b2695a99b35f317d0).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Jared Roesch via Apache TVM Discuss <no...@discuss.tvm.ai>.

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.

Thanks for doing this Haichen!





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/10) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/01c560a579036ef54304d4d3003522d1065e84d304bc96fb8b6edc2ee7a54bfb).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

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 :slight_smile:





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/355bfb0eb6537c24838ccdd08336285624157d26f4a3ec7d01b088596b9f58a1).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by "Cody H. Yu via Apache TVM Discuss" <no...@discuss.tvm.ai>.

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.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/5) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/0dee9c84e87c0508ea4367828dc62bfcbdd2067d0464a9b5396c9a630cb5c116).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Andrew Reusch via Apache TVM Discuss <no...@discuss.tvm.ai>.

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.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/9) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/49ee93c5ff37ecceabdc2b2b8b3b2b44d484a593d00bf0ea8b79364af6f3a0d7).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Haichen Shen via Apache TVM Discuss <no...@discuss.tvm.ai>.

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](https://github.com/dmlc/dlpack/issues/61) to DLPack now.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/8) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/d09135ce435a1e88cf81e3c526ec54ea556094f4e7318fb14e5a8ae2e05482a9).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Andrew Reusch via Apache TVM Discuss <no...@discuss.tvm.ai>.

context is definitely overloaded (can also mean "a collection of state related to a request" e.g. when serving model inference requests).

I do think there are a couple of ways device could be confusing:
 - for µTVM, a new user could consider the whole PCB could be a "device," even though in reality the CPU and accelerator would be separate devices
 - perhaps on mobile this would also be true?

I am not really sure if there is a word that would be both concise and not confusing here, though. Executor? Compute Unit?

anyway, is the plan to propose the DLPack change first, then the TVM change to follow?





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/6) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/ecc6afb57a29ef8c1a98615bcabfb9cd2f91c1049938a91156ea07c89512627c).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

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





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/11) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/c0adf6f9431c79b2450b553c942b31599ca1cf0e62a828baeda3b2b9259b8a21).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Ziheng Jiang via Apache TVM Discuss <no...@discuss.tvm.ai>.

I vote for A0 for consistency with DLDataType / tvm::DataType





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/23) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/00d74b7e16d100eb0c975d9ff2bd4867378afc0138af6dd2964788ffc3ccb440).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by Zhi via Apache TVM Discuss <no...@discuss.tvm.ai>.

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?





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/7) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/277ddbe840f173cbe6fd42a09387f83841757836c4d9f5d5f9923a850d5e1542).

[Apache TVM Discuss] [Development/RFC] [RFC] Rename TVMContext to TVMDevice

Posted by tqchen via Apache TVM Discuss <no...@discuss.tvm.ai>.

How about we do a new round of poll given the new options. Everyone please share your thoughts

## A0
- Use DLDevice in C API
- Introduce tvm::runtime::Device in C++, alias of DLDevice for now, might add member functions(like runtime::DataType's relation to DLDataType) later
- Introduce tvm.runtime.Device on the python side

Consistency in  API with `tf.Device` and `torch.Device`. Keep path for future C++ class that has more functionalities(with the same ABI)

## A1
- Directly DLDevice in C/C++/python API


Less aliasing. Require future update path for introducing Device class if needed.





---
[Visit Topic](https://discuss.tvm.apache.org/t/rfc-rename-tvmcontext-to-tvmdevice/9090/22) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/d9e0cf732dbbeeb8065c013fc2b674ba1417959d6f0592ae4ee6a7a2db15d7d3).