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 torch 13 14 15def 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 21def 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 32test_sum() 33test_simple_compile_eager() 34