Skip to content

Commit

Permalink
#10079: Move Unary Backward ops to TTNN (#10145)
Browse files Browse the repository at this point in the history
* #10079: Merge sin_bw to TTNN

* #10079: Merge sinh_bw to TTNN

* #10079: Merge log10_bw to TTNN

* #10079: Merge log1p_bw to TTNN

* #10079: Merge erfc_bw to TTNN

* #10079: Merge ceil_bw to TTNN

* #10079: Merge softsign_bw to TTNN

* #10079: Update file
  • Loading branch information
mouliraj-mcw authored Jul 12, 2024
1 parent e2c5477 commit 5506790
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 337 deletions.
7 changes: 7 additions & 0 deletions docs/source/ttnn/ttnn/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ Pointwise Unary
ttnn/atanh_bw
ttnn/asin_bw
ttnn/asinh_bw
ttnn/sin_bw
ttnn/sinh_bw
ttnn/log10_bw
ttnn/log1p_bw
ttnn/erfc_bw
ttnn/ceil_bw
ttnn/softsign_bw

Pointwise Binary
================
Expand Down
14 changes: 0 additions & 14 deletions docs/source/ttnn/ttnn/dependencies/tt_lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -846,18 +846,8 @@ Backward Operations

.. autofunction:: tt_lib.tensor.angle_bw

.. autofunction:: tt_lib.tensor.sin_bw

.. autofunction:: tt_lib.tensor.sinh_bw

.. autofunction:: tt_lib.tensor.log10_bw

.. autofunction:: tt_lib.tensor.log1p_bw

.. autofunction:: tt_lib.tensor.erf_bw

.. autofunction:: tt_lib.tensor.erfc_bw

.. autofunction:: tt_lib.tensor.digamma_bw

.. autofunction:: tt_lib.tensor.deg2rad_bw
Expand All @@ -868,12 +858,8 @@ Backward Operations

.. autofunction:: tt_lib.tensor.logiteps_bw

.. autofunction:: tt_lib.tensor.softsign_bw

.. autofunction:: tt_lib.tensor.sign_bw

.. autofunction:: tt_lib.tensor.ceil_bw

.. autofunction:: tt_lib.tensor.log2_bw

.. autofunction:: tt_lib.tensor.ge_bw
Expand Down
6 changes: 6 additions & 0 deletions docs/source/ttnn/ttnn/ttnn/ceil_bw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _ttnn.ceil_bw:

ttnn.ceil_bw
#############

.. autofunction:: ttnn.ceil_bw
6 changes: 6 additions & 0 deletions docs/source/ttnn/ttnn/ttnn/erfc_bw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _ttnn.erfc_bw:

ttnn.erfc_bw
#############

.. autofunction:: ttnn.erfc_bw
6 changes: 6 additions & 0 deletions docs/source/ttnn/ttnn/ttnn/log10_bw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _ttnn.log10_bw:

ttnn.log10_bw
##############

.. autofunction:: ttnn.log10_bw
7 changes: 7 additions & 0 deletions docs/source/ttnn/ttnn/ttnn/log1p_bw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.. _ttnn.log1p_bw:

ttnn.log1p_bw
##############

.. autofunction:: ttnn.log1p_bw
6 changes: 6 additions & 0 deletions docs/source/ttnn/ttnn/ttnn/sin_bw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _ttnn.sin_bw:

ttnn.sin_bw
############

.. autofunction:: ttnn.sin_bw
6 changes: 6 additions & 0 deletions docs/source/ttnn/ttnn/ttnn/sinh_bw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _ttnn.sinh_bw:

ttnn.sinh_bw
#############

.. autofunction:: ttnn.sinh_bw
6 changes: 6 additions & 0 deletions docs/source/ttnn/ttnn/ttnn/softsign_bw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _ttnn.softsign_bw:

ttnn.softsign_bw
#################

.. autofunction:: ttnn.softsign_bw
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import compare_pcc, data_gen_with_range
import ttnn
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range, compare_pcc


@pytest.mark.parametrize(
Expand All @@ -21,7 +21,7 @@ def test_bw_ceil(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, -100, 100, device, True)

pyt_y = torch.ceil(in_data)
tt_output_tensor_on_device = tt_lib.tensor.ceil_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.ceil_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import compare_pcc, data_gen_with_range
import ttnn
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range, compare_pcc


@pytest.mark.parametrize(
Expand All @@ -21,7 +21,7 @@ def test_bw_erfc(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, -200, 199, device, required_grad=True)
pyt_y = torch.erfc(in_data)

tt_output_tensor_on_device = tt_lib.tensor.erfc_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.erfc_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import (
compare_pcc,
data_gen_with_range,
)
import ttnn
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range, compare_pcc


@pytest.mark.parametrize(
Expand All @@ -23,7 +20,7 @@ def test_bw_log10(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, -100, 100, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, -10, 10, device)

tt_output_tensor_on_device = tt_lib.tensor.log10_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.log10_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import (
compare_pcc,
data_gen_with_range,
)
import ttnn
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range, compare_pcc


@pytest.mark.parametrize(
Expand All @@ -23,7 +20,7 @@ def test_bw_log1p(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, -100, 100, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, -10, 10, device)

tt_output_tensor_on_device = tt_lib.tensor.log1p_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.log1p_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_with_range, compare_pcc
import ttnn
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range, compare_pcc
from math import pi


Expand All @@ -21,7 +21,7 @@ def test_bw_sin(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, 0, 2 * pi, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, -10, 10, device, False)

tt_output_tensor_on_device = tt_lib.tensor.sin_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.sin_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import (
data_gen_with_range,
compare_pcc,
)
import ttnn
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range, compare_pcc

from models.utility_functions import (
skip_for_wormhole_b0,
)
Expand All @@ -26,7 +24,7 @@ def test_bw_sinh(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, -9, 9, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, -20, 20, device)

tt_output_tensor_on_device = tt_lib.tensor.sinh_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.sinh_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand All @@ -52,7 +50,7 @@ def test_bw_sinh_inf(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, 89, 96, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, -10, 10, device)

tt_output_tensor_on_device = tt_lib.tensor.sinh_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.sinh_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand All @@ -78,7 +76,7 @@ def test_bw_sinh_neg_inf(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, -97, -89, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, -10, 10, device)

tt_output_tensor_on_device = tt_lib.tensor.sinh_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.sinh_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand All @@ -101,7 +99,7 @@ def test_bw_sinh_nan_test1(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, 86, 89, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, 35, 50, device)

tt_output_tensor_on_device = tt_lib.tensor.sinh_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.sinh_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand All @@ -124,7 +122,7 @@ def test_bw_sinh_nan_test2(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, 86, 89, device, True)
grad_data, grad_tensor = data_gen_with_range(input_shapes, -50, -35, device)

tt_output_tensor_on_device = tt_lib.tensor.sinh_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.sinh_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import compare_pcc, data_gen_with_range
import ttnn
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range, compare_pcc


@pytest.mark.parametrize(
Expand All @@ -21,7 +21,7 @@ def test_bw_softsign(input_shapes, device):
in_data, input_tensor = data_gen_with_range(input_shapes, -100, 100, device, True)

pyt_y = torch.nn.functional.softsign(in_data)
tt_output_tensor_on_device = tt_lib.tensor.softsign_bw(grad_tensor, input_tensor)
tt_output_tensor_on_device = ttnn.softsign_bw(grad_tensor, input_tensor)

in_data.retain_grad()

Expand Down
Loading

0 comments on commit 5506790

Please sign in to comment.