Constructs a new Array object from device pointer The example show cases the usage using CUDA API, but usage of this function will be similar in CPU and OpenCL backends also. In the case of OpenCL backend, the pointer would be cl_mem. A short example of how to create an Array from device pointer is shown below but for detailed set of examples, please check out the tutorial book pages: - [Interope
(dev_ptr: *mut T, dims: Dim4)
| 354 | ///} |
| 355 | /// ``` |
| 356 | pub fn new_from_device_ptr(dev_ptr: *mut T, dims: Dim4) -> Self { |
| 357 | let aftype = T::get_af_dtype(); |
| 358 | unsafe { |
| 359 | let mut temp: af_array = std::ptr::null_mut(); |
| 360 | let err_val = af_device_array( |
| 361 | &mut temp as *mut af_array, |
| 362 | dev_ptr as *mut c_void, |
| 363 | dims.ndims() as c_uint, |
| 364 | dims.get().as_ptr() as *const dim_t, |
| 365 | aftype as c_uint, |
| 366 | ); |
| 367 | HANDLE_ERROR(AfError::from(err_val)); |
| 368 | temp.into() |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | /// Returns the backend of the Array |
| 373 | /// |
nothing calls this directly
no test coverage detected