conftest.py 336 Bytes
Newer Older
cmx's avatar
cmx committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import pytest
import torch

from liger_kernel.utils import is_npu_available


@pytest.fixture(autouse=True)
def clear_gpu_cache():
    yield
    if torch.cuda.is_available():
        torch.cuda.empty_cache()
    elif is_npu_available():
        torch.npu.empty_cache()
    elif torch.xpu.is_available():
        torch.xpu.empty_cache()