Skip to main content

AnyTensorRef

Struct AnyTensorRef 

Source
pub struct AnyTensorRef { /* private fields */ }
Expand description

This is a zero sized type

Implementations§

Source§

impl AnyTensorRef

Source

pub fn device_id(&self) -> u64

Get the device id of the tensor

Source

pub fn shape(&self) -> TensorShape

Get the shape of the tensor

Source

pub fn dimensions(&self) -> usize

Get the dimensions of the tensor

Source

pub fn width(&self) -> u32

Get the width of the tensor

Source

pub fn height(&self) -> u32

Get the height of the tensor

Source

pub fn channel(&self) -> u32

Get the channel size of the tensor

Source

pub fn batch(&self) -> u32

Get the batch size of the tensor

Source

pub fn size(&self) -> usize

Get the size of the tensor when counted by bytes

Note that for packed layouts (NC4HW4) this includes the padding MNN adds to the channel dimension, so it can be larger than the product of the shape.

Source

pub fn element_size(&self) -> usize

Get the size of the tensor when counted by elements

Note that for packed layouts (NC4HW4) this includes the padding MNN adds to the channel dimension, so it can be larger than the product of the shape.

Source

pub fn get_type(&self) -> halide_type_t

Get the halide data type of the tensor

Source

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

Check if the tensor is of the specified data type

Source

pub fn is_same_type(&self, other: &AnyTensorRef) -> bool

Check if both tensors have the same halide data type

Source

pub fn get_dimension_type(&self) -> DimensionType

Get the dimension type of the tensor

Source

pub fn is_dynamic_unsized(&self) -> bool

Check if the tensor is dynamic and needs resizing

Source

pub fn copy_from_host_tensor(&mut self, tensor: &AnyTensorRef) -> Result<()>

Copies the data from a host tensor to the self.as_ptr()

Source

pub fn copy_to_host_tensor(&self, tensor: &mut AnyTensorRef) -> Result<()>

Copies the data from the self.as_ptr() to a host tensor

Source

pub fn create_host_tensor_from_device<T: HalideType + Copy>( &self, copy_data: bool, ) -> Tensor<Owned<T>, Host>

Create a host tensor from the device tensor with same dimensions and data type and optionally copy the data from the device tensor

§Panics

Panics if the tensor’s element type is not T or the copy fails.

Source

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

Try to wait for the device tensor to finish processing

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

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.
§

impl<T> OpaqueAttachment for T
where T: Send + Sync + 'static,