AndrewZhaoLuo commented on code in PR #11141:
URL: https://github.com/apache/tvm/pull/11141#discussion_r874223094
##########
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:
I believe the reason it is done this way is numerical precision concerns. I
don't know how often res will underflow/overflow but I would lean toward
correctness rather than speed here. This mathematics will likely be fused later
on anyway I think
--
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]