conftest.py 1.1 KB
Newer Older
1
import os
2
import platform
3 4
import sys

5 6
import pytest

7 8 9
import megengine.functional
import megengine.module
from megengine import Parameter
10
from megengine.core._imperative_rt.core2 import sync
11 12 13
from megengine.distributed.helper import get_device_count_by_fork
from megengine.jit import trace as _trace
from megengine.module import Linear, Module
14

15
sys.path.append(os.path.join(os.path.dirname(__file__), "helpers"))
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

_ngpu = get_device_count_by_fork("gpu")


@pytest.fixture(autouse=True)
def skip_by_ngpu(request):
    if request.node.get_closest_marker("require_ngpu"):
        require_ngpu = int(request.node.get_closest_marker("require_ngpu").args[0])
        if require_ngpu > _ngpu:
            pytest.skip("skipped for ngpu unsatisfied: {}".format(require_ngpu))


@pytest.fixture(autouse=True)
def skip_distributed(request):
    if request.node.get_closest_marker("distributed_isolated"):
        if platform.system() in ("Windows", "Darwin"):
            pytest.skip(
                "skipped for distributed unsupported at platform: {}".format(
                    platform.system()
                )
            )