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
Trait Implementations§
source§impl<T: OwnedTensorType> Clone for Tensor<T>where
T::H: HalideType,
impl<T: OwnedTensorType> Clone for Tensor<T>where
T::H: HalideType,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)