pub struct AnyTensorRef { /* private fields */ }Expand description
This is a zero sized type
Implementations§
Source§impl AnyTensorRef
impl AnyTensorRef
Sourcepub fn shape(&self) -> TensorShape
pub fn shape(&self) -> TensorShape
Get the shape of the tensor
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Get the dimensions of the tensor
Sourcepub fn size(&self) -> usize
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.
Sourcepub fn element_size(&self) -> usize
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.
Sourcepub fn get_type(&self) -> halide_type_t
pub fn get_type(&self) -> halide_type_t
Get the halide data type of the tensor
Sourcepub fn is_type_of<Ha: HalideType>(&self) -> bool
pub fn is_type_of<Ha: HalideType>(&self) -> bool
Check if the tensor is of the specified data type
Sourcepub fn is_same_type(&self, other: &AnyTensorRef) -> bool
pub fn is_same_type(&self, other: &AnyTensorRef) -> bool
Check if both tensors have the same halide data type
Sourcepub fn get_dimension_type(&self) -> DimensionType
pub fn get_dimension_type(&self) -> DimensionType
Get the dimension type of the tensor
Sourcepub fn is_dynamic_unsized(&self) -> bool
pub fn is_dynamic_unsized(&self) -> bool
Check if the tensor is dynamic and needs resizing
Sourcepub fn copy_from_host_tensor(&mut self, tensor: &AnyTensorRef) -> Result<()>
pub fn copy_from_host_tensor(&mut self, tensor: &AnyTensorRef) -> Result<()>
Copies the data from a host tensor to the self.as_ptr()
Sourcepub fn copy_to_host_tensor(&self, tensor: &mut AnyTensorRef) -> Result<()>
pub fn copy_to_host_tensor(&self, tensor: &mut AnyTensorRef) -> Result<()>
Copies the data from the self.as_ptr() to a host tensor
Sourcepub fn create_host_tensor_from_device<T: HalideType + Copy>(
&self,
copy_data: bool,
) -> Tensor<Owned<T>, Host>
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.