czh978 commented on code in PR #11141:
URL: https://github.com/apache/tvm/pull/11141#discussion_r874480939
##########
python/tvm/relay/frontend/onnx.py:
##########
@@ -2349,30 +2349,18 @@ class LogSoftmax(OnnxOpConverter):
"""Operator converter for Softmax."""
@classmethod
- def run_calculation(cls, x, axes):
+ def run_calculation(cls, inputs, attr, params, opset):
"""Run the calculation for Log Softmax calculation."""
- m = _op.max(x, axes, keepdims=True)
- e = _op.exp(x - m)
- s = _op.sum(e, axes, keepdims=True)
- return x - m - _op.log(s)
Review Comment:
Your concern is right, but the underlying computation of the softmax
operator already takes the overflow into account.
The code is as below:
https://github.com/apache/tvm/blob/a3a4155943cd1a8ced35060902907cde2ba44cd8/include/tvm/topi/nn/softmax.h#L86-L114
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]