Struct executorch_sys::torch::executor::TensorImpl

source ·
#[repr(C, align(8))]
pub struct TensorImpl { pub _bindgen_opaque_blob: [u64; 8], }
Expand description

Manages the storage behind an ETensor (torch::executor::Tensor).

Note that instances of this class do not own the arrays given to it (sizes/strides/data), which means that the caller must guarantee that they live longer than a given instance of this class.

Note on types:

Code that uses ETensor should also be able to build against at::Tensor. So, although the overlapping APIs don’t need to be exactly the same, their types should be semantically similar.

Many of the methods in at::Tensor use int64_t for parameter and return types. This can be a waste when building for 32-bit environments. So, TensorImpl and ETensor use ssize_t instead: like int64_t it is signed, but it will match the native word size of the target architecture. This will avoid unnecessarily expensive uses of 64-bit integers on 32-bit machines.

But, since the types are not identical, code that uses ETensor needs to be generic about the local types it uses when working with these methods. In most cases, auto will do the trick. In the worst case, code can be guarded with #ifdef USE_ATEN_LIB.

Fields§

§_bindgen_opaque_blob: [u64; 8]

Implementations§

source§

impl TensorImpl

source

pub unsafe fn nbytes(&self) -> usize

source

pub unsafe fn size(&self, dim: isize) -> isize

source

pub unsafe fn dim(&self) -> isize

source

pub unsafe fn numel(&self) -> isize

source

pub unsafe fn scalar_type(&self) -> ScalarType

source

pub unsafe fn element_size(&self) -> isize

source

pub unsafe fn sizes(&self) -> ArrayRef<TensorImpl_SizesType>

source

pub unsafe fn dim_order(&self) -> ArrayRef<TensorImpl_DimOrderType>

source

pub unsafe fn strides(&self) -> ArrayRef<TensorImpl_StridesType>

source

pub unsafe fn data(&self) -> *const c_void

source

pub unsafe fn mutable_data(&self) -> *mut c_void

source

pub unsafe fn set_data(&mut self, ptr: *mut c_void)

source

pub unsafe fn new( type_: ScalarType, dim: isize, sizes: *mut TensorImpl_SizesType, data: *mut c_void, dim_order: *mut TensorImpl_DimOrderType, strides: *mut TensorImpl_StridesType, dynamism: TensorShapeDynamism, ) -> Self

Trait Implementations§

source§

impl Debug for TensorImpl

source§

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

Formats the value using the given formatter. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.