Skip to content

Commit

Permalink
Added fusion for squared relu (NVIDIA#8963)
Browse files Browse the repository at this point in the history
* Added fusion for squared relu

Signed-off-by: Selvaraj Anandaraj <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Selvaraj Anandaraj <[email protected]>
Co-authored-by: Selvaraj Anandaraj <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Harper <[email protected]>
  • Loading branch information
4 people authored and galv committed Apr 29, 2024
1 parent b764319 commit 539d72c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nemo/collections/nlp/modules/common/megatron/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ def openai_gelu(x):
return gelu_impl(x)


try:
jit_fuser = torch.compile
except:
jit_fuser = torch.jit.script


@jit_fuser
def squared_relu(x):
return torch.pow(torch.nn.functional.relu(x), 2)

Expand Down

0 comments on commit 539d72c

Please sign in to comment.