pub struct MockTensorFactory;Expand description
Mock tensor factory implementing TensorFactory without any ML backend.
Trait Implementations§
Source§impl TensorFactory for MockTensorFactory
impl TensorFactory for MockTensorFactory
Source§fn empty(
&self,
shape: &[usize],
dtype: DataType,
_device: Device,
) -> Result<TensorRef>
fn empty( &self, shape: &[usize], dtype: DataType, _device: Device, ) -> Result<TensorRef>
创建指定形状/数据类型的空张量(
[MVP])Source§fn from_slice(
&self,
data: &[f32],
shape: &[usize],
_dtype: DataType,
_device: Device,
) -> Result<TensorRef>
fn from_slice( &self, data: &[f32], shape: &[usize], _dtype: DataType, _device: Device, ) -> Result<TensorRef>
通过 slice 数据创建张量(
[MVP])Source§fn to_device(&self, tensor: &TensorRef, _device: Device) -> Result<TensorRef>
fn to_device(&self, tensor: &TensorRef, _device: Device) -> Result<TensorRef>
迁移张量到目标设备(
[MVP])Source§fn narrow(
&self,
tensor: &TensorRef,
dim: usize,
start: usize,
length: usize,
) -> Result<TensorRef>
fn narrow( &self, tensor: &TensorRef, dim: usize, start: usize, length: usize, ) -> Result<TensorRef>
执行窄视图操作(
[MVP])Source§fn zeros(
&self,
shape: &[usize],
dtype: DataType,
_device: &Device,
) -> Result<TensorRef>
fn zeros( &self, shape: &[usize], dtype: DataType, _device: &Device, ) -> Result<TensorRef>
Create tensor filled with zeros(
[Phase 2+] 可选实现)Source§fn ones(
&self,
shape: &[usize],
_dtype: DataType,
_device: &Device,
) -> Result<TensorRef>
fn ones( &self, shape: &[usize], _dtype: DataType, _device: &Device, ) -> Result<TensorRef>
Create tensor filled with ones(
[Phase 2+])Source§fn uniform(
&self,
shape: &[usize],
_low: f32,
_high: f32,
dtype: DataType,
_device: &Device,
) -> Result<TensorRef>
fn uniform( &self, shape: &[usize], _low: f32, _high: f32, dtype: DataType, _device: &Device, ) -> Result<TensorRef>
Create tensor from uniform random distribution(
[Phase 2+])Auto Trait Implementations§
impl Freeze for MockTensorFactory
impl RefUnwindSafe for MockTensorFactory
impl Send for MockTensorFactory
impl Sync for MockTensorFactory
impl Unpin for MockTensorFactory
impl UnsafeUnpin for MockTensorFactory
impl UnwindSafe for MockTensorFactory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more