File: test_issue564.py

package info (click to toggle)
python-thinc 9.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,896 kB
  • sloc: python: 17,122; javascript: 1,559; ansic: 342; makefile: 15; sh: 13
file content (21 lines) | stat: -rw-r--r-- 520 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pytest

from thinc.api import CupyOps
from thinc.compat import has_torch, has_torch_cuda_gpu


@pytest.mark.skipif(not has_torch, reason="needs PyTorch")
@pytest.mark.skipif(not has_torch_cuda_gpu, reason="needs a GPU")
def test_issue564():
    import torch

    if CupyOps.xp is not None:
        ops = CupyOps()
        t = torch.zeros((10, 2)).cuda()
        a = ops.asarray(t)

        assert a.shape == t.shape
        ops.xp.testing.assert_allclose(
            a,
            ops.alloc2f(10, 2),
        )