habana-pyhlml 1.21.4.3__py3-none-any.whl → 1.22.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of habana-pyhlml might be problematic. Click here for more details.

pyhlml/main.py CHANGED
@@ -11,29 +11,18 @@ from pyhlml.hlml_error import HLMLError, ErrorsAsClass
11
11
  _hlmlOBJ = None
12
12
 
13
13
  def _wrapperInit():
14
- """ init module level object and error classes
15
- Parameters: None
16
- Returns: None
17
- """
14
+ """Initialize module-level HLML object and error classes."""
18
15
  ErrorsAsClass()
19
16
  setattr(modules[__name__], "_hlmlOBJ", LibHLML())
20
17
 
21
18
  def check_return(ret):
22
- """ Checks ret for any error.
23
- Parameters:
24
- ret - Symbol for checking if return was valid.
25
- Returns:
26
- ret - Symbol for current error status.
27
- """
19
+ """Raise HLMLError if ret is not HLML_SUCCESS, otherwise return ret."""
28
20
  if (ret != hlml_t.HLML_RETURN.HLML_SUCCESS ):
29
21
  raise HLMLError(ret)
30
22
  return ret
31
23
 
32
24
  def hlmlInit() -> None:
33
- """ Must be called before any other api can be used
34
- Parameters: None
35
- Returns: None
36
- """
25
+ """Initialize HLML. Must be called before any other API can be used."""
37
26
  _wrapperInit()
38
27
  global _hlmlOBJ
39
28
 
@@ -45,10 +34,9 @@ def hlmlInit() -> None:
45
34
  return None
46
35
 
47
36
  def hlmlInitWithFlags(flags=0) -> None:
48
- """ Allows the user to call the init function with a flag.
49
- Parameters:
50
- flags (int) [ default=0 ] - only the default is supported
51
- Returns: None
37
+ """Initialize HLML with flags. Only the default flag (0) is supported.
38
+ Args:
39
+ flags (int): Initialization flags (default 0).
52
40
  """
53
41
  _wrapperInit()
54
42
  global _hlmlOBJ
@@ -61,10 +49,7 @@ def hlmlInitWithFlags(flags=0) -> None:
61
49
  return None
62
50
 
63
51
  def hlmlShutdown() -> None:
64
- """ Shutdown should be called last.
65
- Parameters: None
66
- Returns: None
67
- """
52
+ """Shutdown HLML and release resources. Should be called last."""
68
53
  global _hlmlOBJ
69
54
 
70
55
  fn = _hlmlOBJ.get_func_ptr("hlml_shutdown")
@@ -76,11 +61,9 @@ def hlmlShutdown() -> None:
76
61
  return None
77
62
 
78
63
  def hlmlDeviceGetCount() -> int:
79
- """ Returns the number of Habana devices in the system.
80
- Parameters: None
81
- Returns:
82
- count (int) - Number of habana devices.
83
- Ex. An HLS1-H would return 4
64
+ """Get the number of Habana devices in the system.
65
+ Returns:
66
+ int: Number of Habana devices.
84
67
  """
85
68
  global _hlmlOBJ
86
69
  count = ctypes.c_uint()
@@ -92,11 +75,13 @@ def hlmlDeviceGetCount() -> int:
92
75
  return count.value
93
76
 
94
77
  def hlmlDeviceGetHandleByPCIBusID(pci_addr: str) -> hlml_t.HLML_DEVICE.TYPE:
95
- """ Acquire the handle for a device, based on PCI Address
96
- Parameters:
97
- pci_addr (str) - The PCI Address of a habana device.
98
- Returns:
99
- device (HLML_DEVICE.TYPE) - The handle for the habana device.
78
+ """Get device handle by PCI address.
79
+ If there is a single domain, the 'domain' part of the PCI address
80
+ is not required.
81
+ Args:
82
+ pci_addr (str): PCI address of the device.
83
+ Returns:
84
+ HLML_DEVICE.TYPE: Device handle.
100
85
  """
101
86
  global _hlmlOBJ
102
87
 
@@ -108,11 +93,11 @@ def hlmlDeviceGetHandleByPCIBusID(pci_addr: str) -> hlml_t.HLML_DEVICE.TYPE:
108
93
  return device
109
94
 
110
95
  def hlmlDeviceGetHandleByIndex(index: int) -> hlml_t.HLML_DEVICE.TYPE:
111
- """ Acquire device handle by index
112
- Parameters:
113
- index (int) - The index of a habana device.
114
- Returns:
115
- device (HLML_DEVICE.TYPE) - The handle for the habana device.
96
+ """Get device handle by index.
97
+ Args:
98
+ index (int): Device index.
99
+ Returns:
100
+ HLML_DEVICE.TYPE: Device handle.
116
101
  """
117
102
  global _hlmlOBJ
118
103
  device = hlml_t.HLML_DEVICE.TYPE()
@@ -124,11 +109,11 @@ def hlmlDeviceGetHandleByIndex(index: int) -> hlml_t.HLML_DEVICE.TYPE:
124
109
  return device
125
110
 
126
111
  def hlmlDeviceGetHandleByUUID(uuid: str) -> hlml_t.HLML_DEVICE.TYPE:
127
- """ Acquire device handle by UUID
128
- Parameters:
129
- uuid (str) - A Universal Unique ID for a habana device to access.
130
- Returns:
131
- device (HLML_DEVICE.TYPE) - The handle for the habana device.
112
+ """Get device handle by UUID (Universal Unique ID).
113
+ Args:
114
+ uuid (str): Device UUID.
115
+ Returns:
116
+ HLML_DEVICE.TYPE: Device handle.
132
117
  """
133
118
  global _hlmlOBJ
134
119
  device = hlml_t.HLML_DEVICE.TYPE()
@@ -139,12 +124,12 @@ def hlmlDeviceGetHandleByUUID(uuid: str) -> hlml_t.HLML_DEVICE.TYPE:
139
124
  check_return(ret)
140
125
  return device
141
126
 
142
- def hlmlDeviceGetName(device: hlml_t.HLML_DEVICE.TYPE) -> str:
143
- """ Acquire name of device from handle
144
- Parameters:
145
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
146
- Returns:
147
- name (str) - The name of the habana device.
127
+ def hlmlDeviceGetName(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
128
+ """Get device name from handle.
129
+ Args:
130
+ device (HLML_DEVICE.TYPE): Device handle.
131
+ Returns:
132
+ bytes: Device name.
148
133
  """
149
134
  global _hlmlOBJ
150
135
  name = ctypes.create_string_buffer(hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE)
@@ -159,11 +144,11 @@ def hlmlDeviceGetName(device: hlml_t.HLML_DEVICE.TYPE) -> str:
159
144
  return name.value
160
145
 
161
146
  def hlmlDeviceGetPCIInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_pci_info:
162
- """ Get the PCI attributes of input device
163
- Parameters:
164
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
165
- Returns:
166
- pci_info (c_hlml_pci_info) - The PCI attributes of the given device.
147
+ """Get PCI attributes of the device.
148
+ Args:
149
+ device (HLML_DEVICE.TYPE): Device handle.
150
+ Returns:
151
+ c_hlml_pci_info: PCI attributes.
167
152
  """
168
153
  global _hlmlOBJ
169
154
  pci_info = hlml_t.c_hlml_pci_info()
@@ -178,12 +163,12 @@ def hlmlDeviceGetPCIInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_pci_i
178
163
  return pci_info
179
164
 
180
165
  def hlmlDeviceGetClockInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) -> int:
181
- """ Retrives the current speed of the selected clock (MHz)
182
- Parameters:
183
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
184
- clock_type ( 0-SOC ( GAUDI ) / 1-IC ( GOYA ) / 2-MME ( GOYA ) / 3-TPC ( GOYA ) )
185
- Returns:
186
- speed (int) - The clock speed of the selected clock in MHz.
166
+ """Get current speed of the selected clock (MHz).
167
+ Args:
168
+ device (HLML_DEVICE.TYPE): Device handle.
169
+ clock_type (int): Clock type.
170
+ Returns:
171
+ int: Clock speed in MHz.
187
172
  """
188
173
  global _hlmlOBJ
189
174
  speed = ctypes.c_uint()
@@ -195,12 +180,12 @@ def hlmlDeviceGetClockInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) -> in
195
180
  return speed.value
196
181
 
197
182
  def hlmlDeviceGetMaxClockInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) -> int:
198
- """ Retrives the maximum speed of the selected clock (MHz)
199
- Parameters:
200
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
201
- clock_type ( 0-SOC ( GAUDI ) / 1-IC ( GOYA ) / 2-MME ( GOYA ) / 3-TPC ( GOYA ) )
202
- Returns:
203
- speed (int) - The MAXIMUM clock speed of the selected clock in MHz.
183
+ """Get maximum speed of the selected clock (MHz).
184
+ Args:
185
+ device (HLML_DEVICE.TYPE): Device handle.
186
+ clock_type (int): Clock type.
187
+ Returns:
188
+ int: Maximum clock speed in MHz.
204
189
  """
205
190
  global _hlmlOBJ
206
191
  speed = ctypes.c_uint()
@@ -212,12 +197,12 @@ def hlmlDeviceGetMaxClockInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) ->
212
197
  return speed.value
213
198
 
214
199
  def hlmlDeviceGetClockLimitInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) -> int:
215
- """ Retrives the frequency limit of the selected clock (MHz)
216
- Parameters:
217
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
218
- clock_type ( 0-SOC ( GAUDI ) / 1-IC ( GOYA ) / 2-MME ( GOYA ) / 3-TPC ( GOYA ) )
219
- Returns:
220
- speed (int) - The frequency LIMIT of the selected clock in MHz.
200
+ """Get frequency limit of the selected clock (MHz).
201
+ Args:
202
+ device (HLML_DEVICE.TYPE): Device handle.
203
+ clock_type (int): Clock type.
204
+ Returns:
205
+ int: Frequency limit in MHz.
221
206
  """
222
207
  global _hlmlOBJ
223
208
  speed = ctypes.c_uint()
@@ -229,11 +214,11 @@ def hlmlDeviceGetClockLimitInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 )
229
214
  return speed.value
230
215
 
231
216
  def hlmlDeviceGetUtilizationRates(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_utilization:
232
- """ Returns utilization over the past second as a percentage
233
- Parameters:
234
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
235
- Returns:
236
- hlml_util (int) - The utilization rate over the last second as a percentage.
217
+ """Get device utilization rates over the past second.
218
+ Args:
219
+ device (HLML_DEVICE.TYPE): Device handle.
220
+ Returns:
221
+ c_hlml_utilization: Utilization rates.
237
222
  """
238
223
  global _hlmlOBJ
239
224
  hlml_util = hlml_t.c_hlml_utilization()
@@ -245,11 +230,11 @@ def hlmlDeviceGetUtilizationRates(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_h
245
230
  return hlml_util
246
231
 
247
232
  def hlmlDeviceGetProcessUtilization(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_process_utilization:
248
- """ Returns process utilization over the past second as a percentage
249
- Parameters:
250
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
251
- Returns:
252
- hlml_util (int) - The utilization rate over the last second as a percentage.
233
+ """Get process utilization rates (as a percentage) over the past second.
234
+ Args:
235
+ device (HLML_DEVICE.TYPE): Device handle.
236
+ Returns:
237
+ c_hlml_process_utilization: Process utilization rates.
253
238
  """
254
239
  global _hlmlOBJ
255
240
  hlml_util = hlml_t.c_hlml_process_utilization()
@@ -261,11 +246,11 @@ def hlmlDeviceGetProcessUtilization(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c
261
246
  return hlml_util
262
247
 
263
248
  def hlmlDeviceGetMemoryInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_memory:
264
- """ Returns the total, used, and free memory in bytes
265
- Parameters:
266
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
267
- Returns:
268
- hlml_mem (c_hlml_memory) - The total memory and how much is used/free in bytes.
249
+ """Get total, used, and free memory in bytes.
250
+ Args:
251
+ device (HLML_DEVICE.TYPE): Device handle.
252
+ Returns:
253
+ c_hlml_memory: Memory info.
269
254
  """
270
255
  global _hlmlOBJ
271
256
  hlml_mem = hlml_t.c_hlml_memory()
@@ -278,12 +263,12 @@ def hlmlDeviceGetMemoryInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_me
278
263
 
279
264
  def hlmlDeviceGetTemperature(
280
265
  device: hlml_t.HLML_DEVICE.TYPE, sensor_type: hlml_t.HLML_TEMP_SENS.TYPE) -> int:
281
- """ Retrives the current temperature (celsius) of the selected sensor_type
282
- Parameters:
283
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
284
- sensor_types ( 0-AIP / 1-BOARD )
285
- Returns:
286
- temp (int) - The temperature recorded at the given sensor in celsius.
266
+ """Get current temperature (Celsius) of the selected sensor.
267
+ Args:
268
+ device (HLML_DEVICE.TYPE): Device handle.
269
+ sensor_type (HLML_TEMP_SENS.TYPE): Sensor type.
270
+ Returns:
271
+ int: Temperature in Celsius.
287
272
  """
288
273
  global _hlmlOBJ
289
274
  temp = ctypes.c_uint()
@@ -295,12 +280,12 @@ def hlmlDeviceGetTemperature(
295
280
  return temp.value
296
281
 
297
282
  def hlmlDeviceGetTemperatureThreshold(device: hlml_t.HLML_DEVICE.TYPE, threshold_type: int) -> int:
298
- """ Retrieves the known temperature (celsius) threshold of the requested type
299
- Parameters:
300
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
301
- threshold_type (0-shutdown / 1-slowdown / 2-memory / 3-gpu ) - Which threshold temp to check.
302
- Returns:
303
- temp (int) - The temperature the given threshold is set at in celsius.
283
+ """Get temperature threshold (Celsius) of the requested type.
284
+ Args:
285
+ device (HLML_DEVICE.TYPE): Device handle.
286
+ threshold_type (int): Threshold type.
287
+ Returns:
288
+ int: Threshold temperature in Celsius.
304
289
  """
305
290
  global _hlmlOBJ
306
291
  temp = ctypes.c_uint()
@@ -311,12 +296,12 @@ def hlmlDeviceGetTemperatureThreshold(device: hlml_t.HLML_DEVICE.TYPE, threshold
311
296
  check_return(ret)
312
297
  return temp.value
313
298
 
314
- def hlmlDeviceGetPersistenceMode(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.HLML_ENABLE_STATE:
315
- """ Retrieves the persistence mode of the device
316
- Parameters:
317
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
318
- Returns:
319
- mode (int) - The persistence mode of the device.
299
+ def hlmlDeviceGetPersistenceMode(device: hlml_t.HLML_DEVICE.TYPE) -> int:
300
+ """Get persistence mode of the device.
301
+ Args:
302
+ device (HLML_DEVICE.TYPE): Device handle.
303
+ Returns:
304
+ int: Persistence mode.
320
305
  """
321
306
  global _hlmlOBJ
322
307
  mode = ctypes.c_uint()
@@ -327,12 +312,12 @@ def hlmlDeviceGetPersistenceMode(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.HLML
327
312
  check_return(ret)
328
313
  return mode.value
329
314
 
330
- def hlmlDeviceGetPerformanceState(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.HLML_P_STATES:
331
- """ Retrieves the performance state of the device
332
- Parameters:
333
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
334
- Returns:
335
- p_state (int) - The performance state of the device.
315
+ def hlmlDeviceGetPerformanceState(device: hlml_t.HLML_DEVICE.TYPE) -> int:
316
+ """Get performance state of the device.
317
+ Args:
318
+ device (HLML_DEVICE.TYPE): Device handle.
319
+ Returns:
320
+ int: Performance state.
336
321
  """
337
322
  global _hlmlOBJ
338
323
  p_state = ctypes.c_uint()
@@ -343,19 +328,16 @@ def hlmlDeviceGetPerformanceState(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.HLM
343
328
  check_return(ret)
344
329
  return p_state.value
345
330
 
346
- def hlmlDeviceGetSupportedPerformanceStates( device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.HLML_P_STATES:
347
- """ Get all supported Performance States (HLML_P_STATES) for the device.
348
- The returned array will be in size HLML_PSTATE_NUM_SUPPORTED and will contain a contiguous list
349
- of valid P-States supported by the device.
350
- If the number of supported P-States is fewer than the size of the array
351
- missing elements would contain HLML_PSTATE_UNKNOWN.
352
- Parameters:
353
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
354
- Returns:
355
- p_states (hlml_t.HLML_P_STATES array in size HLML_PSTATE_NUM_SUPPORTED) - that contains
356
- all the supported performance state of the device.
357
- If the number of supported P-States is fewer than the size of the array
358
- missing elements would contain HLML_PSTATE_UNKNOWN.
331
+ def hlmlDeviceGetSupportedPerformanceStates(device: hlml_t.HLML_DEVICE.TYPE) -> tuple:
332
+ """Get all supported performance states for the device.
333
+ The returned array is of size HLML_PSTATE_NUM_SUPPORTED and contains a contiguous
334
+ list of performance states that the device supports.
335
+ If the number of supported performance states is less than HLML_PSTATE_NUM_SUPPORTED,
336
+ the remaining entries in the array will be set to HLML_PSTATE_UNKNOWN.
337
+ Args:
338
+ device (HLML_DEVICE.TYPE): Device handle.
339
+ Returns:
340
+ HLML_P_STATES array: Supported performance states.
359
341
  """
360
342
  global _hlmlOBJ
361
343
  p_states = (hlml_t.HLML_P_STATES.TYPE * hlml_t.HLML_PSTATE_NUM_SUPPORTED)()
@@ -367,11 +349,11 @@ def hlmlDeviceGetSupportedPerformanceStates( device: hlml_t.HLML_DEVICE.TYPE) ->
367
349
  return p_states
368
350
 
369
351
  def hlmlDeviceGetPowerUsage(device: hlml_t.HLML_DEVICE.TYPE) -> int:
370
- """ Retrieves power usage for the device in mW
371
- Parameters:
372
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
373
- Returns:
374
- power (int) - The given device's power usage in mW.
352
+ """Get power usage for the device in mW.
353
+ Args:
354
+ device (HLML_DEVICE.TYPE): Device handle.
355
+ Returns:
356
+ int: Power usage in mW.
375
357
  """
376
358
  global _hlmlOBJ
377
359
  power = ctypes.c_uint()
@@ -383,12 +365,10 @@ def hlmlDeviceGetPowerUsage(device: hlml_t.HLML_DEVICE.TYPE) -> int:
383
365
  return power.value
384
366
 
385
367
  def hlmlDeviceSetPowerManagementLimit(device: hlml_t.HLML_DEVICE.TYPE, limit : ctypes.c_uint) -> None:
386
- """ Sets power management limit on this device in mW
387
- Parameters:
388
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
389
- limit (ctypes.c_uint) - The power limit on the device in mW.
390
- Returns:
391
- ret (HLML_RETURN) - The status of the operation.
368
+ """Set power management limit on this device in mW.
369
+ Args:
370
+ device (HLML_DEVICE.TYPE): Device handle.
371
+ limit (ctypes.c_uint): Power limit in mW.
392
372
  """
393
373
  global _hlmlOBJ
394
374
 
@@ -399,11 +379,11 @@ def hlmlDeviceSetPowerManagementLimit(device: hlml_t.HLML_DEVICE.TYPE, limit : c
399
379
  return None
400
380
 
401
381
  def hlmlDeviceGetPowerManagementDefaultLimit(device: hlml_t.HLML_DEVICE.TYPE) -> int:
402
- """ Retrieves default power management limit on this device in mW
403
- Parameters:
404
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
405
- Returns:
406
- power (int) - The power limit on the device in mW.
382
+ """Get default power management limit on this device in mW.
383
+ Args:
384
+ device (HLML_DEVICE.TYPE): Device handle.
385
+ Returns:
386
+ int: Default power limit in mW.
407
387
  """
408
388
  global _hlmlOBJ
409
389
  power = ctypes.c_uint()
@@ -414,12 +394,12 @@ def hlmlDeviceGetPowerManagementDefaultLimit(device: hlml_t.HLML_DEVICE.TYPE) ->
414
394
  check_return(ret)
415
395
  return power.value
416
396
 
417
- def hlmlDeviceGetECCMode(device: hlml_t.HLML_DEVICE.TYPE) -> dict:
418
- """ Retrieves the current and pending ECC modes of the device
419
- Parameters:
420
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
421
- Returns:
422
- out (dict) - The current and pending ECC modes for the device.
397
+ def hlmlDeviceGetECCMode(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.hlml_ecc_mode:
398
+ """Get current and pending ECC modes of the device.
399
+ Args:
400
+ device (HLML_DEVICE.TYPE): Device handle.
401
+ Returns:
402
+ hlml_ecc_mode: ECC mode info with 'current' and 'pending' attributes.
423
403
  """
424
404
  global _hlmlOBJ
425
405
  out = hlml_t.hlml_ecc_mode()
@@ -436,14 +416,13 @@ def hlmlDeviceGetECCMode(device: hlml_t.HLML_DEVICE.TYPE) -> dict:
436
416
  return out
437
417
 
438
418
  def hlmlDeviceGetTotalECCErrors(device: hlml_t.HLML_DEVICE.TYPE, error_type: hlml_t.HLML_MEMORY_ERROR.TYPE, counter_type: hlml_t.HLML_ECC_COUNTER) -> int:
439
- """ Returns the number of ECC errors for a device. Number is from the last reset, or driver
440
- reinstall. Currently only the number of corrected errors is supported.
441
- Parameters:
442
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
443
- error_type ( 0-CORRECTED / 1-UNCORRECTED ) - The type of errors to count.
444
- counter_type ( 0-VOLATILE / 1-AGGREGATE ) - The type of counter to use.
445
- Returns:
446
- count (int) - The number of ECC errors for the device, specified by parameters.
419
+ """Get number of ECC errors for a device since last reset or driver reinstall.
420
+ Args:
421
+ device (HLML_DEVICE.TYPE): Device handle.
422
+ error_type (HLML_MEMORY_ERROR.TYPE): Error type to count.
423
+ counter_type (HLML_ECC_COUNTER): Counter type to use.
424
+ Returns:
425
+ int: Number of ECC errors.
447
426
  """
448
427
  global _hlmlOBJ
449
428
  count = ctypes.c_longlong()
@@ -455,16 +434,16 @@ def hlmlDeviceGetTotalECCErrors(device: hlml_t.HLML_DEVICE.TYPE, error_type: hlm
455
434
  return count.value
456
435
 
457
436
  def hlmlDeviceGetMemoryErrorCounter(device: hlml_t.HLML_DEVICE.TYPE, error_type: hlml_t.HLML_MEMORY_ERROR.TYPE, counter_type: hlml_t.HLML_ECC_COUNTER.TYPE, location: hlml_t.HLML_MEMORY_LOCATION.TYPE) -> int:
458
- """ Returns the number of ECC errors for a device at a specified memory location.
459
- Number is from the last reset, or driver reinstall. Currently only the number
460
- of corrected errors is supported.
461
- Parameters:
462
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
463
- error_type ( 0-CORRECTED / 1-UNCORRECTED ) - The type of errors to count.
464
- counter_type ( 0-VOLATILE / 1-AGGREGATE ) - The type of counter to use.
465
- location ( 0-SRAM / 1-DRAM ) - The type of memory.
466
- Returns:
467
- count (int) - The number of ECC errors for the device, specified by parameters.
437
+ """Get number of ECC errors for a device at a specified memory location.
438
+ The number is from the last reset or driver reinstall. Currently, only the
439
+ number of corrected errors is supported.
440
+ Args:
441
+ device (HLML_DEVICE.TYPE): Device handle.
442
+ error_type (HLML_MEMORY_ERROR.TYPE): Error type to count.
443
+ counter_type (HLML_ECC_COUNTER.TYPE): Counter type to use.
444
+ location (HLML_MEMORY_LOCATION.TYPE): Memory location.
445
+ Returns:
446
+ int: Number of ECC errors.
468
447
  """
469
448
  global _hlmlOBJ
470
449
  ecc_count = ctypes.c_longlong()
@@ -475,12 +454,12 @@ def hlmlDeviceGetMemoryErrorCounter(device: hlml_t.HLML_DEVICE.TYPE, error_type:
475
454
  check_return(ret)
476
455
  return ecc_count.value
477
456
 
478
- def hlmlDeviceGetUUID(device: hlml_t.HLML_DEVICE.TYPE) -> str:
479
- """ Returns the UUID of the device
480
- Parameters:
481
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
482
- Returns:
483
- name (str) - The UUID for the given device.
457
+ def hlmlDeviceGetUUID(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
458
+ """Get UUID (Universal Unique ID) of the device.
459
+ Args:
460
+ device (HLML_DEVICE.TYPE): Device handle.
461
+ Returns:
462
+ bytes: Device UUID.
484
463
  """
485
464
  global _hlmlOBJ
486
465
  name_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -493,12 +472,12 @@ def hlmlDeviceGetUUID(device: hlml_t.HLML_DEVICE.TYPE) -> str:
493
472
  return name.value
494
473
 
495
474
  def hlmlDeviceGetMinorNumber(device: hlml_t.HLML_DEVICE.TYPE) -> int:
496
- """ Retrieves the minor number of the device ( maps to the device node file )
497
- at /sys/class/accel/accel[minor]
498
- Parameters:
499
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
500
- Returns:
501
- number (int) - The minor number for the device.
475
+ """Get minor number of the device (maps to device node file
476
+ at /sys/class/accel/accel[minor]).
477
+ Args:
478
+ device (HLML_DEVICE.TYPE): Device handle.
479
+ Returns:
480
+ int: Minor number.
502
481
  """
503
482
  global _hlmlOBJ
504
483
  number = ctypes.c_uint()
@@ -510,10 +489,9 @@ def hlmlDeviceGetMinorNumber(device: hlml_t.HLML_DEVICE.TYPE) -> int:
510
489
  return number.value
511
490
 
512
491
  def hlmlEventSetCreate() -> hlml_t.HLML_EVENT_SET.TYPE:
513
- """ Create an empty set of events
514
- Parameters: None.
515
- Returns:
516
- st (HLML_EVENT_SET) - An empty set of events.
492
+ """Create an empty set of events.
493
+ Returns:
494
+ HLML_EVENT_SET.TYPE: Empty event set.
517
495
  """
518
496
  global _hlmlOBJ
519
497
  st = hlml_t.HLML_EVENT_SET.TYPE()
@@ -525,10 +503,9 @@ def hlmlEventSetCreate() -> hlml_t.HLML_EVENT_SET.TYPE:
525
503
  return st
526
504
 
527
505
  def hlmlEventSetFree(st: hlml_t.HLML_EVENT_SET.TYPE) -> None:
528
- """ Release a set of events
529
- Parameters:
530
- st (HLML_EVENT_SET) - The set of events to be released.
531
- Returns: None.
506
+ """Release a set of events.
507
+ Args:
508
+ st (HLML_EVENT_SET.TYPE): Event set to release.
532
509
  """
533
510
  global _hlmlOBJ
534
511
 
@@ -542,12 +519,11 @@ def hlmlDeviceRegisterEvents(
542
519
  device: hlml_t.HLML_DEVICE.TYPE, event_types: int,
543
520
  st: hlml_t.HLML_EVENT_SET.TYPE
544
521
  ) -> None:
545
- """ Start recording events on input device add events to input set
546
- Parameters:
547
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
548
- event_types ( 0-ECC_err / 1-Crit_err / 2-Clock_change ) - The type of events to start recording.
549
- st (HLML_EVENT_SET) - The set of events to be released.
550
- Returns: None.
522
+ """Start recording events on device and add events to set.
523
+ Args:
524
+ device (HLML_DEVICE.TYPE): Device handle.
525
+ event_types (int): Event types to record.
526
+ st (HLML_EVENT_SET.TYPE): Event set (buffer) to be written to.
551
527
  """
552
528
  global _hlmlOBJ
553
529
 
@@ -558,14 +534,15 @@ def hlmlDeviceRegisterEvents(
558
534
  return None
559
535
 
560
536
  def hlmlEventSetWait(st: hlml_t.HLML_EVENT_SET.TYPE, timeout: int) -> hlml_t.c_hlml_event_data:
561
- """ Waits on events and delivers events.
562
- If some events are ready to be delivered at the time of the call, function returns immediately.
563
- If there are no events ready to be delivered, function sleeps until the event arrives but not longer than the specified timeout.
564
- Parameters:
565
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
566
- timeout (int) - The maximum time to wait for a new event.
567
- Returns:
568
- data (c_hlml_event_data) - The data from events ready to be delivered.
537
+ """Wait for events and deliver event data.
538
+ If any events are available at the time of the call, function returns immediately.
539
+ If there are no events available, it waits until an event arrives or the specified
540
+ timeout is reached.
541
+ Args:
542
+ st (HLML_EVENT_SET.TYPE): Event set (buffer) to be written to.
543
+ timeout (int): Maximum time to wait for an event.
544
+ Returns:
545
+ c_hlml_event_data: Event data.
569
546
  """
570
547
  global _hlmlOBJ
571
548
  data = hlml_t.c_hlml_event_data()
@@ -577,14 +554,14 @@ def hlmlEventSetWait(st: hlml_t.HLML_EVENT_SET.TYPE, timeout: int) -> hlml_t.c_h
577
554
  return data
578
555
 
579
556
  def hlmlDeviceGetMACInfo(
580
- device: hlml_t.HLML_DEVICE.TYPE, count=20, start=1) -> hlml_t.c_hlml_mac_info:
581
- """ Get MAC addresses of device.
582
- Parameters:
583
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
584
- Count (int) - How many addresses to return.
585
- Start (int) - The index to start at.
586
- Returns:
587
- mac (c_hlml_mac_info array of size count) - The MAC addresses of the device.
557
+ device: hlml_t.HLML_DEVICE.TYPE, count=20, start=1) -> tuple:
558
+ """Get MAC addresses of device.
559
+ Args:
560
+ device (HLML_DEVICE.TYPE): Device handle.
561
+ count (int): Number of addresses to return.
562
+ start (int): Index to start at.
563
+ Returns:
564
+ c_hlml_mac_info array: MAC addresses.
588
565
  """
589
566
  global _hlmlOBJ
590
567
  mac = (hlml_t.c_hlml_mac_info * count)()
@@ -597,11 +574,11 @@ def hlmlDeviceGetMACInfo(
597
574
  return mac
598
575
 
599
576
  def hlmlDeviceGetHLRevision(device: hlml_t.HLML_DEVICE.TYPE) -> int:
600
- """ Returns HL revision
601
- Parameters:
602
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
603
- Returns:
604
- rev (int) - The HL revision
577
+ """Get HL revision of the device.
578
+ Args:
579
+ device (HLML_DEVICE.TYPE): Device handle.
580
+ Returns:
581
+ int: HL revision.
605
582
  """
606
583
  global _hlmlOBJ
607
584
  rev = ctypes.c_int()
@@ -613,11 +590,11 @@ def hlmlDeviceGetHLRevision(device: hlml_t.HLML_DEVICE.TYPE) -> int:
613
590
  return rev.value
614
591
 
615
592
  def hlmlDeviceGetPCBInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_pcb_info:
616
- """ Returns the PCB info
617
- Parameters:
618
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
619
- Returns:
620
- pcb (c_hlml_pcb_info) - The info about the device's PCB.
593
+ """Get PCB info of the device.
594
+ Args:
595
+ device (HLML_DEVICE.TYPE): Device handle.
596
+ Returns:
597
+ c_hlml_pcb_info: PCB info.
621
598
  """
622
599
  global _hlmlOBJ
623
600
  pcb = hlml_t.c_hlml_pcb_info()
@@ -628,12 +605,12 @@ def hlmlDeviceGetPCBInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_pcb_i
628
605
  check_return(ret)
629
606
  return pcb
630
607
 
631
- def hlmlDeviceGetSerial(device: hlml_t.HLML_DEVICE.TYPE) -> str:
632
- """ Returns the unique board sn
633
- Parameters:
634
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
635
- Returns:
636
- ser (str) - The serial number of the device.
608
+ def hlmlDeviceGetSerial(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
609
+ """Get unique board serial number.
610
+ Args:
611
+ device (HLML_DEVICE.TYPE): Device handle.
612
+ Returns:
613
+ bytes: Serial number.
637
614
  """
638
615
  global _hlmlOBJ
639
616
  ser_len = hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE
@@ -646,11 +623,11 @@ def hlmlDeviceGetSerial(device: hlml_t.HLML_DEVICE.TYPE) -> str:
646
623
  return ser.value
647
624
 
648
625
  def hlmlDeviceGetModuleID(device: hlml_t.HLML_DEVICE.TYPE) -> int:
649
- """ Retrieves the module id configured on the device.
650
- Parameters:
651
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
652
- Returns:
653
- module_id (int) - The module id configured on the device.
626
+ """Get module ID configured on the device.
627
+ Args:
628
+ device (HLML_DEVICE.TYPE): Device handle.
629
+ Returns:
630
+ int: Module ID.
654
631
  """
655
632
  global _hlmlOBJ
656
633
  module_id = ctypes.c_uint()
@@ -662,11 +639,11 @@ def hlmlDeviceGetModuleID(device: hlml_t.HLML_DEVICE.TYPE) -> int:
662
639
  return module_id.value
663
640
 
664
641
  def hlmlDeviceGetBoardID(device: hlml_t.HLML_DEVICE.TYPE) -> int:
665
- """ Retrieves the device boardID ( 0 - 7 )
666
- Parameters:
667
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
668
- Returns:
669
- brd (int) - The board id of which slot the device is in.
642
+ """Get device board ID (slot number between 0 and 7).
643
+ Args:
644
+ device (HLML_DEVICE.TYPE): Device handle.
645
+ Returns:
646
+ int: Board ID.
670
647
  """
671
648
  global _hlmlOBJ
672
649
  brd = ctypes.c_uint()
@@ -678,13 +655,12 @@ def hlmlDeviceGetBoardID(device: hlml_t.HLML_DEVICE.TYPE) -> int:
678
655
  return brd.value
679
656
 
680
657
  def hlmlDeviceGetPCIEThroughput(device: hlml_t.HLML_DEVICE.TYPE, counter_type: int) -> int:
681
- """ Retrieve PCIe utilization information ( over 10ms interval )
682
- counter_type ( 0-TX / 1-RX )
683
- Parameters:
684
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
685
- counter_type (int) -----------------------------------------------------------------------------
686
- Returns:
687
- throughput (int) - The throughput on the PCIE Transfer or Recieve Connection.
658
+ """Get PCIe utilization information (over 10ms interval).
659
+ Args:
660
+ device (HLML_DEVICE.TYPE): Device handle.
661
+ counter_type (int): 0 for TX, 1 for RX.
662
+ Returns:
663
+ int: PCIe throughput.
688
664
  """
689
665
  global _hlmlOBJ
690
666
  pcie = ctypes.c_uint()
@@ -696,11 +672,11 @@ def hlmlDeviceGetPCIEThroughput(device: hlml_t.HLML_DEVICE.TYPE, counter_type: i
696
672
  return pcie.value
697
673
 
698
674
  def hlmlDeviceGetPCIEReplayCounter(device: hlml_t.HLML_DEVICE.TYPE) -> int:
699
- """ Retrieve the PCIe replay counter
700
- Parameters:
701
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
702
- Returns:
703
- pcie (int) - The replay counter of the PCIE device.
675
+ """Get PCIe replay counter.
676
+ Args:
677
+ device (HLML_DEVICE.TYPE): Device handle.
678
+ Returns:
679
+ int: Replay counter.
704
680
  """
705
681
  global _hlmlOBJ
706
682
  pcie = ctypes.c_uint()
@@ -712,11 +688,11 @@ def hlmlDeviceGetPCIEReplayCounter(device: hlml_t.HLML_DEVICE.TYPE) -> int:
712
688
  return pcie.value
713
689
 
714
690
  def hlmlDeviceGetCurrPCIELinkGeneration(device: hlml_t.HLML_DEVICE.TYPE) -> int:
715
- """ Retrieve the current PCIe link generation
716
- Parameters:
717
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
718
- Returns:
719
- link (int) - The generation of the device's PCIe link.
691
+ """Get current PCIe link generation.
692
+ Args:
693
+ device (HLML_DEVICE.TYPE): Device handle.
694
+ Returns:
695
+ int: PCIe link generation.
720
696
  """
721
697
  global _hlmlOBJ
722
698
  link = ctypes.c_uint()
@@ -728,11 +704,11 @@ def hlmlDeviceGetCurrPCIELinkGeneration(device: hlml_t.HLML_DEVICE.TYPE) -> int:
728
704
  return link.value
729
705
 
730
706
  def hlmlDeviceGetCurrPCIELinkWidth(device: hlml_t.HLML_DEVICE.TYPE) -> int:
731
- """ Retrieve the current PCIe link width
732
- Parameters:
733
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
734
- Returns:
735
- width (int) - The width or lanes of the PCIE connection.
707
+ """Get current PCIe link width.
708
+ Args:
709
+ device (HLML_DEVICE.TYPE): Device handle.
710
+ Returns:
711
+ int: PCIe link width.
736
712
  """
737
713
  global _hlmlOBJ
738
714
  width = ctypes.c_uint()
@@ -744,11 +720,11 @@ def hlmlDeviceGetCurrPCIELinkWidth(device: hlml_t.HLML_DEVICE.TYPE) -> int:
744
720
  return width.value
745
721
 
746
722
  def hlmlDeviceGetCurrentClocksThrottleReasons(device: hlml_t.HLML_DEVICE.TYPE) -> int:
747
- """ Retrieves the current clocks reason for throttling
748
- Parameters:
749
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
750
- Returns:
751
- reason (int) - A code for the reason for the current clock throttle.
723
+ """Get current clocks throttle reason.
724
+ Args:
725
+ device (HLML_DEVICE.TYPE): Device handle.
726
+ Returns:
727
+ int: Throttle reason code.
752
728
  """
753
729
  global _hlmlOBJ
754
730
  reason = ctypes.c_ulonglong()
@@ -760,11 +736,11 @@ def hlmlDeviceGetCurrentClocksThrottleReasons(device: hlml_t.HLML_DEVICE.TYPE) -
760
736
  return reason.value
761
737
 
762
738
  def hlmlDeviceGetTotalEnergyConsumption(device: hlml_t.HLML_DEVICE.TYPE) -> int:
763
- """ Retrieves total energy consumption in mJ since the driver was last reloaded
764
- Parameters:
765
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
766
- Returns:
767
- energy (int) - Total energy consumption of the habana device.
739
+ """Get total energy consumption in mJ since last driver reload.
740
+ Args:
741
+ device (HLML_DEVICE.TYPE): Device handle.
742
+ Returns:
743
+ int: Total energy consumption in mJ.
768
744
  """
769
745
  global _hlmlOBJ
770
746
  energy = ctypes.c_ulonglong()
@@ -776,14 +752,13 @@ def hlmlDeviceGetTotalEnergyConsumption(device: hlml_t.HLML_DEVICE.TYPE) -> int:
776
752
  return energy.value
777
753
 
778
754
  def hlmlDeviceGetMacAddrInfo(device: hlml_t.HLML_DEVICE.TYPE) -> Tuple[Tuple[int, int], Tuple[int, int]]:
779
- """ Retrieves the masks for supported ports and external ports.
780
- Parameters:
781
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
782
- Returns:
783
- (mask, ext_mask)
784
- mask is a tuple of two ints containing bitmask for supported ports.
785
- mask_ext is a tuple of two ints containing bitmask for external
786
- ports within the supported ports.
755
+ """Get masks for supported and external ports.
756
+ Args:
757
+ device (HLML_DEVICE.TYPE): Device handle.
758
+ Returns:
759
+ Tuple[Tuple[int, int], Tuple[int, int]]: (mask, ext_mask), where:
760
+ mask: Bitmask of supported ports.
761
+ ext_mask: Bitmask of external ports (subset of supported).
787
762
  """
788
763
  global _hlmlOBJ
789
764
  mask = (ctypes.c_uint64 * 2)()
@@ -796,12 +771,12 @@ def hlmlDeviceGetMacAddrInfo(device: hlml_t.HLML_DEVICE.TYPE) -> Tuple[Tuple[int
796
771
  return (mask[0], mask[1]), (ext_mask[0], ext_mask[1])
797
772
 
798
773
  def hlmlDeviceNicGetLink(device: hlml_t.HLML_DEVICE.TYPE, port: int) -> bool:
799
- """ Retrieves the NICs link status (up/down) for the requested port.
800
- Parameters:
801
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
802
- port - Port for which the status is requested.
803
- Returns:
804
- up (bool) - Status of the port, True if up and False if down.
774
+ """Get NIC link status (up/down) for the requested port.
775
+ Args:
776
+ device (HLML_DEVICE.TYPE): Device handle.
777
+ port (int): Port number.
778
+ Returns:
779
+ bool: Port status. True if up, False if down.
805
780
  """
806
781
  global _hlmlOBJ
807
782
  up = ctypes.c_bool()
@@ -813,13 +788,13 @@ def hlmlDeviceNicGetLink(device: hlml_t.HLML_DEVICE.TYPE, port: int) -> bool:
813
788
  return up.value
814
789
 
815
790
  def hlmlDeviceNicGetStatistics(device: hlml_t.HLML_DEVICE.TYPE, port: int, num_of_counts: int = None) -> hlml_t.c_hlml_nic_stats_info:
816
- """ Retrieves the NICs statistics for the requested port.
817
- Parameters:
818
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
819
- port (int) - Port for which the stats is requested.
820
- [optional] num_of_counts (int) - num of counts to allocate
821
- Returns:
822
- nic_stats_info (c_hlml_nic_stats_info) - The nic statistics
791
+ """Get NIC statistics for the requested port.
792
+ Args:
793
+ device (HLML_DEVICE.TYPE): Device handle.
794
+ port (int): Port number.
795
+ num_of_counts (int, optional): Number of counts to allocate.
796
+ Returns:
797
+ c_hlml_nic_stats_info: NIC statistics.
823
798
  """
824
799
  global _hlmlOBJ
825
800
  nic_stats_info = hlml_t.c_hlml_nic_stats_info(port, num_of_counts)
@@ -830,10 +805,10 @@ def hlmlDeviceNicGetStatistics(device: hlml_t.HLML_DEVICE.TYPE, port: int, num_o
830
805
  check_return(ret)
831
806
  return nic_stats_info
832
807
 
833
- def hlmlGetHLMLVersion() -> str:
834
- """ Returns version of hlml library.
835
- Returns:
836
- ver (str) - Version of hlml library.
808
+ def hlmlGetHLMLVersion() -> bytes:
809
+ """Get version of HLML library.
810
+ Returns:
811
+ bytes: HLML library version.
837
812
  """
838
813
  global _hlmlOBJ
839
814
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -845,10 +820,10 @@ def hlmlGetHLMLVersion() -> str:
845
820
  check_return(ret)
846
821
  return version.value
847
822
 
848
- def hlmlGetDriverVersion() -> str:
849
- """ Return version of driver.
850
- Returns:
851
- ver (str) - Version of driver.
823
+ def hlmlGetDriverVersion() -> bytes:
824
+ """Get version of driver.
825
+ Returns:
826
+ bytes: Driver version.
852
827
  """
853
828
  global _hlmlOBJ
854
829
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -860,10 +835,10 @@ def hlmlGetDriverVersion() -> str:
860
835
  check_return(ret)
861
836
  return version.value
862
837
 
863
- def hlmlGetNicDriverVersion() -> str:
864
- """ Return version of NIC driver.
865
- Returns:
866
- ver (str) - Version of NIC driver.
838
+ def hlmlGetNicDriverVersion() -> bytes:
839
+ """Get version of NIC driver.
840
+ Returns:
841
+ bytes: NIC driver version.
867
842
  """
868
843
  global _hlmlOBJ
869
844
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -875,12 +850,12 @@ def hlmlGetNicDriverVersion() -> str:
875
850
  check_return(ret)
876
851
  return version.value
877
852
 
878
- def hlmlDeviceGetModelNumber(device: hlml_t.HLML_DEVICE.TYPE) -> str:
879
- """ Returns model number.
880
- Parameters:
881
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
882
- Returns:
883
- model (str) - model number (in string format).
853
+ def hlmlDeviceGetModelNumber(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
854
+ """Get model number of the device.
855
+ Args:
856
+ device (HLML_DEVICE.TYPE): Device handle.
857
+ Returns:
858
+ bytes: Model number.
884
859
  """
885
860
  global _hlmlOBJ
886
861
  num_len = hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE
@@ -892,12 +867,12 @@ def hlmlDeviceGetModelNumber(device: hlml_t.HLML_DEVICE.TYPE) -> str:
892
867
  check_return(ret)
893
868
  return num_str.value
894
869
 
895
- def hlmlDeviceGetFirmwareFITVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
896
- """ Return firmware fit version.
897
- Parameters:
898
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
899
- Returns:
900
- ver (str) - firmware fit version.
870
+ def hlmlDeviceGetFirmwareFITVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
871
+ """Get firmware FIT version.
872
+ Args:
873
+ device (HLML_DEVICE.TYPE): Device handle.
874
+ Returns:
875
+ bytes: Firmware FIT version.
901
876
  """
902
877
  global _hlmlOBJ
903
878
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -909,12 +884,12 @@ def hlmlDeviceGetFirmwareFITVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
909
884
  check_return(ret)
910
885
  return ver_str.value
911
886
 
912
- def hlmlDeviceGetFirmwareSPIVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
913
- """ Return firmware spi version.
914
- Parameters:
915
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
916
- Returns:
917
- ver (str) - firmware spi version.
887
+ def hlmlDeviceGetFirmwareSPIVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
888
+ """Get firmware SPI version.
889
+ Args:
890
+ device (HLML_DEVICE.TYPE): Device handle.
891
+ Returns:
892
+ bytes: Firmware SPI version.
918
893
  """
919
894
  global _hlmlOBJ
920
895
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -926,12 +901,12 @@ def hlmlDeviceGetFirmwareSPIVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
926
901
  check_return(ret)
927
902
  return ver_str.value
928
903
 
929
- def hlmlDeviceGetFWBootVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
930
- """ Return fw boot version.
931
- Parameters:
932
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
933
- Returns:
934
- ver (str) - fw boot version.
904
+ def hlmlDeviceGetFWBootVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
905
+ """Get firmware boot version.
906
+ Args:
907
+ device (HLML_DEVICE.TYPE): Device handle.
908
+ Returns:
909
+ bytes: Firmware boot version.
935
910
  """
936
911
  global _hlmlOBJ
937
912
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -943,12 +918,12 @@ def hlmlDeviceGetFWBootVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
943
918
  check_return(ret)
944
919
  return ver_str.value
945
920
 
946
- def hlmlDeviceGetFWOSVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
947
- """ Return fw os version.
948
- Parameters:
949
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
950
- Returns:
951
- ver (str) - fw os version.
921
+ def hlmlDeviceGetFWOSVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
922
+ """Get firmware OS version.
923
+ Args:
924
+ device (HLML_DEVICE.TYPE): Device handle.
925
+ Returns:
926
+ bytes: Firmware OS version.
952
927
  """
953
928
  global _hlmlOBJ
954
929
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -960,12 +935,12 @@ def hlmlDeviceGetFWOSVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
960
935
  check_return(ret)
961
936
  return ver_str.value
962
937
 
963
- def hlmlDeviceGetCPLDVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
964
- """ Return cpld version.
965
- Parameters:
966
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
967
- Returns:
968
- ver (str) - cpld version.
938
+ def hlmlDeviceGetCPLDVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
939
+ """Get CPLD version.
940
+ Args:
941
+ device (HLML_DEVICE.TYPE): Device handle.
942
+ Returns:
943
+ bytes: CPLD version.
969
944
  """
970
945
  global _hlmlOBJ
971
946
  ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
@@ -978,11 +953,9 @@ def hlmlDeviceGetCPLDVersion(device: hlml_t.HLML_DEVICE.TYPE) -> str:
978
953
  return ver_str.value
979
954
 
980
955
  def hlmlDeviceClearCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE) -> None:
981
- """ Clears a devices Cpu affinity
982
- Parameters:
983
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
984
- Returns:
985
- None.
956
+ """Clear device's CPU affinity.
957
+ Args:
958
+ device (HLML_DEVICE.TYPE): Device handle.
986
959
  """
987
960
  global _hlmlOBJ
988
961
 
@@ -993,12 +966,12 @@ def hlmlDeviceClearCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE) -> None:
993
966
  return None
994
967
 
995
968
  def hlmlDeviceGetCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE, cpu_set_size: int):
996
- """ Retrieves the CPU affinity set associated with a device.
997
- Parameters:
998
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
999
- cpu_set_size - The size of the cpu set.
1000
- Returns:
1001
- cpu_set (int) - The cpu set.
969
+ """Get CPU affinity set associated with a device.
970
+ Args:
971
+ device (HLML_DEVICE.TYPE): Device handle.
972
+ cpu_set_size (int): Size of the CPU set.
973
+ Returns:
974
+ array: CPU set.
1002
975
  """
1003
976
  global _hlmlOBJ
1004
977
  cpu_set = (ctypes.c_ulong * cpu_set_size)()
@@ -1010,13 +983,13 @@ def hlmlDeviceGetCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE, cpu_set_size: int)
1010
983
  return cpu_set
1011
984
 
1012
985
  def hlmlDeviceGetCpuAffinityWithinScope(device: hlml_t.HLML_DEVICE.TYPE, cpu_set_size: int, scope: hlml_t.HLML_AFFINITY_SCOPE.TYPE):
1013
- """ Retrieves the CPU affinity set associated with a device.
1014
- Parameters:
1015
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1016
- cpu_set_size - The size of the cpu set.
1017
- scope - The affinity scope.
1018
- Returns:
1019
- cpu_set (int) - The cpu set.
986
+ """Get CPU affinity set associated with a device.
987
+ Args:
988
+ device (HLML_DEVICE.TYPE): Device handle.
989
+ cpu_set_size (int): Size of the CPU set.
990
+ scope (HLML_AFFINITY_SCOPE.TYPE): Affinity scope.
991
+ Returns:
992
+ array: CPU set.
1020
993
  """
1021
994
  global _hlmlOBJ
1022
995
  cpu_set = (ctypes.c_ulong * cpu_set_size)()
@@ -1028,13 +1001,13 @@ def hlmlDeviceGetCpuAffinityWithinScope(device: hlml_t.HLML_DEVICE.TYPE, cpu_set
1028
1001
  return cpu_set
1029
1002
 
1030
1003
  def hlmlDeviceGetMemoryAffinity(device: hlml_t.HLML_DEVICE.TYPE, node_set_size: int, scope: hlml_t.HLML_AFFINITY_SCOPE.TYPE):
1031
- """ Retrieves the memory affinity set associated with a device.
1032
- Parameters:
1033
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1034
- node_set_size - The size of the node set.
1035
- scope - The affinity scope.
1036
- Returns:
1037
- node_set (int) - The node set.
1004
+ """Get memory affinity set associated with a device.
1005
+ Args:
1006
+ device (HLML_DEVICE.TYPE): Device handle.
1007
+ node_set_size (int): Size of the node set.
1008
+ scope (HLML_AFFINITY_SCOPE.TYPE): Affinity scope.
1009
+ Returns:
1010
+ array: Node set.
1038
1011
  """
1039
1012
  global _hlmlOBJ
1040
1013
  node_set = (ctypes.c_ulong * node_set_size)()
@@ -1046,11 +1019,9 @@ def hlmlDeviceGetMemoryAffinity(device: hlml_t.HLML_DEVICE.TYPE, node_set_size:
1046
1019
  return node_set
1047
1020
 
1048
1021
  def hlmlDeviceSetCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE) -> None:
1049
- """ Sets the CPU affinity with a device.
1050
- Parameters:
1051
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1052
- Returns:
1053
- None.
1022
+ """Set CPU affinity for a device.
1023
+ Args:
1024
+ device (HLML_DEVICE.TYPE): Device handle.
1054
1025
  """
1055
1026
  global _hlmlOBJ
1056
1027
 
@@ -1061,14 +1032,12 @@ def hlmlDeviceSetCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE) -> None:
1061
1032
  return None
1062
1033
 
1063
1034
  def hlmlDeviceGetViolationStatus(device: hlml_t.HLML_DEVICE.TYPE, perf_policy: hlml_t.HLML_PERF_POLICY.TYPE) -> hlml_t.c_hlml_violation_time:
1064
- """ Gets the violation status of a device.
1065
- Parameters:
1066
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1067
- perf_policy_type (HLML_PERF_POLICY.TYPE) - The perf policy type (
1068
- 0=HLML_PERF_POLICY_POWER
1069
- 1=HLML_PERF_POLICY_THERMAL)
1070
- Returns:
1071
- violation_time (c_hlml_violation_time) - The violation status of the device.
1035
+ """Get violation status of a device for a given performance policy.
1036
+ Args:
1037
+ device (HLML_DEVICE.TYPE): Device handle.
1038
+ perf_policy (HLML_PERF_POLICY.TYPE): Performance policy type.
1039
+ Returns:
1040
+ c_hlml_violation_time: Violation status, comprised of reference time and violation time.
1072
1041
  """
1073
1042
  global _hlmlOBJ
1074
1043
 
@@ -1081,12 +1050,12 @@ def hlmlDeviceGetViolationStatus(device: hlml_t.HLML_DEVICE.TYPE, perf_policy: h
1081
1050
  return violation_time
1082
1051
 
1083
1052
  def hlmlDeviceGetReplacedRowsCount(device: hlml_t.HLML_DEVICE.TYPE, cause: hlml_t.HLML_ROW_REPLACEMENT_CAUSE.TYPE) -> int:
1084
- """ Returns the number of replaced rows.
1085
- Parameters:
1086
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1087
- cause (HLML_ROW_REPLACEMENT_CAUSE.TYPE) - The replacement cause to query.
1088
- Returns:
1089
- row_count -> The number of replaced rows
1053
+ """Get number of replaced rows for a given cause.
1054
+ Args:
1055
+ device (HLML_DEVICE.TYPE): Device handle.
1056
+ cause (HLML_ROW_REPLACEMENT_CAUSE.TYPE): Replacement cause.
1057
+ Returns:
1058
+ int: Number of replaced rows.
1090
1059
  """
1091
1060
  global _hlmlOBJ
1092
1061
 
@@ -1099,12 +1068,13 @@ def hlmlDeviceGetReplacedRowsCount(device: hlml_t.HLML_DEVICE.TYPE, cause: hlml_
1099
1068
  return row_count.value
1100
1069
 
1101
1070
  def hlmlDeviceGetReplacedRows(device: hlml_t.HLML_DEVICE.TYPE, cause: hlml_t.HLML_ROW_REPLACEMENT_CAUSE.TYPE, row_count: int):
1102
- """ Returns an array of rows replaced by the given cause.
1103
- Parameters:
1104
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1105
- cause (HLML_ROW_REPLACEMENT_CAUSE.TYPE) - The replacement cause to query.
1106
- Returns:
1107
- addresses - An array of hlml_t.c_hlml_row_address structures.
1071
+ """Get array of replaced rows for a given cause.
1072
+ Args:
1073
+ device (HLML_DEVICE.TYPE): Device handle.
1074
+ cause (HLML_ROW_REPLACEMENT_CAUSE.TYPE): Replacement cause.
1075
+ row_count (int): Number of rows to retrieve.
1076
+ Returns:
1077
+ array: Array of hlml_t.c_hlml_row_address structures.
1108
1078
  """
1109
1079
  global _hlmlOBJ
1110
1080
 
@@ -1118,11 +1088,11 @@ def hlmlDeviceGetReplacedRows(device: hlml_t.HLML_DEVICE.TYPE, cause: hlml_t.HLM
1118
1088
  return addresses
1119
1089
 
1120
1090
  def hlmlDeviceGetReplacedRowsPendingStatus(device: hlml_t.HLML_DEVICE.TYPE) -> int:
1121
- """ Returns the pending status of replaced rows.
1122
- Parameters:
1123
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1124
- Returns:
1125
- is_pending - If there is pending row status.
1091
+ """Get pending status of replaced rows.
1092
+ Args:
1093
+ device (HLML_DEVICE.TYPE): Device handle.
1094
+ Returns:
1095
+ int: Pending status. True if there are pending replaced rows, False otherwise.
1126
1096
  """
1127
1097
  global _hlmlOBJ
1128
1098
 
@@ -1135,11 +1105,11 @@ def hlmlDeviceGetReplacedRowsPendingStatus(device: hlml_t.HLML_DEVICE.TYPE) -> i
1135
1105
  return is_pending.value
1136
1106
 
1137
1107
  def hlmlDeviceGetOperationStatus(device: hlml_t.HLML_DEVICE.TYPE) -> str:
1138
- """ Return Operation Status.
1139
- Parameters:
1140
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1141
- Returns:
1142
- status (str) - operation status.
1108
+ """Get operation status of the device.
1109
+ Args:
1110
+ device (HLML_DEVICE.TYPE): Device handle.
1111
+ Returns:
1112
+ str: Operation status.
1143
1113
  """
1144
1114
  global _hlmlOBJ
1145
1115
  sts_len = hlml_t.COMMON_DEFINE.STATUS_MAX_LEN
@@ -1151,12 +1121,12 @@ def hlmlDeviceGetOperationStatus(device: hlml_t.HLML_DEVICE.TYPE) -> str:
1151
1121
  check_return(ret)
1152
1122
  return sts_str.value
1153
1123
 
1154
- def hlmlDeviceGetPowerManagementMode(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.HLML_ENABLE_STATE:
1155
- """ Acquire name of device from handle
1156
- Parameters:
1157
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1158
- Returns:
1159
- mode (int) - The power management mode of the device.
1124
+ def hlmlDeviceGetPowerManagementMode(device: hlml_t.HLML_DEVICE.TYPE) -> int:
1125
+ """Get power management mode of the device.
1126
+ Args:
1127
+ device (HLML_DEVICE.TYPE): Device handle.
1128
+ Returns:
1129
+ int: Power management mode.
1160
1130
  """
1161
1131
  global _hlmlOBJ
1162
1132
  mode = ctypes.c_uint()
@@ -1167,12 +1137,11 @@ def hlmlDeviceGetPowerManagementMode(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.
1167
1137
  return mode.value
1168
1138
 
1169
1139
  def hlmlDeviceGetPowerManagementLimit(device: hlml_t.HLML_DEVICE.TYPE) -> int:
1170
- """ Returns the pending status of replaced rows.
1171
- Parameters:
1172
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1173
- Returns:
1174
- limit (int) - Reference in which to return the power management
1175
- limit in mW
1140
+ """Get power management limit of the device in mW.
1141
+ Args:
1142
+ device (HLML_DEVICE.TYPE): Device handle.
1143
+ Returns:
1144
+ int: Power management limit in mW.
1176
1145
  """
1177
1146
  global _hlmlOBJ
1178
1147
  power_max = ctypes.c_uint()
@@ -1183,12 +1152,11 @@ def hlmlDeviceGetPowerManagementLimit(device: hlml_t.HLML_DEVICE.TYPE) -> int:
1183
1152
  return power_max.value
1184
1153
 
1185
1154
  def hlmlDeviceGetPowerManagementLimitConstraints(device: hlml_t.HLML_DEVICE.TYPE) -> Tuple[int, int]:
1186
- """ Returns the power management limit constraints of the device.
1187
- Parameters:
1188
- device (HLML_DEVICE.TYPE) - The handle for a habana device.
1189
- Returns:
1190
- min_limit (int) - The minimum power management limit of the device.
1191
- max_limit (int) - The maximum power management limit of the device.
1155
+ """Get power management limit constraints (min, max) for the device.
1156
+ Args:
1157
+ device (HLML_DEVICE.TYPE): Device handle.
1158
+ Returns:
1159
+ Tuple[int, int]: (min_limit, max_limit)
1192
1160
  """
1193
1161
  global _hlmlOBJ
1194
1162
  min_limit = ctypes.c_uint()
@@ -1199,4 +1167,3 @@ def hlmlDeviceGetPowerManagementLimitConstraints(device: hlml_t.HLML_DEVICE.TYPE
1199
1167
 
1200
1168
  check_return(ret)
1201
1169
  return min_limit.value, max_limit.value
1202
-