44
55from __future__ import annotations
66
7+ from cuda.core.experimental._utils.cuda_utils cimport (
8+ _check_driver_error as raise_if_driver_error,
9+ check_or_create_options,
10+ )
11+
712from dataclasses import dataclass
813from typing import TYPE_CHECKING, Optional
914
@@ -13,9 +18,6 @@ from cuda.core.experimental._utils.cuda_utils import (
1318 driver,
1419 handle_return,
1520)
16- from cuda.core.experimental._utils.cuda_utils import (
17- _check_driver_error as raise_if_driver_error,
18- )
1921
2022if TYPE_CHECKING:
2123 import cuda.bindings
@@ -47,26 +49,6 @@ cdef class EventOptions:
4749 support_ipc: Optional[bool ] = False
4850
4951
50- cdef inline EventOptions check_or_create_options(options, str options_description):
51- """
52- Create the specified options dataclass from a dictionary of options or None.
53- """
54- cdef EventOptions opts
55- if options is None :
56- opts = EventOptions()
57- elif isinstance (options, dict ):
58- opts = EventOptions(** options)
59- elif not isinstance (options, EventOptions):
60- raise TypeError (
61- f" The {options_description} must be provided as an object "
62- f" of type {EventOptions.__name__} or as a dict with valid {options_description}. "
63- f" The provided object is '{options}'."
64- )
65-
66- return opts
67-
68-
69-
7052cdef class Event:
7153 """ Represent a record at a specific point of execution within a CUDA stream.
7254
@@ -108,7 +90,7 @@ cdef class Event:
10890 @classmethod
10991 def _init (cls , device_id: int , ctx_handle: Context , opts = None ):
11092 cdef Event self = Event.__new__ (Event)
111- cdef EventOptions options = check_or_create_options(opts, " Event options" )
93+ cdef EventOptions options = check_or_create_options(EventOptions, opts, " Event options" )
11294 flags = 0x0
11395 self ._timing_disabled = False
11496 self ._busy_waited = False
0 commit comments