[vulkan] Clamp tanh activation op input to preserve numerical stability (#73107)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/73107
It was observed that for large inputs (magnitude >= 30), the `tanh` shader would produce numerically unstable outputs when running with MoltenVK. The solution is to clamp the input with the range [-15, 15] before applying the `tanh` function.
Test Plan: Imported from OSS
Reviewed By: mikaylagawarecki
Differential Revision: D34354838
Pulled By: SS-JIA
fbshipit-source-id: ca2c5373987d9c086c3797a87ab08ffc189e2529
(cherry picked from commit 423bcbff64b2c3864f9d50314793ea70f5639af0)