pytorch

Форк
0
/
_test_bazel.py 
33 строки · 909.0 Байт
1
# Owner(s): ["module: bazel"]
2

3
"""
4
This test module contains a minimalistic "smoke tests" for the bazel build.
5

6
Currently it doesn't use any testing framework (i.e. pytest)
7
TODO: integrate this into the existing pytorch testing framework.
8

9
The name uses underscore `_test_bazel.py` to avoid globbing into other non-bazel configurations.
10
"""
11

12
import torch
13

14

15
def test_sum() -> None:
16
    assert torch.eq(
17
        torch.tensor([[1, 2, 3]]) + torch.tensor([[4, 5, 6]]), torch.tensor([[5, 7, 9]])
18
    ).all()
19

20

21
def test_simple_compile_eager() -> None:
22
    def foo(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
23
        a = torch.sin(x)
24
        b = torch.cos(y)
25
        return a + b
26

27
    opt_foo1 = torch.compile(foo, backend="eager")
28
    # just check that we can run without raising an Exception
29
    assert opt_foo1(torch.randn(10, 10), torch.randn(10, 10)) is not None
30

31

32
test_sum()
33
test_simple_compile_eager()
34

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.