-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RUNTIME] Enable NDArray type extension #2598
Conversation
@junrushao1994 @were @yzhliu @ZihengJiang please review. |
Ok, I see your point. By checking array_type_index_, it is possible for a front end language to understand which subclass the NDArray represents. |
Quick naive questions @tqchen If an external library wants to inherit tvm arrays, and we don't want to modify TVM's codebase
|
@junrushao1994 I agree with 1 that inheriting the container only will suffice. If inherit both, maybe they share some attributes, which should be maintained on both sides. This is not good for further maintenance. If something like an The only counter-intuitive part of doing this is that: when garbage collection, |
I don't understand the |
From the C++ side, if we want |
Probably we need a method like |
Here is the situation we are facing: |
To resolve this issue, it will be desirable to have a trait to force users to define a static indicator for each subclass of |
This PR proposed an improved version of
tvm::NDArray
signature that opens the path for future type extensions.While the current NDArray works great, there is a potential need to extend the NDArray itself to store additional information. This can become useful when we need to introduce variants that might be scheduled by an additional async engine, or a different form of lazy/eager execution.
In these cases, we could potentially subclass the NDArray and NDArray::Container, however, this also brings a potential need for runtime type checking. This PR adds a field
array_type_index_
to NDArray::Container to make the structure future compatible with the possibility of extensions. On 64 bit platform, it won't use additional space because we will need an additional int field anyway due to memory alignment issues.