Skip to content

Commit 7293e41

Browse files
committed
Add correct stub
1 parent 61f5d1c commit 7293e41

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

.github/workflows/_build_linux_cuda.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ jobs:
171171
172172
- name: Check Stub
173173
run: |
174+
set -ex
175+
174176
python scripts/generate_stub.py -o ~/stubs
175177
cp ~/stubs/* src/spdl/io/lib/
176178
git diff --exit-code
@@ -188,6 +190,8 @@ jobs:
188190
- name: Unit test
189191
if: '!cancelled()'
190192
run: |
193+
set -ex
194+
191195
# Run test
192196
python -c 'import spdl.io.utils;assert spdl.io.utils.built_with_cuda()'
193197
if "${{ inputs.use-nvdec == 'nvdec' }}" ; then

scripts/generate_stub.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
"""Generate interface files for extension modules."""
1010

11-
import logging
1211
from argparse import ArgumentParser
1312
from pathlib import Path
1413

@@ -31,7 +30,6 @@ def _generate(mod, output):
3130

3231
def _main():
3332
args = _parse_args()
34-
logging.basicConfig(level=logging.DEBUG)
3533
args.output_dir.mkdir(exist_ok=True, parents=True)
3634
_generate(_archive, args.output_dir / "_archive.pyi")
3735
_generate(_import_libspdl(), args.output_dir / "_libspdl.pyi")

src/spdl/io/lib/_libspdl_cuda.pyi

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from collections.abc import Callable, Sequence
2+
from typing import Annotated, overload
3+
4+
from numpy.typing import NDArray
5+
6+
import spdl.io.lib._spdl_ffmpeg8
7+
8+
9+
class CUDAConfig:
10+
pass
11+
12+
def cuda_config(device_index: int, stream: int = 0, allocator: tuple[Callable[[int, int, int], int], Callable[[int], None]] | None = None) -> CUDAConfig: ...
13+
14+
class CUDABuffer:
15+
@property
16+
def __cuda_array_interface__(self) -> dict: ...
17+
18+
@property
19+
def device_index(self) -> int: ...
20+
21+
class NvDecDecoder:
22+
def reset(self) -> None: ...
23+
24+
def init(self, device_config: CUDAConfig, codec: spdl.io.lib._spdl_ffmpeg8.VideoCodec, *, crop_left: int = 0, crop_top: int = 0, crop_right: int = 0, crop_bottom: int = 0, scale_width: int = -1, scale_height: int = -1) -> None: ...
25+
26+
def decode(self, packets: spdl.io.lib._spdl_ffmpeg8.VideoPackets) -> list[CUDABuffer]: ...
27+
28+
def flush(self) -> list[CUDABuffer]: ...
29+
30+
@overload
31+
def decode_image_nvjpeg(data: bytes, *, device_config: CUDAConfig, scale_width: int = -1, scale_height: int = -1, pix_fmt: str = 'rgb', _zero_clear: bool = False) -> None: ...
32+
33+
@overload
34+
def decode_image_nvjpeg(data: Sequence[bytes], *, device_config: CUDAConfig, scale_width: int, scale_height: int, pix_fmt: str = 'rgb', _zero_clear: bool = False) -> None: ...
35+
36+
def cpu_storage(size: int) -> spdl.io.lib._spdl_ffmpeg8.CPUStorage: ...
37+
38+
@overload
39+
def transfer_buffer(buffer: spdl.io.lib._spdl_ffmpeg8.CPUBuffer, *, device_config: CUDAConfig) -> CUDABuffer: ...
40+
41+
@overload
42+
def transfer_buffer(buffer: Annotated[NDArray, dict(order='C', device='cpu')], *, device_config: CUDAConfig) -> CUDABuffer: ...
43+
44+
def transfer_buffer_cpu(buffer: Annotated[NDArray, dict(order='C', device='cuda')]) -> spdl.io.lib._spdl_ffmpeg8.CPUBuffer: ...
45+
46+
def init() -> None: ...
47+
48+
def built_with_cuda() -> bool: ...
49+
50+
def built_with_nvcodec() -> bool: ...
51+
52+
def built_with_nvjpeg() -> bool: ...
53+
54+
def synchronize_stream(arg: CUDAConfig, /) -> None: ...
55+
56+
def nv12_to_planar_rgb(buffers: Sequence[CUDABuffer], *, device_config: CUDAConfig, matrix_coeff: int = 1) -> CUDABuffer: ...
57+
58+
def nv12_to_planar_bgr(buffers: Sequence[CUDABuffer], *, device_config: CUDAConfig, matrix_coeff: int = 1) -> CUDABuffer: ...

0 commit comments

Comments
 (0)