-
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
[Frontend][TFLite] Densify Op added #7048
Conversation
cc @tkonolige , @u99127 ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ANSHUMAN87. Overall looks pretty good, but I am a little confused at exactly what is happening is this pass. Is it converting matrices from sparse to dense at compile time?
Thanks @tkonolige for review! The Densify Op does not need to be present in TVM runtime currently, because its purpose is to convert sparse weights(constant) to dense form. So i have optimized it out. However in case it is required in future to be present in TVM runtime, we can always do it with sparse_to_dense Op with the indices produced from the utility prepare_dense_matrix_from_sparse(). As to your other comments i have tried to add comments in the necessary places. Please have a look. In case anything more required. Please let me know. TIA! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding all the comments. It looks good to me.
cc @FrozenGene ! |
Sorry about the delay in reviewing . I think there are a couple of design points here that we should consider and take a well-informed decision on this direction.
TBH I would probably prefer #2 as an approach to try and reduce any duplications in the frontends and give other compilers or others who use Relay a chance to get to the densify op. I don't think we can use it for any of our work instantly. If the performance or code size becomes an issue we'll need to reconsider a runtime or partial runtime representation of sparse weights at which point #1 would be a stepping stone towards it . These are my thought on the design. regards
|
Thanks @u99127 for your inputs! Most of your arguments i concur. When i went through first approach, i found the performance is too bad and Sparse_to_Dense Op resulted in stack corruption when fed with higher dimension inputs, hence i switched to second approach, which makes sense if we think from TFLite perspective. Because TFLite framework, optmizes out Densify Op when it comes to Sparse Inference. As my future work will include the Sparse Inference as well, i think at this point it will suffice to keep densified weight in Runtime. However as i mentioned earlier, if we want to keep in TVM runtime, current PR changes supports that as well, with the steps i mentioned in my previous comment. Provided we first fix the Sparse_to_Dense limitations(which i am looking into right now). May be we can do this Op conversion with a configurable user option in Frontend. |
573077b
to
a5f1c68
Compare
I have added TODO to use sparse_to_dense Op as well to enable user to have Sparse weights in store rather than Dense weight when board onto TVM. I believe this PR is ready to be merged. Unless any further comment. |
Gentle ping @zhiics , @FrozenGene ! |
Thanks @FrozenGene, @tkonolige! |
* [Frontend][TFLite] Densify Op added * [1] Review comments handled * TODO added for sparse_to_dense Op usage * stale comments removed
* [Frontend][TFLite] Densify Op added * [1] Review comments handled * TODO added for sparse_to_dense Op usage * stale comments removed
* [Frontend][TFLite] Densify Op added * [1] Review comments handled * TODO added for sparse_to_dense Op usage * stale comments removed
* [Frontend][TFLite] Densify Op added * [1] Review comments handled * TODO added for sparse_to_dense Op usage * stale comments removed
* [Frontend][TFLite] Densify Op added * [1] Review comments handled * TODO added for sparse_to_dense Op usage * stale comments removed
Densify Op performs sparse to dense transformation for sparse weights based on their sparse parameters provided.
This Op is needed for sparse ConvNet models.