Skip to content

adds available_device to test_js_divergence.py #3335 #3362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tests/ignite/metrics/test_js_divergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ def test_case(request):


@pytest.mark.parametrize("n_times", range(5))
def test_compute(n_times, test_case: Tuple[Tensor, Tensor, int]):
def test_compute(n_times, test_case: Tuple[Tensor, Tensor, int], available_device):
y_pred, y, batch_size = test_case

js_div = JSDivergence()
js_div = JSDivergence(device=available_device)
assert js_div._device == torch.device(available_device)

js_div.reset()
if batch_size > 1:
Expand All @@ -85,8 +86,9 @@ def test_compute(n_times, test_case: Tuple[Tensor, Tensor, int]):
assert pytest.approx(np_res, rel=1e-4) == res


def test_accumulator_detached():
js_div = JSDivergence()
def test_accumulator_detached(available_device):
js_div = JSDivergence(device=available_device)
assert js_div._device == torch.device(available_device)

y_pred = torch.tensor([[2.0, 3.0], [-2.0, 1.0]], dtype=torch.float)
y = torch.tensor([[-2.0, 1.0], [2.0, 3.0]], dtype=torch.float)
Expand Down
Loading