Struct mnn::tensor::Tensor

source ·
pub struct Tensor<T: TensorType> { /* private fields */ }

Implementations§

source§

impl<H: HalideType> Tensor<Host<H>>

source

pub fn as_ref(&self) -> Tensor<Ref<'_, Host<H>>>

source§

impl<H: HalideType> Tensor<Device<H>>

source

pub fn as_ref(&self) -> Tensor<Ref<'_, Device<H>>>

source§

impl<T: TensorType> Tensor<T>
where T::H: HalideType,

source

pub unsafe fn from_ptr(tensor: *mut Tensor) -> Self

This function constructs a Tensor type from a raw pointer

§Safety

Since this constructs a Tensor from a raw pointer we have no way to guarantee that it’s a valid tensor or it’s lifetime

source

pub fn copy_from_host_tensor( &mut self, tensor: &Tensor<Host<T::H>>, ) -> Result<()>

Copies the data from a host tensor to the self tensor

source

pub fn copy_to_host_tensor(&self, tensor: &mut Tensor<Host<T::H>>) -> Result<()>

Copies the data from the self tensor to a host tensor

source

pub fn device_id(&self) -> u64

source

pub fn shape(&self) -> TensorShape

Get the shape of the tensor

source

pub fn dimensions(&self) -> usize

source

pub fn width(&self) -> u32

source

pub fn height(&self) -> u32

source

pub fn channel(&self) -> u32

source

pub fn batch(&self) -> u32

source

pub fn size(&self) -> usize

source

pub fn element_size(&self) -> usize

source

pub fn print_shape(&self)

source

pub fn print(&self)

source

pub fn is_dynamic_unsized(&self) -> bool

Check if the tensor is dynamic and needs resizing

source

pub unsafe fn halide_buffer(&self) -> *const halide_buffer_t

DO not use this function directly

§Safety

This is just provided as a 1:1 compat mostly for possible later use

source

pub unsafe fn halide_buffer_mut(&self) -> *mut halide_buffer_t

Do not use this function directly

§Safety

This is just provided as a 1:1 compat mostly for possible later use

source

pub fn get_dimension_type(&self) -> DimensionType

source

pub fn get_type(&self) -> halide_type_t

source

pub fn is_type_of<H: HalideType>(&self) -> bool

source§

impl<T: MutableTensorType> Tensor<T>
where T::H: HalideType,

source

pub fn fill(&mut self, value: T::H)
where T::H: Copy,

source§

impl<T: HostTensorType> Tensor<T>
where T::H: HalideType,

source

pub fn try_host(&self) -> Result<&[T::H]>

Try to map the device tensor to the host memory and get the slice

source

pub fn try_host_mut(&mut self) -> Result<&mut [T::H]>

Try to map the device tensor to the host memory and get the mutable slice

source

pub fn host(&self) -> &[T::H]

source

pub fn host_mut(&mut self) -> &mut [T::H]

source§

impl<T: DeviceTensorType> Tensor<T>
where T::H: HalideType,

source

pub fn wait(&self, map_type: MapType, finish: bool)

source

pub fn create_host_tensor_from_device( &self, copy_data: bool, ) -> Tensor<Host<T::H>>

source§

impl<T: OwnedTensorType> Tensor<T>
where T::H: HalideType,

source

pub fn new(shape: impl AsTensorShape, dm_type: DimensionType) -> Self

source§

impl<T: HostTensorType + RefTensorType> Tensor<T>
where T::H: HalideType,

source

pub fn borrowed(shape: impl AsTensorShape, input: impl AsRef<[T::H]>) -> Self

source

pub fn borrowed_mut( shape: impl AsTensorShape, input: impl AsMut<[T::H]>, ) -> Self

Trait Implementations§

source§

impl<T: OwnedTensorType> Clone for Tensor<T>
where T::H: HalideType,

source§

fn clone(&self) -> Tensor<T>

Returns a copy 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<T: TensorType> Drop for Tensor<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Tensor<T>

§

impl<T> RefUnwindSafe for Tensor<T>
where T: RefUnwindSafe,

§

impl<T> !Send for Tensor<T>

§

impl<T> !Sync for Tensor<T>

§

impl<T> Unpin for Tensor<T>
where T: Unpin,

§

impl<T> UnwindSafe for Tensor<T>
where T: UnwindSafe,

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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

§

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.