Merged
Conversation
apbose
reviewed
May 16, 2024
narendasan
reviewed
May 17, 2024
apbose
reviewed
May 21, 2024
apbose
reviewed
May 23, 2024
zewenli98
reviewed
May 24, 2024
| ) | ||
|
|
||
| # TensorRT ITopKLayer does not have a sorted flag, it is always returning the sorted topk elements | ||
| # so here no matter sorted is True or False the returned the topk Tensor object is always sorted |
Collaborator
There was a problem hiding this comment.
@narendasan If TRT doesn't have sorted flag, the outputs of TRT and pytorch might be different. e.g.,
>>> x
tensor([ 1.2096, -0.0950, 0.7965, -0.0960, 0.7188, -1.5562])
>>> torch.ops.aten.topk.default(x, 4, sorted=False)
(tensor([ 0.7188, 1.2096, 0.7965, -0.0950]), tensor([4, 0, 2, 1]))
>>> torch.ops.aten.topk.default(x, 4, sorted=True)
(tensor([ 1.2096, 0.7965, 0.7188, -0.0950]), tensor([0, 2, 4, 1]))
Is the current implementation acceptable?
Collaborator
There was a problem hiding this comment.
yeah thats a valid point, and I was also wondering this in the test cases-
In the above you mentioned that topk in TRT returns sorted by default. So was curious if there was a mismatch in the test cases where sorted=False.
Looks like in the test cases, the default flag from torch matches the TRT sorted output.
I missed this point in the next review. @lanluo-nvidia you have more insights?
laikhtewari
pushed a commit
that referenced
this pull request
May 24, 2024
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.
Description
Add aten.topk implementation
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: