@@ -4,7 +4,7 @@ use dim4::Dim4;
4
4
use defines:: { AfError , DType , Backend } ;
5
5
use error:: HANDLE_ERROR ;
6
6
use util:: { AfArray , DimT , HasAfEnum , MutAfArray , MutVoidPtr } ;
7
- use self :: libc:: { uint8_t, c_void, c_int, c_uint, c_longlong, c_char} ;
7
+ use self :: libc:: { uint8_t, c_void, c_int, c_uint, c_longlong, c_ulong , c_char} ;
8
8
use std:: ffi:: CString ;
9
9
10
10
// Some unused functions from array.h in C-API of ArrayFire
@@ -100,6 +100,8 @@ extern {
100
100
fn af_unlock_array ( arr : AfArray ) -> c_int ;
101
101
102
102
fn af_get_device_ptr ( ptr : MutVoidPtr , arr : AfArray ) -> c_int ;
103
+
104
+ fn af_get_allocated_bytes ( result : * mut c_ulong , arr : AfArray ) -> c_int ;
103
105
}
104
106
105
107
/// A multidimensional data container
@@ -405,6 +407,19 @@ impl Array {
405
407
temp
406
408
}
407
409
}
410
+
411
+ /// Get the size of physical allocated bytes.
412
+ ///
413
+ /// This function will return the size of the parent/owner if the current Array object is an
414
+ /// indexed Array.
415
+ pub fn get_allocated_bytes ( & self ) -> u64 {
416
+ unsafe {
417
+ let mut temp: u64 = 0 ;
418
+ let err_val = af_get_allocated_bytes ( & mut temp as * mut c_ulong , self . handle as AfArray ) ;
419
+ HANDLE_ERROR ( AfError :: from ( err_val) ) ;
420
+ temp
421
+ }
422
+ }
408
423
}
409
424
410
425
/// Used for creating Array object from native resource id
0 commit comments