-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6123: Add support for backward mvlgamma
- Loading branch information
1 parent
b76f05a
commit f895ddb
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
tests/tt_eager/python_api_testing/unit_testing/backward_ops/test_backward_mvlgamma.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import torch | ||
import pytest | ||
import tt_lib | ||
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import compare_results, data_gen_pt_tt | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_shapes", | ||
( | ||
(torch.Size([1, 1, 32, 32])), | ||
(torch.Size([1, 1, 320, 384])), | ||
(torch.Size([1, 3, 320, 384])), | ||
), | ||
) | ||
def test_bw_mvlgamma(input_shapes, device): | ||
grad_data, grad_tensor = data_gen_pt_tt(input_shapes, device) | ||
|
||
in_data = torch.Tensor(size=input_shapes).uniform_(3, 10) | ||
in_data.requires_grad = True | ||
input_tensor = ( | ||
tt_lib.tensor.Tensor(in_data, tt_lib.tensor.DataType.BFLOAT16).to(tt_lib.tensor.Layout.TILE).to(device) | ||
) | ||
|
||
pyt_y = torch.mvlgamma(in_data, 4) | ||
|
||
tt_output_tensor_on_device = tt_lib.tensor.mvlgamma_bw(grad_tensor, input_tensor) | ||
|
||
in_data.retain_grad() | ||
|
||
pyt_y.backward(gradient=grad_data) | ||
|
||
golden_tensor = [in_data.grad] | ||
comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor) | ||
|
||
assert comp_pass |
This file contains 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
This file contains 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
This file contains 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