Skip to content

Commit 0c321a9

Browse files
committed
cuda.core: remove GraphCondition.__int__ (#1945)
Address review feedback on #1986: drop the implicit int() conversion on GraphCondition. Passing a GraphCondition directly to launch() is still supported; the kernel-arg handler now reaches into _c_handle directly instead of going through __int__. Made-with: Cursor
1 parent a95dc9e commit 0c321a9

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

cuda_core/cuda/core/_kernel_arg_handler.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ cdef class ParamHolder:
321321
continue
322322
elif arg_type is GraphCondition:
323323
prepare_arg[cydriver.CUgraphConditionalHandle](
324-
self.data, self.data_addresses, <intptr_t>int(arg), i)
324+
self.data, self.data_addresses,
325+
<intptr_t><unsigned long long>(<GraphCondition>arg)._c_handle, i)
325326
continue
326327
# If no exact types are found, fallback to slower `isinstance` check
327328
elif isinstance(arg, Buffer):
@@ -348,7 +349,8 @@ cdef class ParamHolder:
348349
continue
349350
elif isinstance(arg, GraphCondition):
350351
prepare_arg[cydriver.CUgraphConditionalHandle](
351-
self.data, self.data_addresses, <intptr_t>int(arg), i)
352+
self.data, self.data_addresses,
353+
<intptr_t><unsigned long long>(<GraphCondition>arg)._c_handle, i)
352354
continue
353355
# TODO: support ctypes/numpy struct
354356
raise TypeError("the argument is of unsupported type: " + str(type(arg)))

cuda_core/cuda/core/graph/_graph_definition.pyx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cdef class GraphCondition:
3939
runtime by device code via ``cudaGraphSetConditional``.
4040
4141
A :class:`GraphCondition` may be passed directly as a kernel
42-
argument to ``launch()``; ``__int__`` returns the underlying
42+
argument to ``launch()``: the launcher unwraps it to the underlying
4343
``CUgraphConditionalHandle`` value so device code can update the
4444
condition.
4545
"""
@@ -61,9 +61,6 @@ cdef class GraphCondition:
6161
def __hash__(self) -> int:
6262
return hash(<unsigned long long>self._c_handle)
6363

64-
def __int__(self) -> int:
65-
return <unsigned long long>self._c_handle
66-
6764
@property
6865
def handle(self) -> driver.CUgraphConditionalHandle:
6966
"""The raw CUgraphConditionalHandle as an int."""

0 commit comments

Comments
 (0)