pub struct Tensor<T: TensorType> { /* private fields */ }
Expand description
A generic tensor that can of host / device / owned / borrowed
Implementations§
Source§impl<H: HalideType> Tensor<Host<H>>
impl<H: HalideType> Tensor<Host<H>>
Source§impl<H: HalideType> Tensor<Device<H>>
impl<H: HalideType> Tensor<Device<H>>
Source§impl<T: TensorType> Tensor<T>where
T::H: HalideType,
impl<T: TensorType> Tensor<T>where
T::H: HalideType,
Sourcepub unsafe fn from_ptr(tensor: *mut Tensor) -> Self
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
Sourcepub fn copy_from_host_tensor(
&mut self,
tensor: &Tensor<Host<T::H>>,
) -> Result<()>
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
Sourcepub fn copy_to_host_tensor(&self, tensor: &mut Tensor<Host<T::H>>) -> Result<()>
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
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 element_size(&self) -> usize
pub fn element_size(&self) -> usize
Get the size of the tensor when counted by elements
Sourcepub fn print_shape(&self)
pub fn print_shape(&self)
Print the shape 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 unsafe fn halide_buffer(&self) -> *const halide_buffer_t
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
Sourcepub unsafe fn halide_buffer_mut(&self) -> *mut halide_buffer_t
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
Sourcepub fn get_dimension_type(&self) -> DimensionType
pub fn get_dimension_type(&self) -> DimensionType
Get the dimension type of the tensor
Sourcepub fn get_type(&self) -> halide_type_t
pub fn get_type(&self) -> halide_type_t
Get the data type of the tensor
Sourcepub fn is_type_of<H: HalideType>(&self) -> bool
pub fn is_type_of<H: HalideType>(&self) -> bool
Check if the tensor is of the specified data type
Source§impl<T: MutableTensorType> Tensor<T>where
T::H: HalideType,
impl<T: MutableTensorType> Tensor<T>where
T::H: HalideType,
Source§impl<T: HostTensorType> Tensor<T>where
T::H: HalideType,
impl<T: HostTensorType> Tensor<T>where
T::H: HalideType,
Source§impl<T: DeviceTensorType> Tensor<T>where
T::H: HalideType,
impl<T: DeviceTensorType> Tensor<T>where
T::H: HalideType,
Source§impl<T: OwnedTensorType> Tensor<T>where
T::H: HalideType,
impl<T: OwnedTensorType> Tensor<T>where
T::H: HalideType,
Sourcepub fn new(shape: impl AsTensorShape, dm_type: DimensionType) -> Self
pub fn new(shape: impl AsTensorShape, dm_type: DimensionType) -> Self
Create a new tensor with the specified shape and dimension type
Source§impl<T: HostTensorType + RefTensorType> Tensor<T>where
T::H: HalideType,
impl<T: HostTensorType + RefTensorType> Tensor<T>where
T::H: HalideType,
Sourcepub fn borrowed(shape: impl AsTensorShape, input: impl AsRef<[T::H]>) -> Self
pub fn borrowed(shape: impl AsTensorShape, input: impl AsRef<[T::H]>) -> Self
Try to create a ref tensor from any array-like type
Sourcepub fn borrowed_mut(
shape: impl AsTensorShape,
input: impl AsMut<[T::H]>,
) -> Self
pub fn borrowed_mut( shape: impl AsTensorShape, input: impl AsMut<[T::H]>, ) -> Self
Try to create a mutable ref tensor from any array-like type