Skip to main content

ArcTensor

Struct ArcTensor 

Source
pub struct ArcTensor(pub Arc<ReentrantMutex<RefCell<Tensor>>>);
Expand description

原子引用计数(线程安全)张量句柄。

Tuple Fields§

§0: Arc<ReentrantMutex<RefCell<Tensor>>>

Implementations§

Source§

impl ArcTensor

Source

pub fn lock(&self) -> ReentrantMutexGuard<'_, RefCell<Tensor>>

获取内部数据的互斥锁守卫

Source

pub fn from_tensor(t: Tensor) -> Self

Tensor 创建新的 ArcTensor

Source

pub fn into_inner(self) -> Arc<ReentrantMutex<RefCell<Tensor>>>

获取内部句柄的克隆

Source§

impl ArcTensor

Source

pub fn shape(&self) -> Vec<usize>

Source

pub fn dtype(&self) -> DType

Source

pub fn device(&self) -> Device

Source§

impl ArcTensor

Source

pub fn to_vec<T: Pod + DTypeMapping>(&self) -> Result<Vec<T>>

Source

pub fn from_vec<T: Pod + DTypeMapping>( data: Vec<T>, shape: Vec<usize>, device: Device, ) -> Result<Self>

Source

pub fn from_scalar<T: Pod + DTypeMapping>( value: T, device: Device, ) -> Result<Self>

Source§

impl ArcTensor

Source

pub fn zeros(shape: Vec<usize>, dtype: DType, device: Device) -> Result<Self>

创建指定形状和数据类型的零张量

Source

pub fn ones(shape: Vec<usize>, dtype: DType, device: Device) -> Result<Self>

创建指定形状和数据类型的全一张量

Source

pub fn empty(shape: Vec<usize>, dtype: DType, device: Device) -> Result<Self>

创建指定形状和数据类型的空张量(未初始化,当前为零初始化)

Source§

impl ArcTensor

Source

pub fn as_view(&self) -> ArcTensorView

获取内部句柄的视图

Source

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

Source

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

Source

pub fn T(&self) -> Result<ArcTensorView>

Source§

impl ArcTensor

Source

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

Trait Implementations§

Source§

impl Add for ArcTensor

Source§

type Output = ArcTensor

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for ArcTensor

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl AsView for ArcTensor

Source§

impl Clone for ArcTensor

Source§

fn clone(&self) -> ArcTensor

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 Debug for ArcTensor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Tensor> for ArcTensor

Source§

fn from(t: Tensor) -> Self

Converts to this type from the input type.

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.