-
Notifications
You must be signed in to change notification settings - Fork 77
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
transformations: implement stencil-tensorize-z-dimension #2516
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2516 +/- ##
==========================================
- Coverage 89.74% 89.66% -0.08%
==========================================
Files 356 357 +1
Lines 44796 45024 +228
Branches 6721 6766 +45
==========================================
+ Hits 40201 40373 +172
- Misses 3609 3636 +27
- Partials 986 1015 +29 ☔ View full report in Codecov by Sentry. |
This transformation actually deals with two different flavours of z-value tensors, which can be distinguished as follows:
Merging the main branch into this PR has come with additional verification, which because of the above distinction did not pass in two places:
|
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.
Nice work!
I see a lot of little things that could be simplified, with a bit of know-how, so I'm in favour of having a call and going over those so I can guide you through them, what do you think?
It should make the pass more readable and more powerful in one go, and is a nice opportunity to teach you more xDSL tricks 🙂
I also am strongly in favor of having one reverse-walking pass, rather than a forward tensorizing pass and a second one to adjust shapes. But we can do the above mentioned simplification orthogonally if you'd rather stick to that for now!
This is very nice stuff! I'm not 100% sure in my head how we go from here to CSL, but this is definitely a good start! |
The
stencil-tensorize-z-dimension
pass transforms scalar stencils into stencils operating on tensors of z-dim values, which will prove helpful when lowering.To summarise, the pass does the following
memref<1024x512x512xf32>
and similar are replaced by a corresponding tensorised versionmemref<1024x512xtensor<512xf32>>
stencil.access
in the x and y dimensions produce a z-dim tensor, whilestencil.access
in the z-dimension produce a z-dim tensor with an offset (diagonal accesses are currently not supported, see below).arith
dialect operation has two tensors as inputs, this is valid in the dialect and requires no change.arith
dialect operation has tensor and scalar as inputs, the scalar is expanded into an empty tensor usingtensor.empty
andlinalg.fill
. This is a temporary solution, as the dialect we're lowing to does support mixing tensor and scalar operands in most cases.This should be lowered as follows:
stencil.load
triggers a host-to-device transfer of z-value tensors to each of the targeted devicesstencil.store
likewise triggers a device-to-host transferstencil.apply
invokes the computationstencil.access
at non-zero x/y coordinates trigger device-to-device communicationstencil.access
at zero x/y coordinates trigger device-internal computationarith.<anything>
trigger device-internal computationTodo:
linalg.map
for future updatesLimitations: