Function: free

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

Frees device memory.

Prototype

  • C Prototype

    aclError aclrtFree(void *devPtr)
    
  • Python Function

    ret = acl.rt.free(dev_ptr)
    

Parameters

Parameter Description
dev_ptr Int, pointer address of the memory to be freed.

Return Values

Return Value Description
ret Int, error code. If 0 is returned, the operation is successful. If other values are returned, the operation fails.

Constraints

  • The acl.rt.free API can be used to free only the memory allocated by the acl.rt.malloc or acl.rt.malloc_cached API.
  • This API immediately frees the input memory. No implicit device synchronization or stream synchronization is performed within the function. Ensure that the memory pointer is not accessed after this API is called.