Repository navigation
[TF-TRT] Add LogSoftmax Support for TF-TRT - #57013
pavanimajety wants to merge 1 commit into
Conversation
tfeher
left a comment
There was a problem hiding this comment.
Hi Pavani, thank you for the PR, it looks great overall! But for new converters we prefer to derive them from OpConverterBase, I have left instructions on how to update.
| if (params->validation_only) return Status::OK(); | ||
|
|
||
| // Perform LogSoftmax operation - | ||
| // logsoftmax = logits - log(reduce_sum(exp(logits), axis)) |
There was a problem hiding this comment.
Is there a reason to prefer this formulation over log(softmax(logits))?
There was a problem hiding this comment.
I chose this way because tensorflow implements in Python using logsoftmax = logits - log(reduce_sum(exp(logits), axis)) .
There was a problem hiding this comment.
As clarified offline, TRT shall fuse both formulations, therefore it looks fine.
6c20977 to
ff037ca
Compare
tfeher
left a comment
There was a problem hiding this comment.
Thanks @pavanimajety for refactoring the converter, the PR looks good to me!
|
@pavanimajety Please add a PR description. |
bixia1
left a comment
There was a problem hiding this comment.
Looks good to me, just request fix to comment style and a PR description.
| // Perform LogSoftmax operation - | ||
| // logsoftmax = logits - log(reduce_sum(exp(logits), axis)) | ||
|
|
||
| // get the logits tensor |
There was a problem hiding this comment.
A comment usually starts with a capital letter and ends with a period, see the examples here.
Can you fix here and other place in this file?
There was a problem hiding this comment.
Fixed the comments.
bixia1
left a comment
There was a problem hiding this comment.
Looks good to me now. Would you please squash the commits?
Fix Softmax comments [TF-TRT] Move LogSoftmax to use OpConverterBase Fix compiler errors clang-format Undo changes to convert_nodes.cc Fix comments
dcc7347 to
1a8eb9a
Compare
Done. Thanks for reviewing |
3424d49 to
1a8eb9a
Compare
1a8eb9a to
9f60ba1
Compare
9f60ba1 to
1a8eb9a
Compare
|
Sorry, rebased for further work by mistake. |
|
This is merged, wonder why it doesn't show as merged here. |
Would you mind checking again? I don't see in tensorflow:master : https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/tf2tensorrt/convert/ops |
|
It did not show as merged here because copybara sync was broken. Fixed in big squash commit 49f97f1 |
Fix Softmax comments [TF-TRT] Move LogSoftmax to use OpConverterBase Fix compiler errors clang-format Undo changes to convert_nodes.cc Fix comments
This PR adds TF-TRT support to
tf.nn.log_softmaxoperation. This is performed using the formulalogsoftmax = logits - log(reduce_sum(exp(logits), axis=-1)). The implemented TRT layers are fused into a single op.@DEKHTIARJonathan @tfeher : Please review the changes.