Function: ptr_to_bytes

Applicable Products

  • Ascend 950PR&950DT products: Supported
  • Atlas A3 products: Supported
  • Atlas A2 products: Supported
  • Atlas 200I/500 A2 inference products: Supported
  • Atlas inference products: Supported
  • Atlas training products: Supported

Function

Converts void* data into a bytes object, which can be directly accessed by Python code.

Prototype

bytes_out = acl.util.ptr_to_bytes(ptr, size)

Parameters

Parameter Description
ptr Int, pointer address in the C language. It is the start address of the data that can be accessed.
size Int, data size, in bytes.

Return Values

Return Value Description
bytes_out bytes object

Precautions

Example modification:

bytes_out = acl.util.ptr_to_bytes(bytes_ptr, size)

acl.util.ptr_to_bytes may cause data performance deterioration. Therefore, you are advised to use the data of the acl.util.bytes_to_ptr function for subsequent calculation.