From 3bf35c0b2dcc7d69bf1d10e0d7b133ef8b66228e Mon Sep 17 00:00:00 2001 From: Dmitry Sidorov Date: Tue, 12 Aug 2025 17:40:41 +0200 Subject: [PATCH] [NFC] Apply format on test files --- tests/test_torch_custom_pipeline.py | 5 ++++- tests/test_torch_mlir_linear.py | 1 + tests/test_torch_mock_opt.py | 6 +++++- tests/test_torch_user_controlled_ir_print.py | 2 +- tests/test_triton_mock_opt.py | 2 ++ tests/test_wrong_command_line.py | 1 + 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/test_torch_custom_pipeline.py b/tests/test_torch_custom_pipeline.py index e17f90b..22b02e1 100644 --- a/tests/test_torch_custom_pipeline.py +++ b/tests/test_torch_custom_pipeline.py @@ -40,7 +40,10 @@ def test_torch_custom_pipeline(ir_type): output = response.json()["output"] assert "===== Initial IR =====" in output - assert "llvm.func @main(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64)" in output + assert ( + "llvm.func @main(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64)" + in output + ) assert "===== IR after mlir-translate --mlir-to-llvmir =====" in output assert "define { ptr, ptr, i64, [2 x i64], [2 x i64] } @main" in output assert "===== IR after llc -mtriple=nvptx64 =====" in output diff --git a/tests/test_torch_mlir_linear.py b/tests/test_torch_mlir_linear.py index 6195edb..53f1448 100644 --- a/tests/test_torch_mlir_linear.py +++ b/tests/test_torch_mlir_linear.py @@ -4,6 +4,7 @@ API_URL = os.environ.get("API_URL", "http://localhost:8000/generate_ir") + def test_torch_mlir_linear(): code = """ import torch diff --git a/tests/test_torch_mock_opt.py b/tests/test_torch_mock_opt.py index ba83e62..fc6c9ed 100644 --- a/tests/test_torch_mock_opt.py +++ b/tests/test_torch_mock_opt.py @@ -5,6 +5,7 @@ import pytest import httpx + @pytest.fixture(scope="session") def mock_opt_path(): cpp_src = os.path.abspath("tests/cpp_sources/mock-opt.cpp") @@ -17,6 +18,7 @@ def mock_opt_path(): shutil.rmtree(build_dir) + def test_torch_mock_opt(mock_opt_path): code = """ import torch @@ -41,7 +43,9 @@ def forward(self, x): "dump_after_each_opt": True, } - response = httpx.post(os.environ.get("API_URL", "http://localhost:8000/generate_ir"), json=payload) + response = httpx.post( + os.environ.get("API_URL", "http://localhost:8000/generate_ir"), json=payload + ) assert response.status_code == 200 assert "graph(%self.1 : __torch__.builtins.MyModel," in response.json()["output"] assert "test mock_opt 42" in response.json()["output"] diff --git a/tests/test_torch_user_controlled_ir_print.py b/tests/test_torch_user_controlled_ir_print.py index 5de2290..3740c7a 100644 --- a/tests/test_torch_user_controlled_ir_print.py +++ b/tests/test_torch_user_controlled_ir_print.py @@ -48,4 +48,4 @@ def forward(self, x): assert "affine_map" in ir assert "memref.global" in ir assert "arith.constant" in ir - assert "linalg.matmul" in ir \ No newline at end of file + assert "linalg.matmul" in ir diff --git a/tests/test_triton_mock_opt.py b/tests/test_triton_mock_opt.py index 2fe993e..528d77b 100644 --- a/tests/test_triton_mock_opt.py +++ b/tests/test_triton_mock_opt.py @@ -12,6 +12,7 @@ reason="No NVIDIA GPU detected. Skip", ) + @pytest.fixture(scope="session") def mock_opt_path(): cpp_src = os.path.abspath("tests/cpp_sources/mock-opt.cpp") @@ -24,6 +25,7 @@ def mock_opt_path(): shutil.rmtree(build_dir) + def test_triton_mock_opt(mock_opt_path): code = """ import triton diff --git a/tests/test_wrong_command_line.py b/tests/test_wrong_command_line.py index f65506d..28613ae 100644 --- a/tests/test_wrong_command_line.py +++ b/tests/test_wrong_command_line.py @@ -20,6 +20,7 @@ def forward(self, x): example_input = torch.randn(4, 4) """ + @pytest.mark.parametrize("ir_type", ["llvm_mlir"]) def test_wrong_command_line(ir_type): payload = {