[Inductor][CPP] Fix the test case of test_linear_reuse_kernels (#163723)

Fixes #163491.
Add tolerances to make `test_linear_reuse_kernels` more stable.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/163723
Approved by: https://github.com/leslie-fang-intel
This commit is contained in:
CaoE
2025-09-29 05:29:01 +00:00
committed by PyTorch MergeBot
parent eb4361a801
commit b9854c9d89

View File

@ -2936,10 +2936,20 @@ class TestSelectAlgorithm(BaseTestSelectAlgorithm):
x = torch.randn(batch_size, in_features).to(dtype=dtype) x = torch.randn(batch_size, in_features).to(dtype=dtype)
mod = M().to(dtype=dtype).eval() mod = M().to(dtype=dtype).eval()
self.common(mod, (x)) with verify(dtype) as (atol, rtol):
_, code = run_and_get_cpp_code(mod, x) ref_res = mod(x)
# Check that only 2 kernels are in the generated code m = torch.compile(mod)
assert code.count("AMXState amx_state") == 2 res, code = run_and_get_cpp_code(m, x)
self.assertEqual(
res,
ref_res,
atol=atol,
rtol=rtol,
equal_nan=True,
exact_dtype=True,
)
# Check that only 2 kernels are in the generated code
assert code.count("AMXState amx_state") == 2
@dynamo_config.patch({"dynamic_shapes": True, "assume_static_by_default": False}) @dynamo_config.patch({"dynamic_shapes": True, "assume_static_by_default": False})