Files
pytorch/test/export/test_functionalized_assertions.py
Harmen Stoppels 01554c7b5a fix incorrect literal strings / accidental tuples (#146037)
* `expr,` is short for `(expr,)`
* literal strings over multiple lines need to escape the newline `\` or use `(...)`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/146037
Approved by: https://github.com/Skylion007
2025-02-03 15:08:11 +00:00

32 lines
985 B
Python

# Owner(s): ["oncall: export"]
import torch
from torch.testing._internal.common_utils import run_tests, TestCase
class TestFuntionalAssertions(TestCase):
def test_functional_assert_async_msg(self) -> None:
dep_token = torch.ops.aten._make_dep_token()
self.assertEqual(
torch.ops.aten._functional_assert_async.msg(
torch.tensor(1), "test msg", dep_token
),
dep_token,
)
with self.assertRaisesRegex(RuntimeError, "test msg"):
torch.ops.aten._functional_assert_async.msg(
torch.tensor(0), "test msg", dep_token
)
def test_functional_sym_constrain_range(self) -> None:
dep_token = torch.ops.aten._make_dep_token()
self.assertEqual(
torch.ops.aten._functional_sym_constrain_range(
3, min=2, max=5, dep_token=dep_token
),
dep_token,
)
if __name__ == "__main__":
run_tests()