Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions src/numpy-stubs/_core/_simd.pyi
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
import sys
from types import ModuleType
from typing import TypedDict, type_check_only
from typing import Required, TypedDict, type_check_only

# NOTE: these 6 are only defined on systems with an intel processor
# NOTE: these are only defined on (some) systems with an intel processor
SSE42: ModuleType | None = ...
FMA3: ModuleType | None = ...
AVX2: ModuleType | None = ...
AVX512F: ModuleType | None = ...
AVX512_SKX: ModuleType | None = ...
if sys.platform == "linux":
X86_V4: ModuleType | None = ...
X86_V3: ModuleType | None = ...
X86_V4: ModuleType | None = ...

# NOTE: these 2 are only defined on systems with an arm processor
ASIMD: ModuleType | None = ...
NEON: ModuleType | None = ...

# NOTE: This is only defined on systems with an riscv64 processor.
RVV: ModuleType | None = ...

baseline: ModuleType | None = ...

@type_check_only
class SimdTargets(TypedDict):
class SimdTargets(TypedDict, total=False):
# x86
SSE42: ModuleType | None
AVX2: ModuleType | None
FMA3: ModuleType | None
AVX512F: ModuleType | None
AVX512_SKX: ModuleType | None
X86_V3: ModuleType | None
X86_V4: ModuleType | None

baseline: ModuleType | None
# ARM
ASIMD: ModuleType | None
NEON: ModuleType | None

# RISC-V
RVV: ModuleType | None

baseline: Required[ModuleType | None]

targets: SimdTargets = ...

Expand Down
3 changes: 3 additions & 0 deletions tool/allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ numpy(\.\w+)?\.tests.*
numpy(\..+)?\.float(96|128)
numpy(\..+)?\.complex(192|256)

# system-dependent private SIMD submodules
numpy\._core\._simd\.(SSE42|FMA3|AVX(2|512F|512_SKX)|X86_V(3|4)|ASIMD|NEON|RVV)

# these are always either missing float96/complex192 or float128/complex256
numpy\.__all__
numpy\._?core\.__all__
Expand Down
7 changes: 0 additions & 7 deletions tool/allowlists/simd.txt

This file was deleted.

13 changes: 0 additions & 13 deletions tool/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@
ALLOWLISTS = ["common.txt", f"py3{sys.version_info.minor}.txt"]


def __check_simd() -> None:
try:
from numpy._core import _simd # noqa: PLC0415, PLC2701
except ImportError:
return

if not hasattr(_simd, "AVX512F"):
ALLOWLISTS.append("simd.txt")


__check_simd()


def _allowlists() -> list[str]:
relpath = (TOOL_DIR / "allowlists").relative_to(CWD)
return [str(relpath / fname) for fname in ALLOWLISTS]
Expand Down