pub trait BackendDevice:
Sized
+ Debug
+ Clone {
type Storage: BackendStorage;
Show 14 methods
// Required methods
fn new(_: usize) -> Result<Self>;
fn location(&self) -> DeviceLocation;
fn same_device(&self, _: &Self) -> bool;
fn zeros_impl(&self, _shape: &Shape, _dtype: DType) -> Result<Self::Storage>;
fn ones_impl(&self, _shape: &Shape, _dtype: DType) -> Result<Self::Storage>;
unsafe fn alloc_uninit(
&self,
_shape: &Shape,
_dtype: DType,
) -> Result<Self::Storage>;
fn storage_from_slice<T: WithDType>(&self, _: &[T]) -> Result<Self::Storage>;
fn storage_from_cpu_storage(&self, _: &CpuStorage) -> Result<Self::Storage>;
fn storage_from_cpu_storage_owned(
&self,
_: CpuStorage,
) -> Result<Self::Storage>;
fn rand_uniform(
&self,
_: &Shape,
_: DType,
_: f64,
_: f64,
) -> Result<Self::Storage>;
fn rand_normal(
&self,
_: &Shape,
_: DType,
_: f64,
_: f64,
) -> Result<Self::Storage>;
fn set_seed(&self, _: u64) -> Result<()>;
fn get_current_seed(&self) -> Result<u64>;
fn synchronize(&self) -> Result<()>;
}
Required Associated Types§
type Storage: BackendStorage
Required Methods§
fn new(_: usize) -> Result<Self>
fn location(&self) -> DeviceLocation
fn same_device(&self, _: &Self) -> bool
fn zeros_impl(&self, _shape: &Shape, _dtype: DType) -> Result<Self::Storage>
fn ones_impl(&self, _shape: &Shape, _dtype: DType) -> Result<Self::Storage>
sourceunsafe fn alloc_uninit(
&self,
_shape: &Shape,
_dtype: DType,
) -> Result<Self::Storage>
unsafe fn alloc_uninit( &self, _shape: &Shape, _dtype: DType, ) -> Result<Self::Storage>
§Safety
This function is unsafe as it doesn’t initialize the underlying data store. The caller should ensure that the data is properly initialized as early as possible after this call.
fn storage_from_slice<T: WithDType>(&self, _: &[T]) -> Result<Self::Storage>
fn storage_from_cpu_storage(&self, _: &CpuStorage) -> Result<Self::Storage>
fn storage_from_cpu_storage_owned(&self, _: CpuStorage) -> Result<Self::Storage>
fn rand_uniform( &self, _: &Shape, _: DType, _: f64, _: f64, ) -> Result<Self::Storage>
fn rand_normal( &self, _: &Shape, _: DType, _: f64, _: f64, ) -> Result<Self::Storage>
fn set_seed(&self, _: u64) -> Result<()>
fn get_current_seed(&self) -> Result<u64>
sourcefn synchronize(&self) -> Result<()>
fn synchronize(&self) -> Result<()>
Synchronize should block until all the operations on the device are completed.
Object Safety§
This trait is not object safe.