-
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
[TensorIR] New schedule primitive set_dtype
#14316
Conversation
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
It's a bit tricky since it would change the behavior of the PrimFunc (aka get different result before and after the schedule) |
There seems to be some interest in introducing schedule primitives like these that might cause different output. This certainly seems like a useful primitive to have, but since we don't normally want schedule primitives to cause the output to change, primitives like these might be hard to introduce. Would it make sense to have some discussion on perhaps introducing a different scheduling class that allows these kinds of primitives, or explicitly setting a "danger" flag in the Schedule class before using these primitives. That way, we could still allow primitives like these and make sure that a user knows the risk of using a primitive that could cause the output to change. |
Thanks @quic-sanirudh for the suggestion. I agree that it's a really useful primitive/tool for optimizations. It makes sense if we introduce a |
Adding a |
how about |
@yzh119 any updates |
I have updated my code with new name |
oops, @yzh119 please also check the c++ apis @junrushao mentioned :) |
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.
LGTM!
I don't know why but now it requires committer approval to run github actions for existing contributors. I'm merging this in after the actions got green |
Motivation
Currently, we miss a schedule primitive to change the data type of allocated buffer (e.g. via
cache_read
/cache_write
), and thus we cannot perform type conversion while loading data from global to shared memory.This PR adds a new schedule primitive
set_dtype
that follows the interface ofset_scope
and allows users to customize the allocated buffers' data type.Example
Before running
set_dtype
:then we perform the
set_dtype
schedule:we get transformed code:
where data type conversions are inserted automatically.
Other Usage
Using the combination of
cache_read
+set_dtype
can help us load data from the memory hierarchy while converting data to the desired type.cc @Hzfengsy @vinx13 @junrushao