Open
Conversation
New NKI kernel!
| sz_cin, sz_hin, sz_win = in_tensor.shape | ||
| sz_hout = (sz_hin + 2*padding - kernel_size) // stride + 1 | ||
| sz_wout = (sz_win + 2*padding - kernel_size) // stride + 1 | ||
|
|
Contributor
There was a problem hiding this comment.
let's add assertions on expectations for the shape and parameter values here.
| sz_p = sz_cin | ||
|
|
||
| # Generate pool index patterns with stride | ||
| i0 = nl.arange(sz_p)[:, None, None, None, None] # Channel dim |
Contributor
There was a problem hiding this comment.
let's use mgrid for this
| i4 = nl.arange(kernel_size)[None, None, None, None, :] # Pool width | ||
|
|
||
| # Load input data | ||
| in_tile: tensor[sz_p, sz_hin, sz_win] = nl.load(in_tensor) |
Contributor
There was a problem hiding this comment.
per the docs here, your partition dimension must be the first dimension. These should be 2d tiles. We're deprecating block dimension on SBUF.
Contributor
Author
There was a problem hiding this comment.
@JonathanHenson The tiling was based on the average_pool2D example.
Will that be updated any time soon?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To replace the MaxPool2D function. Not sure if it is faster than a traced pytorch version or not.
However, it does show an interesting use of masking to avoid extra memory writes. (instead of padding with -inf rows and columns on every edge, I just adjust my indices and mask the values for the columns I didn't insert).
All tests are included in the code.
Testing:
Please see detailed unit test requirements in the CONTRIBUTING.md
nki.baremetalnki.benchmarkPull Request Checklist