Skip to content

Commit 659858e

Browse files
committed
Simplify length check
1 parent a213c17 commit 659858e

1 file changed

Lines changed: 5 additions & 26 deletions

File tree

cuda_bindings/cuda/bindings/_nvml.pyx

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5511,8 +5511,6 @@ cdef class PlatformInfo_v1:
55115511
@property
55125512
def ib_guid(self):
55135513
"""~_numpy.uint8: (array of length 16).Infiniband GUID reported by platform (for Blackwell, ibGuid is 8 bytes so indices 8-15 are zero)"""
5514-
if 16 == 0:
5515-
return _numpy.array([])
55165514
cdef view.array arr = view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False)
55175515
arr.data = <char *>(&(self._ptr[0].ibGuid))
55185516
return _numpy.asarray(arr)
@@ -5530,8 +5528,6 @@ cdef class PlatformInfo_v1:
55305528
@property
55315529
def rack_guid(self):
55325530
"""~_numpy.uint8: (array of length 16).GUID of the rack containing this GPU (for Blackwell rackGuid is 13 bytes so indices 13-15 are zero)"""
5533-
if 16 == 0:
5534-
return _numpy.array([])
55355531
cdef view.array arr = view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False)
55365532
arr.data = <char *>(&(self._ptr[0].rackGuid))
55375533
return _numpy.asarray(arr)
@@ -5731,8 +5727,6 @@ cdef class PlatformInfo_v2:
57315727
@property
57325728
def ib_guid(self):
57335729
"""~_numpy.uint8: (array of length 16).Infiniband GUID reported by platform (for Blackwell, ibGuid is 8 bytes so indices 8-15 are zero)"""
5734-
if 16 == 0:
5735-
return _numpy.array([])
57365730
cdef view.array arr = view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False)
57375731
arr.data = <char *>(&(self._ptr[0].ibGuid))
57385732
return _numpy.asarray(arr)
@@ -5750,8 +5744,6 @@ cdef class PlatformInfo_v2:
57505744
@property
57515745
def chassis_serial_number(self):
57525746
"""~_numpy.uint8: (array of length 16).Serial number of the chassis containing this GPU (for Blackwell it is 13 bytes so indices 13-15 are zero)"""
5753-
if 16 == 0:
5754-
return _numpy.array([])
57555747
cdef view.array arr = view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False)
57565748
arr.data = <char *>(&(self._ptr[0].chassisSerialNumber))
57575749
return _numpy.asarray(arr)
@@ -7334,8 +7326,6 @@ cdef class VgpuSchedulerCapabilities:
73347326
@property
73357327
def supported_schedulers(self):
73367328
"""~_numpy.uint32: (array of length 3)."""
7337-
if 3 == 0:
7338-
return _numpy.array([])
73397329
cdef view.array arr = view.array(shape=(3,), itemsize=sizeof(unsigned int), format="I", mode="c", allocate_buffer=False)
73407330
arr.data = <char *>(&(self._ptr[0].supportedSchedulers))
73417331
return _numpy.asarray(arr)
@@ -10843,13 +10833,12 @@ cdef class ConfComputeGpuCertificate:
1084310833
def cert_chain(self, val):
1084410834
if self._readonly:
1084510835
raise ValueError("This ConfComputeGpuCertificate instance is read-only")
10836+
self._ptr[0].certChainSize = len(val)
1084610837
if len(val) == 0:
10847-
self._ptr[0].certChainSize = 0
1084810838
return
1084910839
cdef view.array arr = view.array(shape=(4096,), itemsize=sizeof(unsigned char), format="B", mode="c")
1085010840
arr[:] = _numpy.asarray(val, dtype=_numpy.uint8)
1085110841
memcpy(<void *>(&(self._ptr[0].certChain)), <void *>(arr.data), sizeof(unsigned char) * len(val))
10852-
self._ptr[0].certChainSize = len(val)
1085310842

1085410843
@property
1085510844
def attestation_cert_chain(self):
@@ -10864,13 +10853,12 @@ cdef class ConfComputeGpuCertificate:
1086410853
def attestation_cert_chain(self, val):
1086510854
if self._readonly:
1086610855
raise ValueError("This ConfComputeGpuCertificate instance is read-only")
10856+
self._ptr[0].attestationCertChainSize = len(val)
1086710857
if len(val) == 0:
10868-
self._ptr[0].attestationCertChainSize = 0
1086910858
return
1087010859
cdef view.array arr = view.array(shape=(5120,), itemsize=sizeof(unsigned char), format="B", mode="c")
1087110860
arr[:] = _numpy.asarray(val, dtype=_numpy.uint8)
1087210861
memcpy(<void *>(&(self._ptr[0].attestationCertChain)), <void *>(arr.data), sizeof(unsigned char) * len(val))
10873-
self._ptr[0].attestationCertChainSize = len(val)
1087410862

1087510863
@staticmethod
1087610864
def from_data(data):
@@ -11000,8 +10988,6 @@ cdef class ConfComputeGpuAttestationReport:
1100010988
@property
1100110989
def nonce(self):
1100210990
"""~_numpy.uint8: (array of length 32)."""
11003-
if 32 == 0:
11004-
return _numpy.array([])
1100510991
cdef view.array arr = view.array(shape=(32,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False)
1100610992
arr.data = <char *>(&(self._ptr[0].nonce))
1100710993
return _numpy.asarray(arr)
@@ -11029,13 +11015,12 @@ cdef class ConfComputeGpuAttestationReport:
1102911015
def attestation_report(self, val):
1103011016
if self._readonly:
1103111017
raise ValueError("This ConfComputeGpuAttestationReport instance is read-only")
11018+
self._ptr[0].attestationReportSize = len(val)
1103211019
if len(val) == 0:
11033-
self._ptr[0].attestationReportSize = 0
1103411020
return
1103511021
cdef view.array arr = view.array(shape=(8192,), itemsize=sizeof(unsigned char), format="B", mode="c")
1103611022
arr[:] = _numpy.asarray(val, dtype=_numpy.uint8)
1103711023
memcpy(<void *>(&(self._ptr[0].attestationReport)), <void *>(arr.data), sizeof(unsigned char) * len(val))
11038-
self._ptr[0].attestationReportSize = len(val)
1103911024

1104011025
@property
1104111026
def cec_attestation_report(self):
@@ -11050,13 +11035,12 @@ cdef class ConfComputeGpuAttestationReport:
1105011035
def cec_attestation_report(self, val):
1105111036
if self._readonly:
1105211037
raise ValueError("This ConfComputeGpuAttestationReport instance is read-only")
11038+
self._ptr[0].cecAttestationReportSize = len(val)
1105311039
if len(val) == 0:
11054-
self._ptr[0].cecAttestationReportSize = 0
1105511040
return
1105611041
cdef view.array arr = view.array(shape=(4096,), itemsize=sizeof(unsigned char), format="B", mode="c")
1105711042
arr[:] = _numpy.asarray(val, dtype=_numpy.uint8)
1105811043
memcpy(<void *>(&(self._ptr[0].cecAttestationReport)), <void *>(arr.data), sizeof(unsigned char) * len(val))
11059-
self._ptr[0].cecAttestationReportSize = len(val)
1106011044

1106111045
@staticmethod
1106211046
def from_data(data):
@@ -11186,8 +11170,6 @@ cdef class GpuFabricInfo_v2:
1118611170
@property
1118711171
def cluster_uuid(self):
1118811172
"""~_numpy.uint8: (array of length 16).Uuid of the cluster to which this GPU belongs."""
11189-
if 16 == 0:
11190-
return _numpy.array([])
1119111173
cdef view.array arr = view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False)
1119211174
arr.data = <char *>(&(self._ptr[0].clusterUuid))
1119311175
return _numpy.asarray(arr)
@@ -11381,13 +11363,12 @@ cdef class NvlinkSupportedBwModes_v1:
1138111363
def bw_modes(self, val):
1138211364
if self._readonly:
1138311365
raise ValueError("This NvlinkSupportedBwModes_v1 instance is read-only")
11366+
self._ptr[0].totalBwModes = len(val)
1138411367
if len(val) == 0:
11385-
self._ptr[0].totalBwModes = 0
1138611368
return
1138711369
cdef view.array arr = view.array(shape=(23,), itemsize=sizeof(unsigned char), format="B", mode="c")
1138811370
arr[:] = _numpy.asarray(val, dtype=_numpy.uint8)
1138911371
memcpy(<void *>(&(self._ptr[0].bwModes)), <void *>(arr.data), sizeof(unsigned char) * len(val))
11390-
self._ptr[0].totalBwModes = len(val)
1139111372

1139211373
@staticmethod
1139311374
def from_data(data):
@@ -13985,8 +13966,6 @@ cdef class GpuFabricInfo_v3:
1398513966
@property
1398613967
def cluster_uuid(self):
1398713968
"""~_numpy.uint8: (array of length 16).Uuid of the cluster to which this GPU belongs."""
13988-
if 16 == 0:
13989-
return _numpy.array([])
1399013969
cdef view.array arr = view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False)
1399113970
arr.data = <char *>(&(self._ptr[0].clusterUuid))
1399213971
return _numpy.asarray(arr)

0 commit comments

Comments
 (0)