You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "CharlieFRuan (via GitHub)" <gi...@apache.org> on 2024/01/19 19:48:23 UTC

[PR] [Metal] Dispatch numerically stable tanh for metal [tvm]

CharlieFRuan opened a new pull request, #16438:
URL: https://github.com/apache/tvm/pull/16438

   Prior to this PR, `tanh(x)`returns `NaN` on metal when `x > 45.0`.
   
   Metal's built-in tanh is implemented as `(t - 1.0) / (t + 1.0)`, where `t = exp(2.0 * x)`. Hence for large `x`, `t` becomes `inf`, causing `tanh(x)` to be `NaN`.
   
   A numerically stable `tanh` is implemented for `llvm`, this PR lifts it to `src/target/intrin_rule.cc` and apply the same rule for metal as well.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Metal] Dispatch numerically stable tanh for metal [tvm]

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao merged PR #16438:
URL: https://github.com/apache/tvm/pull/16438


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Metal] Dispatch numerically stable tanh for metal [tvm]

Posted by "CharlieFRuan (via GitHub)" <gi...@apache.org>.
CharlieFRuan commented on PR #16438:
URL: https://github.com/apache/tvm/pull/16438#issuecomment-1901013499

   cc @MasterJH5574 @tqchen 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Metal] Dispatch numerically stable tanh for metal [tvm]

Posted by "CharlieFRuan (via GitHub)" <gi...@apache.org>.
CharlieFRuan commented on PR #16438:
URL: https://github.com/apache/tvm/pull/16438#issuecomment-1901330874

   Observed the same issue on webgpu as well; updated to fix.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org