-
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
Add init
member to ReduceNode
#6138
Conversation
This is my first time contributing to TVM and I have tried to follow all the instructions for Contributors from the documentation, but please let me know I could change anything. I ran clang-format on all the files, but looks like I confused clang-format with linting tools for cpp. I'll try and fix them ASAP. Thanks, |
Thanks @quic-sanirudh for proposing the new change. My only conern wrt to the custom initialization value is that it might break the follow up primitives, e.g. rfactor and cross thread allreduce will require the init value to be the identity element. As a result, we might want to pause a bit. The initial value can still be added by introducing an additional stage(with a small overhead). There is early plan to introduce scheduling for TIR, which might bring the possibility to include such custom initialization stage, which we can then support this feature |
Hi @tqchen Also, I'm not aware of the TIR level scheduling that's planned, is there an RFC or PR where this is being discussed that I can read about. Thanks |
TIR level scheduling is still in an early stage so no RFC yet, will keep you updated once the RFC is out. |
Thanks @quic-sanirudh what you said about rfactor makes sense. We can still support rfactor, by checking the factor indices, and only assign the init value if the factor indices equals the initial one, however, we may not be able to express the computation as a related primitive. Given that rfactor is not usually used together with the usage of init, this might be fine. It would also be great to add a few compiled testcases |
Thanks @tqchen for the suggestion. I'll work on adding the rfactor support and update the PR once its done. Also, could you explain what you meant by adding "compiled" testcases as I'm a little confused by that. Did you mean cpp tests? |
Oh, i meant test cases that use this feature to compile a reduction with init value like those in |
Ah okay, thanks for the clarification. I'll add those too. |
- This patch adds a new member to ReduceNode called init which allows initialization with a custom ProducerLoad or a Float/Int immediate. - This allows initialization of the output Tensor of a reduction with another Tensor instead of the `identity_element` defined in the CommReducer - One example use case for this node is to initialize the Output of a convolution reduction with the Bias values thereby saving the Bias-add computation.
I added the support for initializing with rfactor, but doesn't work with crossthread_allreduce. I also added a few unit and compiled tests. |
Thanks @quic-sanirudh ! this is now merged |
- This patch adds a new member to ReduceNode called init which allows initialization with a custom ProducerLoad or a Float/Int immediate. - This allows initialization of the output Tensor of a reduction with another Tensor instead of the `identity_element` defined in the CommReducer - One example use case for this node is to initialize the Output of a convolution reduction with the Bias values thereby saving the Bias-add computation.
- This patch adds a new member to ReduceNode called init which allows initialization with a custom ProducerLoad or a Float/Int immediate. - This allows initialization of the output Tensor of a reduction with another Tensor instead of the `identity_element` defined in the CommReducer - One example use case for this node is to initialize the Output of a convolution reduction with the Bias values thereby saving the Bias-add computation.
- This patch adds a new member to ReduceNode called init which allows initialization with a custom ProducerLoad or a Float/Int immediate. - This allows initialization of the output Tensor of a reduction with another Tensor instead of the `identity_element` defined in the CommReducer - One example use case for this node is to initialize the Output of a convolution reduction with the Bias values thereby saving the Bias-add computation.
initialization with a custom ProducerLoad or a Float/Int immediate.
another Tensor instead of the
identity_element
defined in theCommReducer
convolution reduction with the Bias values thereby saving the
Bias-add computation.
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.