pub trait PoolScalar:
Copy
+ Sized
+ Send
+ Sealed {
// Required methods
unsafe fn pool_acquire(pool: &mut BufferPool, len: usize) -> Vec<Self>;
fn pool_release(pool: &mut BufferPool, buf: Vec<Self>);
}Expand description
Scalar types supported by BufferPool.
The trait is sealed to the scalar dtypes that tenferro currently pools for CPU execution.
§Examples
ⓘ
use tenferro_tensor::buffer_pool::{BufferPool, PoolScalar};
let mut pool = BufferPool::new();
let mut buf = unsafe { <f64 as PoolScalar>::pool_acquire(&mut pool, 2) };
buf.copy_from_slice(&[3.0, 4.0]);
<f64 as PoolScalar>::pool_release(&mut pool, buf);Required Methods§
Sourceunsafe fn pool_acquire(pool: &mut BufferPool, len: usize) -> Vec<Self>
unsafe fn pool_acquire(pool: &mut BufferPool, len: usize) -> Vec<Self>
Acquire a buffer with length len.
The vector length is set without initializing its contents. Callers must overwrite every element before any read.
§Safety
The returned vector may contain uninitialized elements. Reading any element before writing it is undefined behavior.
§Examples
ⓘ
use tenferro_tensor::buffer_pool::{BufferPool, PoolScalar};
let mut pool = BufferPool::new();
let mut buf = unsafe { <f64 as PoolScalar>::pool_acquire(&mut pool, 2) };
buf.copy_from_slice(&[1.0, 2.0]);
assert_eq!(buf, vec![1.0, 2.0]);Sourcefn pool_release(pool: &mut BufferPool, buf: Vec<Self>)
fn pool_release(pool: &mut BufferPool, buf: Vec<Self>)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.