Repository navigation
Add automatically-generated .pyi files to cuda_core #2061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a1b9c09
Add infrastructure for type-checking cuda_core
mdboom 317c54d
Update all type annotations so they pass type-checking
mdboom a2a17d1
Add new .pyi files
mdboom 1aeb0f9
Pin Cython version
mdboom ebf19fc
Merge remote-tracking branch 'upstream/main' into pyi-experiment
mdboom 9ae9666
Address feedback in the PR
mdboom 442d212
Fix tests
mdboom d296dbb
Merge remote-tracking branch 'upstream/main' into pyi-experiment
mdboom 7fe26fc
Complete type annotations for public APIs
mdboom 950d31c
Fix type annotations
mdboom 0db1a95
Merge remote-tracking branch 'upstream/main' into pyi-experiment
mdboom 006d6f9
Fix previous merge
mdboom d263672
Remove pre-cuda.bindings imports
mdboom a1c680d
Fix isinstance check
mdboom 7e8cb6f
Add CONTRIBUTING docs
mdboom b1def1b
More type annotations
mdboom 8970f7c
Fix build
mdboom a11d8b7
Merge remote-tracking branch 'upstream/main' into pyi-experiment
mdboom 70528ee
Fix types
mdboom dacb4d2
Merge branch 'main' into pyi-experiment
mdboom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_context.pyx | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Sequence | ||
| from dataclasses import dataclass | ||
|
|
||
| import cuda.bindings.driver | ||
| from cuda.core._device_resources import (DeviceResources, SMResource, | ||
| WorkqueueResource) | ||
| from cuda.core._stream import Stream | ||
|
|
||
|
|
||
| class Context: | ||
| """CUDA context wrapper. | ||
|
|
||
| Context objects represent CUDA contexts and cannot be instantiated directly. | ||
| Use Device or Stream APIs to obtain context objects. | ||
| """ | ||
|
|
||
| def close(self): | ||
| """Release this context wrapper's underlying CUDA handles.""" | ||
|
|
||
| def __init__(self, *args, **kwargs) -> None: | ||
| ... | ||
|
|
||
| @property | ||
| def handle(self) -> cuda.bindings.driver.CUcontext | None: | ||
| """Return the underlying CUcontext handle.""" | ||
|
|
||
| @property | ||
| def _handle(self) -> cuda.bindings.driver.CUcontext | None: | ||
| ... | ||
|
|
||
| @property | ||
| def is_green(self) -> bool: | ||
| """True if this context was created from device resources.""" | ||
|
|
||
| @property | ||
| def resources(self) -> DeviceResources: | ||
| """Query the hardware resources provisioned for this context. | ||
|
|
||
| For green contexts, returns the resources this context was created | ||
| with (SM partition, workqueue config). For primary contexts, returns | ||
| the full device resources. | ||
|
|
||
| Raises :class:`RuntimeError` if the context has been closed. | ||
| """ | ||
|
|
||
| def create_stream(self, options: object=None) -> Stream: | ||
| """Create a new stream bound to this green context. | ||
|
|
||
| This method is only available on green contexts. For primary | ||
| contexts, use :meth:`Device.create_stream` instead. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| options : :obj:`~_stream.StreamOptions`, optional | ||
| Customizable dataclass for stream creation options. | ||
|
|
||
| Returns | ||
| ------- | ||
| :obj:`~_stream.Stream` | ||
| Newly created stream object. | ||
| """ | ||
|
|
||
| def __eq__(self, other: object) -> bool: | ||
| ... | ||
|
|
||
| def __hash__(self) -> int: | ||
| ... | ||
|
|
||
| def __repr__(self) -> str: | ||
| ... | ||
|
|
||
| @dataclass | ||
| class ContextOptions: | ||
| """Options for context creation. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| resources : :obj:`~cuda.core.typing.DeviceResourcesType` | ||
| Device resources used to create a green context. | ||
| """ | ||
| resources: DeviceResourcesType | ||
| __all__ = ['Context', 'ContextOptions'] | ||
| DeviceResourcesType = Sequence[SMResource | WorkqueueResource] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to generate stubs for private functions?