Created
January 5, 2025 15:38
-
-
Save alexdremov/1d854039dfc05e4a531a5c96c91126f6 to your computer and use it in GitHub Desktop.
Code snippet uploaded via Python script (py)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
row_minus_max = row - tl.max(row, axis=1, keep_dims=True) | |
row_minus_max = tl.where(cols_mask, row_minus_max, -float('inf')) | |
numerator = tl.exp(row_minus_max) | |
denominator = tl.sum(numerator, axis=1, keep_dims=True) | |
softmax_output = numerator / denominator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment