-
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
[TIR] StmtFunctor RenewDefs #10843
[TIR] StmtFunctor RenewDefs #10843
Conversation
cc @junrushao1994 @vinx13 @jinhongyii @MasterJH5574 please help to review |
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.
“Regenerate” itself is already a word. So I suggest we using “RegenerateDef” instead of “ReGenerateDef” 🤔
7d0e66a
to
9e03820
Compare
In this PR, I introduce a StmtFunctor `RenewDefs` for deep copy all definition nodes in PrimFunc (including Var, Buffer, and IterVar). This functor can create a new PrimFunc with the same behavior as the old one but contains different Nodes. This Functor may help TIR fusion or inline multiple PrimFuncs
9e03820
to
445d36e
Compare
Please take another look @tqchen @jinhongyii @junrushao1994 @MasterJH5574 |
Some additional ideas for possible regressions Symbolic shape case that needs remapSymbolic vars needs to be mapped to the same one def fn(a: T.handle, b: T.handle, n: T.int32)
m = T.var("int32")
A = match_buffer((n, m), a)
B = match_bufer((n, m*2), b) |
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.
Some high level comments, no correctness issue but would be good to add test coverage.
Thanks for this interesting case! As a further step, there might be usecases where buffers are declared as divisible by power-of-2, for example: def fn(a: T.handle):
m = T.var("int32")
A = match_buffer(a, (m * 8, ), "float32") @tqchen do you think this is a case we want to support? |
@junrushao1994 what you are describing is not a case we support right now, but can be something we want to support in the future and indeed an useful case |
Any updates? |
@junrushao1994 @tqchen please take another look at it. |
* [TIR] StmtFunctor RenewDefs In this PR, I introduce a StmtFunctor `RenewDefs` for deep copy all definition nodes in PrimFunc (including Var, Buffer, and IterVar). This functor can create a new PrimFunc with the same behavior as the old one but contains different Nodes. This Functor may help TIR fusion or inline multiple PrimFuncs * add ut * address comments * address comments * lint * lint
In this PR, I introduce a StmtFunctor
ReGenerateDef
for deep copy all definition nodes in PrimFunc (including Var, Buffer, and IterVar). This functor can create a new PrimFunc with the same behavior as the old one but contains different Nodes.This Functor may help TIR fusion or inline multiple PrimFuncs
cc @tqchen @jinhongyii