| 914 | |
| 915 | |
| 916 | def restrict_platform(min_compute_cap=None, platforms=None): |
| 917 | spec = [] |
| 918 | if min_compute_cap is not None: |
| 919 | compute_cap = get_arch() |
| 920 | cond = f"compute cap ({compute_cap}) >= {min_compute_cap}" |
| 921 | spec.append((cond, compute_cap >= min_compute_cap)) |
| 922 | if platforms is not None: |
| 923 | import platform |
| 924 | |
| 925 | cond = f"platform.machine() ({platform.machine()}) in {platforms}" |
| 926 | spec.append((cond, platform.machine() in platforms)) |
| 927 | |
| 928 | def decorator(fun): |
| 929 | if all(val for _, val in spec): |
| 930 | return fun |
| 931 | else: |
| 932 | |
| 933 | @functools.wraps(fun) |
| 934 | def dummy_case(*args, **kwargs): |
| 935 | print(f"Omitting test case in unsupported env: `{spec}`") |
| 936 | |
| 937 | return dummy_case |
| 938 | |
| 939 | return decorator |
| 940 | |
| 941 | |
| 942 | def check_numba_compatibility_cpu(if_skip=True): |