Skip to content

Commit

Permalink
#4433: Refactor import statement and list creation
Browse files Browse the repository at this point in the history
  • Loading branch information
umadevimcw committed Dec 26, 2023
1 parent 8a04f8a commit 3cea6aa
Show file tree
Hide file tree
Showing 38 changed files with 75 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -28,8 +28,7 @@ def test_bw_abs(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor = [in_data.grad]

comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -30,9 +30,7 @@ def test_bw_add(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor.append(other_data.grad)
golden_tensor = [in_data.grad, other_data.grad]

status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -31,9 +31,7 @@ def test_bw_addalpha(input_shapes, alpha, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor.append(other_data.grad)
golden_tensor = [in_data.grad, other_data.grad]

status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand Down Expand Up @@ -36,10 +36,7 @@ def test_bw_addcdiv(input_shapes, value, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor.append(tensor1_data.grad)
golden_tensor.append(tensor2_data.grad)
golden_tensor = [in_data.grad, tensor1_data.grad, tensor2_data.grad]

status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand Down Expand Up @@ -36,10 +36,7 @@ def test_bw_addcmul(input_shapes, value, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor.append(tensor1_data.grad)
golden_tensor.append(tensor2_data.grad)
golden_tensor = [in_data.grad, tensor1_data.grad, tensor2_data.grad]

status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -30,7 +30,6 @@ def test_bw_binary_assign(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor = [in_data.grad]
status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -22,8 +22,6 @@ def test_bw_binary_le(input_shapes, device):

tt_output_tensor_on_device = tt_lib.tensor.binary_le_bw(grad_tensor, input_tensor)
pt_y = torch.zeros_like(grad_data)
golden_tensor = list()
golden_tensor.append(pt_y)
golden_tensor.append(pt_y)
golden_tensor = [pt_y, pt_y]
comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -30,7 +30,6 @@ def test_bw_clamp(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor = [in_data.grad]
comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -28,8 +28,7 @@ def test_bw_clamp_max(input_shapes, max, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor = [in_data.grad]

comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -28,8 +28,7 @@ def test_bw_clamp_min(input_shapes, min, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor = [in_data.grad]

comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -30,9 +30,7 @@ def test_bw_div(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor.append(other_data.grad)
golden_tensor = [in_data.grad, other_data.grad]

status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -28,8 +28,7 @@ def test_bw_exp(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor = [in_data.grad]

comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -22,15 +22,14 @@
# value: grad.sum()
# result: at::fill(self_t, value_t)
def test_bw_fill(input_shapes, device):
torch.manual_seed(12386)
# torch.manual_seed(12386)
grad_data, grad_tensor = data_gen_pt_tt(input_shapes, device)
pyt_y = torch.zeros_like(grad_data)
grad_sum = grad_data.sum()
pyt_y.fill_(grad_sum)

tt_output_tensor_on_device = tt_lib.tensor.fill_bw(grad_tensor)

golden_tensor = list()
golden_tensor.append(pyt_y)
golden_tensor = [pyt_y]
comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -24,7 +24,6 @@ def test_bw_fill_zero(input_shapes, device):
grad_data, grad_tensor = data_gen_pt_tt(input_shapes, device)
tt_output_tensor_on_device = tt_lib.tensor.fill_zero_bw(grad_tensor)
pyt_y = torch.zeros_like(grad_data)
golden_tensor = list()
golden_tensor.append(pyt_y)
golden_tensor = [pyt_y]
comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -22,8 +22,7 @@ def test_bw_unary_gt(input_shapes, device):

pyt_y = torch.zeros_like(grad_data)

golden_tensor = list()
golden_tensor.append(pyt_y)
golden_tensor = [pyt_y]

comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import compare_results, data_gen_pt_tt


@pytest.mark.parametrize(
Expand All @@ -27,8 +27,6 @@ def test_bw_log(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)

golden_tensor = [in_data.grad]
comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -21,8 +21,7 @@ def test_bw_unary_lt(input_shapes, device):
tt_output_tensor_on_device = tt_lib.tensor.lt_bw(grad_tensor)
pyt_y = torch.zeros_like(grad_data)

golden_tensor = list()
golden_tensor.append(pyt_y)
golden_tensor = [pyt_y]

comp_pass = compare_results(tt_output_tensor_on_device, golden_tensor)
assert comp_pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import compare_results, data_gen_pt_tt


@pytest.mark.parametrize(
Expand All @@ -30,9 +30,7 @@ def test_bw_max(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor.append(other_data.grad)
golden_tensor = [in_data.grad, other_data.grad]

status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -30,9 +30,6 @@ def test_bw_min(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data.grad)
golden_tensor.append(other_data.grad)

golden_tensor = [in_data.grad, other_data.grad]
status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import pytest
import tt_lib
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import *
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results


@pytest.mark.parametrize(
Expand All @@ -30,9 +30,7 @@ def test_bw_mul(input_shapes, device):

pyt_y.backward(gradient=grad_data)

golden_tensor = list()
golden_tensor.append(in_data_a.grad)
golden_tensor.append(in_data_b.grad)
golden_tensor = [in_data_a.grad, in_data_b.grad]

status = compare_results(tt_output_tensor_on_device, golden_tensor)
assert status
Loading

0 comments on commit 3cea6aa

Please sign in to comment.