-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[TIR][Transform] Clear buffer_map during MakeUnpackedAPI #12891
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
Conversation
|
@Lunderberg I think we make use of this in following passes and I'm unsure why make packed API decides to clear it? |
|
@Mousius Thank you, and it looks like that's also being caught in the tests, as this breaks pretty much every ethos-u test at this line. (Also why I intentionally marked this as a draft PR, to catch any impact to workflows that I'm not as familiar with.) To me, the |
|
@Mousius Can you check the latest commit on this PR? I didn't try to re-order the passes, but reading from the |
Aha! Makes perfect sense, thanks for the explanation! I figured that was why it was in draft, being a bit nosey as I remember wondering about it when I was writing |
Mousius
left a comment
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.
@Mousius Can you check the latest commit on this PR? I didn't try to re-order the passes, but reading from the
BufferStore/BufferLoadobjects instead of thebuffer_mapresolved the test cases I ran locally.
The fix makes sense to me, can we either make use of get_loads and get_stores or move the collect_buffer_map function to utils.py?
Also can we add to the documentation of the Pass the intention behind clearing it?
Certainly. It is now pulled out and documented, with defined behavior for buffers that share a backing |
No worries at all, and I wouldn't consider it nosey, either. It's the exact type of comment I was hoping for, as there wasn't an immediately obvious reason for the asymmetry between packed and unpacked.
Good call, and will do. |
| if buffer_info[param].btype == BufferType.constant: | ||
| continue | ||
| buffer = primfunc.buffer_map[param] | ||
|
|
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.
I've just chatted with @ekalda around this and we're not sure why the extra buffer appears, it appears to be an unused intermediary buffer and for the tests I ran this fixes it:
| if param not in buffer_map: | |
| base_addresses.append( | |
| util.BaseAddress( | |
| param.name.replace("-", "_"), | |
| idx, | |
| _get_region(buffer_info[param].btype, param, scratch_region_map), | |
| 0, | |
| ) | |
| ) | |
| idx += 1 | |
| continue |
I can tidy this loop up afterwards 😸
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.
That works for me locally, on to the CI! Thank you on the ethos-u debugging, and it helps quite a bit.
This mimics the behavior in `MakePackedAPI`, and is assumed to be the case for some codegens.
This previously relied on `MakeUnpackedAPI` preserving the `PrimFunc::buffer_map`, even after it had been used for lowering. It now reads from the `BufferLoad` and `BufferStore` nodes to determine buffer shapes.
297ceb6 to
17ce8c3
Compare
|
Thanks for making the API that little bit more consistent @Lunderberg 😸 |
* [TIR][Transform] Clear buffer_map during MakeUnpackedAPI This mimics the behavior in `MakePackedAPI`, and is assumed to be the case for some codegens. * Remove read of buffer_map in ethosu.tir_to_cs_translator This previously relied on `MakeUnpackedAPI` preserving the `PrimFunc::buffer_map`, even after it had been used for lowering. It now reads from the `BufferLoad` and `BufferStore` nodes to determine buffer shapes. * Added more documentation for MakePackedAPI/MakeUnpackedAPI
This mimics the behavior in
MakePackedAPI, and is assumed to be the case for some codegens.