pytorch
1# Owner(s): ["module: bazel"]
2
3"""
4This test module contains a minimalistic "smoke tests" for the bazel build.
5
6Currently it doesn't use any testing framework (i.e. pytest)
7TODO: integrate this into the existing pytorch testing framework.
8
9The name uses underscore `_test_bazel.py` to avoid globbing into other non-bazel configurations.
10"""
11
12import torch13
14def test_sum() -> None:15assert torch.eq(torch.tensor([[1, 2, 3]]) + torch.tensor([[4, 5, 6]]), torch.tensor([[5, 7, 9]])).all()16
17def test_simple_compile_eager() -> None:18
19def foo(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:20a = torch.sin(x)21b = torch.cos(y)22return a + b23
24opt_foo1 = torch.compile(foo, backend="eager")25# just check that we can run without raising an Exception26assert opt_foo1(torch.randn(10, 10), torch.randn(10, 10)) is not None27
28
29test_sum()30test_simple_compile_eager()31