1+ # This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_context.pyx
2+
3+ from __future__ import annotations
4+
5+ from collections .abc import Sequence
6+ from dataclasses import dataclass
7+
8+ from cuda .core ._device_resources import (DeviceResources , SMResource ,
9+ WorkqueueResource )
10+ from cuda .core ._stream import StreamOptions
11+
12+
13+ class Context :
14+ """CUDA context wrapper.
15+
16+ Context objects represent CUDA contexts and cannot be instantiated directly.
17+ Use Device or Stream APIs to obtain context objects.
18+ """
19+
20+ def close (self ):
21+ """Release this context wrapper's underlying CUDA handles."""
22+
23+ def __init__ (self , * args , ** kwargs ):
24+ ...
25+
26+ @property
27+ def handle (self ):
28+ """Return the underlying CUcontext handle."""
29+
30+ @property
31+ def _handle (self ):
32+ ...
33+
34+ @property
35+ def is_green (self ) -> bool :
36+ """True if this context was created from device resources."""
37+
38+ @property
39+ def resources (self ) -> DeviceResources :
40+ """Query the hardware resources provisioned for this context.
41+
42+ For green contexts, returns the resources this context was created
43+ with (SM partition, workqueue config). For primary contexts, returns
44+ the full device resources.
45+
46+ Raises :class:`RuntimeError` if the context has been closed.
47+ """
48+
49+ def create_stream (self , options : StreamOptions | None = None ):
50+ """Create a new stream bound to this green context.
51+
52+ This method is only available on green contexts. For primary
53+ contexts, use :meth:`Device.create_stream` instead.
54+
55+ Parameters
56+ ----------
57+ options : :obj:`~_stream.StreamOptions`, optional
58+ Customizable dataclass for stream creation options.
59+
60+ Returns
61+ -------
62+ :obj:`~_stream.Stream`
63+ Newly created stream object.
64+ """
65+
66+ def __eq__ (self , other ):
67+ ...
68+
69+ def __hash__ (self ) -> int :
70+ ...
71+
72+ def __repr__ (self ) -> str :
73+ ...
74+
75+ @dataclass
76+ class ContextOptions :
77+ """Options for context creation.
78+
79+ Attributes
80+ ----------
81+ resources : :obj:`~cuda.core.typing.DeviceResourcesType`
82+ Device resources used to create a green context.
83+ """
84+ resources : DeviceResourcesType
85+ __all__ = ['Context' , 'ContextOptions' ]
86+ DeviceResourcesType = Sequence [SMResource | WorkqueueResource ]
0 commit comments