Skip to main content

RcTensorView

Struct RcTensorView 

Source
pub struct RcTensorView { /* private fields */ }

Implementations§

Source§

impl RcTensorView

Source

pub fn elementwise<T, F>( output: &mut Self, inputs: &[&Self], f: F, ) -> Result<()>
where T: Pod + DTypeMapping, F: FnMut(&[T]) -> T,

静态方法:对一组形状相同的视图执行逐元素运算。

  • output: 输出视图(可变)
  • inputs: 输入视图列表,形状必须与输出相同
  • f: 回调函数,参数为各输入视图在当前元素的值,返回输出值。
Source§

impl RcTensorView

Source

pub fn fill_cpu<T: Pod + DTypeMapping>(&mut self, value: T) -> Result<()>

填充 CPU 视图为常量值

Source§

impl RcTensorView

Source

pub fn elementwise_kernel( output: &mut Self, expression: &str, inputs: Vec<&Self>, ) -> Result<()>

Source§

impl RcTensorView

Source

pub fn fill_cuda<T: Pod + DTypeMapping>( output: &mut Self, value: T, ) -> Result<()>

Source§

impl RcTensorView

Source

pub fn new(handle: RcTensor) -> Self

Source

pub fn into_handle(self) -> RcTensor

Source

pub fn handle(&self) -> &RcTensor

Source§

impl RcTensorView

Source

pub fn add(a: &Self, b: &Self, out: &mut Self) -> Result<()>

Source§

impl RcTensorView

Source

pub fn lock(&self) -> &RefCell<Tensor>

Trait Implementations§

Source§

impl Add for RcTensorView

Source§

type Output = RcTensorView

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for RcTensorView

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl Clone for RcTensorView

Source§

fn clone(&self) -> RcTensorView

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl TensorViewOps for RcTensorView

Source§

unsafe fn as_gpu_slice(&self) -> &CudaSlice<u8>

获取 GPU 切片(只读),视图偏移量由内核参数 strides 和 offset 处理。

Source§

unsafe fn as_gpu_slice_mut(&mut self) -> &mut CudaSlice<u8>

获取 GPU 切片(可变)。

Source§

type Handle = RcTensor

Source§

fn new(handle: RcTensor) -> Self

Source§

fn as_strided( &self, new_shape: Vec<usize>, new_strides: Vec<usize>, offset: usize, ) -> Self

Source§

fn is_contiguous(&self) -> bool

Source§

fn shape(&self) -> &[usize]

Source§

fn strides(&self) -> &[usize]

Source§

fn offset(&self) -> &usize

Source§

fn dtype(&self) -> DType

Source§

fn size(&self) -> usize

Source§

fn device(&self) -> Device

Source§

fn assign(&mut self, src: &Self) -> Result<()>

Source§

unsafe fn as_gpu_view(&self) -> CudaView<'_, u8>

Source§

unsafe fn as_gpu_view_mut(&self) -> CudaViewMut<'_, u8>

Source§

unsafe fn raw_data_ptr(&self) -> *mut u8

Source§

fn to(&self, out: &mut Self, target_device: Device) -> Result<()>

Source§

fn to_device(&self, target_device: Device) -> Result<Self>

Source§

fn broadcast_to(&self, target_shape: &[usize]) -> Result<Self>

Source§

fn transpose(&self, axes: &[usize]) -> Result<Self>

Source§

fn slice(&self, info: &SliceInfo) -> Result<Self>

Source§

fn concat_into(views: &[&Self], axis: usize, out: &mut Self) -> Result<()>

Source§

fn split_into( &self, sizes: &[usize], axis: usize, out_views: &mut [Self], ) -> Result<()>

Source§

fn concat(views: &[&Self], axis: usize) -> Result<Self>

Source§

fn split(&self, sizes: &[usize], axis: usize) -> Result<Vec<Self>>

Source§

fn strided_copy_to(&self, dst: &mut Self) -> Result<()>

Source§

fn contiguous_into(&self, out: &mut Self) -> Result<()>

Source§

fn contiguous(&self) -> Result<Self::Handle>

Source§

fn matmul_into(&self, other: &Self, out: &mut Self) -> Result<()>

Source§

fn matmul(&self, other: &Self) -> Result<Self>

Source§

fn fill<T: Pod + DTypeMapping>(&mut self, value: T) -> Result<()>

Source§

fn T(&self) -> Result<Self>

Source§

fn to_cpu(&self) -> Result<Self>

Source§

fn to_gpu(&self, device_id: usize) -> Result<Self>

Source§

fn num_bytes(&self) -> usize

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.