pub trait BasicOps<B>: TensorKind<B>where
B: Backend,{
type Elem: Element;
Show 37 methods
// Required methods
fn empty(
shape: Shape,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive;
fn zeros(
shape: Shape,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive;
fn ones(
shape: Shape,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive;
fn full<E>(
shape: Shape,
fill_value: E,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive
where E: ElementConversion;
fn reshape(tensor: Self::Primitive, shape: Shape) -> Self::Primitive;
fn transpose(tensor: Self::Primitive) -> Self::Primitive;
fn swap_dims(
tensor: Self::Primitive,
dim1: usize,
dim2: usize,
) -> Self::Primitive;
fn permute(tensor: Self::Primitive, axes: &[usize]) -> Self::Primitive;
fn flip(tensor: Self::Primitive, axes: &[usize]) -> Self::Primitive;
fn slice(tensor: Self::Primitive, slices: &[Slice]) -> Self::Primitive;
fn slice_assign(
tensor: Self::Primitive,
slices: &[Slice],
value: Self::Primitive,
) -> Self::Primitive;
fn select(
tensor: Self::Primitive,
dim: usize,
indices: <B as Backend>::IntTensorPrimitive,
) -> Self::Primitive;
fn select_assign(
tensor: Self::Primitive,
dim: usize,
indices: <B as Backend>::IntTensorPrimitive,
values: Self::Primitive,
update: IndexingUpdateOp,
) -> Self::Primitive;
fn mask_where(
tensor: Self::Primitive,
mask: <B as Backend>::BoolTensorPrimitive,
source: Self::Primitive,
) -> Self::Primitive;
fn mask_fill(
tensor: Self::Primitive,
mask: <B as Backend>::BoolTensorPrimitive,
value: Self::Elem,
) -> Self::Primitive;
fn gather(
dim: usize,
tensor: Self::Primitive,
indices: <B as Backend>::IntTensorPrimitive,
) -> Self::Primitive;
fn scatter(
dim: usize,
tensor: Self::Primitive,
indices: <B as Backend>::IntTensorPrimitive,
values: Self::Primitive,
update: IndexingUpdateOp,
) -> Self::Primitive;
fn device(tensor: &Self::Primitive) -> <B as Backend>::Device;
fn to_device(
tensor: Self::Primitive,
device: &<B as Backend>::Device,
) -> Self::Primitive;
fn into_data_async(
tensor: Self::Primitive,
) -> impl Future<Output = Result<TensorData, ExecutionError>> + Send;
fn register_transaction(
tr: &mut TransactionPrimitive<B>,
tensor: Self::Primitive,
);
fn from_data(
data: TensorData,
device: &<B as Backend>::Device,
) -> Self::Primitive;
fn from_data_dtype(
data: TensorData,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive;
fn repeat_dim(
tensor: Self::Primitive,
dim: usize,
times: usize,
) -> Self::Primitive;
fn cat(vectors: Vec<Self::Primitive>, dim: usize) -> Self::Primitive;
fn equal(
lhs: Self::Primitive,
rhs: Self::Primitive,
) -> <B as Backend>::BoolTensorPrimitive;
fn equal_elem(
lhs: Self::Primitive,
rhs: Self::Elem,
) -> <B as Backend>::BoolTensorPrimitive;
fn not_equal(
lhs: Self::Primitive,
rhs: Self::Primitive,
) -> <B as Backend>::BoolTensorPrimitive;
fn not_equal_elem(
lhs: Self::Primitive,
rhs: Self::Elem,
) -> <B as Backend>::BoolTensorPrimitive;
fn any(tensor: Self::Primitive) -> <B as Backend>::BoolTensorPrimitive;
fn any_dim(
tensor: Self::Primitive,
dim: usize,
) -> <B as Backend>::BoolTensorPrimitive;
fn all(tensor: Self::Primitive) -> <B as Backend>::BoolTensorPrimitive;
fn all_dim(
tensor: Self::Primitive,
dim: usize,
) -> <B as Backend>::BoolTensorPrimitive;
fn expand(tensor: Self::Primitive, shape: Shape) -> Self::Primitive;
fn unfold(
tensor: Self::Primitive,
dim: usize,
size: usize,
step: usize,
) -> Self::Primitive;
// Provided methods
fn elem_type_name() -> &'static str { ... }
fn dtype(tensor: &Self::Primitive) -> DType { ... }
}Expand description
Trait that list all operations that can be applied on all tensors.
§Warnings
This is an internal trait, use the public API provided by the
Tensor
struct.
Required Associated Types§
Required Methods§
Sourcefn empty(
shape: Shape,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive
fn empty( shape: Shape, device: &<B as Backend>::Device, dtype: DType, ) -> Self::Primitive
Creates an empty tensor with the given shape.
§Arguments
shape- The shape of the tensor.device- The device on which the tensor will be allocated.dtype- The target data type.
§Returns
The empty tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For creating empty tensors, users should prefer the
Tensor::empty
function, which is more high-level and designed for public use.
Sourcefn zeros(
shape: Shape,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive
fn zeros( shape: Shape, device: &<B as Backend>::Device, dtype: DType, ) -> Self::Primitive
Creates a tensor filled with zeros.
§Arguments
shape- The shape of the tensor.device- The device on which the tensor will be allocated.dtype- The target data type.
§Returns
The tensor filled with zeros.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For creating a tensor filled with zeros, users should prefer the
Tensor::zeros
function, which is more high-level and designed for public use.
Sourcefn ones(
shape: Shape,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive
fn ones( shape: Shape, device: &<B as Backend>::Device, dtype: DType, ) -> Self::Primitive
Creates a tensor filled with ones.
§Arguments
shape- The shape of the tensor.device- The device on which the tensor will be allocated.dtype- The target data type.
§Returns
The tensor filled with ones.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For creating a tensor filled with ones, users should prefer the
Tensor::ones
function, which is more high-level and designed for public use.
Sourcefn full<E>(
shape: Shape,
fill_value: E,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitivewhere
E: ElementConversion,
fn full<E>(
shape: Shape,
fill_value: E,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitivewhere
E: ElementConversion,
Creates a tensor of the given shape where each element is equal to the provided value.
§Arguments
shape- The shape of the tensor.fill_value- The value with which to fill the tensor.device- The device on which the tensor will be allocated.dtype- The target data type.
§Returns
The tensor filled with the specified value.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For creating full tensors, users should prefer the
Tensor::full
function, which is more high-level and designed for public use.
Sourcefn reshape(tensor: Self::Primitive, shape: Shape) -> Self::Primitive
fn reshape(tensor: Self::Primitive, shape: Shape) -> Self::Primitive
Reshapes the tensor.
§Arguments
tensor- The tensor.shape- The new shape of the tensor.
§Returns
The reshaped tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For reshaping a tensor, users should prefer the
Tensor::reshape
function, which is more high-level and designed for public use.
Sourcefn slice(tensor: Self::Primitive, slices: &[Slice]) -> Self::Primitive
fn slice(tensor: Self::Primitive, slices: &[Slice]) -> Self::Primitive
Select tensor elements corresponding to the given slices.
§Arguments
tensor- The tensor.slices- The slices specifying ranges and steps for each dimension.
§Returns
The selected elements.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For selecting elements of a tensor, users should prefer the
Tensor::slice
function, which is more high-level and designed for public use.
Sourcefn slice_assign(
tensor: Self::Primitive,
slices: &[Slice],
value: Self::Primitive,
) -> Self::Primitive
fn slice_assign( tensor: Self::Primitive, slices: &[Slice], value: Self::Primitive, ) -> Self::Primitive
Assigns the given value to the tensor elements corresponding to the given slices.
§Arguments
tensor- The tensor.slices- The slices specifying which elements to assign, including support for steps.value- The value to assign.
§Returns
The tensor with the assigned values.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For assigning values to elements of a tensor, users should prefer the
Tensor::slice_assign
function, which is more high-level and designed for public use.
Sourcefn select(
tensor: Self::Primitive,
dim: usize,
indices: <B as Backend>::IntTensorPrimitive,
) -> Self::Primitive
fn select( tensor: Self::Primitive, dim: usize, indices: <B as Backend>::IntTensorPrimitive, ) -> Self::Primitive
Select tensor elements along the given dimension corresponding to the given indices.
§Arguments
tensor- The tensor to select from.dim- The dimension along which to select.indices- The indices of the elements to select.
§Returns
The selected tensor elements.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For selecting elements from a tensor along an axis, users should prefer the
Tensor::select
function, which is more high-level and designed for public use.
Sourcefn select_assign(
tensor: Self::Primitive,
dim: usize,
indices: <B as Backend>::IntTensorPrimitive,
values: Self::Primitive,
update: IndexingUpdateOp,
) -> Self::Primitive
fn select_assign( tensor: Self::Primitive, dim: usize, indices: <B as Backend>::IntTensorPrimitive, values: Self::Primitive, update: IndexingUpdateOp, ) -> Self::Primitive
Assign the selected elements along the given dimension corresponding to the given indices from the value tensor.
§Arguments
tensor- The tensor to assign elements to.dim- The axis along which to assign elements.indices- The indices of the elements to assign.values- The values to assign to the tensor.update- The operation used to update the existing values at the indexed positions (e.g., add).
§Returns
A tensor with the same shape as the input tensor, where each element is taken from the corresponding element of the input tensor at the corresponding index along the specified axis, except for the elements at the specified indices, which are taken from the corresponding element of the values tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For assigning elements to a tensor along an axis, users should prefer the
Tensor::select_assign
function, which is more high-level and designed for public use.
Sourcefn mask_where(
tensor: Self::Primitive,
mask: <B as Backend>::BoolTensorPrimitive,
source: Self::Primitive,
) -> Self::Primitive
fn mask_where( tensor: Self::Primitive, mask: <B as Backend>::BoolTensorPrimitive, source: Self::Primitive, ) -> Self::Primitive
Selects elements from a tensor based on a boolean mask.
§Arguments
tensor- The tensor to select elements from if the corresponding element of the mask is true.mask- The boolean mask to use for selecting elements.source- The tensor to select elements from when the corresponding element of the mask is false.
§Returns
A tensor with the same shape as the input tensors, where each element is taken from the corresponding element of the left hand side tensor if the corresponding element of the mask is true, and from the corresponding element of the right hand side tensor otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For selecting elements from a tensor based on a boolean mask, users should prefer the
Tensor::mask_where
function, which is more high-level and designed for public use.
Sourcefn mask_fill(
tensor: Self::Primitive,
mask: <B as Backend>::BoolTensorPrimitive,
value: Self::Elem,
) -> Self::Primitive
fn mask_fill( tensor: Self::Primitive, mask: <B as Backend>::BoolTensorPrimitive, value: Self::Elem, ) -> Self::Primitive
Fills elements of a tensor based on a boolean mask.
§Arguments
tensor- The tensor where will be overwritten with the value when the corresponding element of the mask is true.mask- The boolean mask to use for filling elements.value- The value to fill elements with when the corresponding element of the mask is true.
§Returns
A tensor with the same shape as the input tensors, where each element is taken from the corresponding element unmodified if the corresponding element of the mask is false, and filled with the value otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For filling elements of a tensor based on a boolean mask, users should prefer the
Tensor::mask_fill
function, which is more high-level and designed for public use.
Sourcefn gather(
dim: usize,
tensor: Self::Primitive,
indices: <B as Backend>::IntTensorPrimitive,
) -> Self::Primitive
fn gather( dim: usize, tensor: Self::Primitive, indices: <B as Backend>::IntTensorPrimitive, ) -> Self::Primitive
Gathers elements from a tensor along an axis.
§Arguments
dim- The axis along which to gather elements.tensor- The tensor to gather elements from.indices- The indices of the elements to gather.
§Returns
A tensor with the same shape as the input tensor, where each element is taken from the corresponding element of the input tensor at the corresponding index along the specified axis.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For gathering elements from a tensor along an axis, users should prefer the
Tensor::gather
function, which is more high-level and designed for public use.
Sourcefn scatter(
dim: usize,
tensor: Self::Primitive,
indices: <B as Backend>::IntTensorPrimitive,
values: Self::Primitive,
update: IndexingUpdateOp,
) -> Self::Primitive
fn scatter( dim: usize, tensor: Self::Primitive, indices: <B as Backend>::IntTensorPrimitive, values: Self::Primitive, update: IndexingUpdateOp, ) -> Self::Primitive
Scatters elements into a tensor along an axis.
§Arguments
dim- The axis along which to scatter elements.tensor- The tensor to scatter elements into.indices- The indices of the elements to scatter.values- The values to scatter into the tensor.update- The operation used to update the existing values at the indexed positions (e.g., add).
§Returns
A tensor with the same shape as the input tensor, where each element is taken from the corresponding element of the input tensor at the corresponding index along the specified axis, except for the elements at the specified indices, which are taken from the corresponding element of the values tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For scattering elements into a tensor along an axis, users should prefer the
Tensor::scatter
function, which is more high-level and designed for public use.
Sourcefn device(tensor: &Self::Primitive) -> <B as Backend>::Device
fn device(tensor: &Self::Primitive) -> <B as Backend>::Device
Returns the device on which the tensor is allocated.
§Arguments
tensor- The tensor.
§Returns
The device on which the tensor is allocated.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For getting the device of a tensor, users should prefer the
Tensor::device
function, which is more high-level and designed for public use.
Sourcefn to_device(
tensor: Self::Primitive,
device: &<B as Backend>::Device,
) -> Self::Primitive
fn to_device( tensor: Self::Primitive, device: &<B as Backend>::Device, ) -> Self::Primitive
Moves the tensor to the given device.
§Arguments
tensor- The tensor.device- The device on which the tensor will be moved.
§Returns
The tensor on the given device.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For moving a tensor to a device, users should prefer the
Tensor::to_device
function, which is more high-level and designed for public use.
Sourcefn into_data_async(
tensor: Self::Primitive,
) -> impl Future<Output = Result<TensorData, ExecutionError>> + Send
fn into_data_async( tensor: Self::Primitive, ) -> impl Future<Output = Result<TensorData, ExecutionError>> + Send
Extracts the data from the tensor asynchronously.
§Arguments
tensor- The tensor.
§Returns
The data of the tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For extracting the data of a tensor, users should prefer the
Tensor::into_data
function, which is more high-level and designed for public use.
Sourcefn register_transaction(
tr: &mut TransactionPrimitive<B>,
tensor: Self::Primitive,
)
fn register_transaction( tr: &mut TransactionPrimitive<B>, tensor: Self::Primitive, )
Read the data from the tensor using a transaction.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
Sourcefn from_data(
data: TensorData,
device: &<B as Backend>::Device,
) -> Self::Primitive
fn from_data( data: TensorData, device: &<B as Backend>::Device, ) -> Self::Primitive
Creates a tensor from the given data.
§Arguments
data- The data of the tensor.device- The device on which the tensor will be allocated.
§Returns
The tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For creating a tensor from data, users should prefer the
Tensor::from_data
function, which is more high-level and designed for public use.
Sourcefn from_data_dtype(
data: TensorData,
device: &<B as Backend>::Device,
dtype: DType,
) -> Self::Primitive
fn from_data_dtype( data: TensorData, device: &<B as Backend>::Device, dtype: DType, ) -> Self::Primitive
Creates a tensor from the given data enforcing the given data type.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For creating a tensor from data, users should prefer the
Tensor::from_data_dtype
function, which is more high-level and designed for public use.
Sourcefn repeat_dim(
tensor: Self::Primitive,
dim: usize,
times: usize,
) -> Self::Primitive
fn repeat_dim( tensor: Self::Primitive, dim: usize, times: usize, ) -> Self::Primitive
Repeat the tensor along the given dimension.
§Arguments
tensor- The tensor.dim- The dimension along which the tensor will be repeated.times- The number of times the tensor will be repeated.
§Returns
The repeated tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For repeating a tensor, users should prefer the
Tensor::repeat_dim
function, which is more high-level and designed for public use.
Sourcefn cat(vectors: Vec<Self::Primitive>, dim: usize) -> Self::Primitive
fn cat(vectors: Vec<Self::Primitive>, dim: usize) -> Self::Primitive
Concatenates the given tensors along the given dimension.
§Arguments
vectors- The tensors to concatenate.dim- The dimension along which the tensors will be concatenated.
§Returns
The concatenated tensor.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For concatenating tensors, users should prefer the
Tensor::cat
function, which is more high-level and designed for public use.
Sourcefn equal(
lhs: Self::Primitive,
rhs: Self::Primitive,
) -> <B as Backend>::BoolTensorPrimitive
fn equal( lhs: Self::Primitive, rhs: Self::Primitive, ) -> <B as Backend>::BoolTensorPrimitive
Equates the given tensors.
§Arguments
lhs- The left hand side tensor.rhs- The right hand side tensor.
§Returns
The tensor of booleans indicating whether the corresponding elements are equal.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For equating tensors, users should prefer the
Tensor::equal
function, which is more high-level and designed for public use.
Sourcefn equal_elem(
lhs: Self::Primitive,
rhs: Self::Elem,
) -> <B as Backend>::BoolTensorPrimitive
fn equal_elem( lhs: Self::Primitive, rhs: Self::Elem, ) -> <B as Backend>::BoolTensorPrimitive
Element-wise equality between two tensors.
§Arguments
lhs- The left hand side tensor.rhs- The right hand side tensor.
§Returns
A boolean tensor with the same shape as the input tensors, where each element is true if the corresponding elements of the input tensors are equal, and false otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For element-wise equality between two tensors, users should prefer the
Tensor::equal_elem
function, which is more high-level and designed for public use.
Sourcefn not_equal(
lhs: Self::Primitive,
rhs: Self::Primitive,
) -> <B as Backend>::BoolTensorPrimitive
fn not_equal( lhs: Self::Primitive, rhs: Self::Primitive, ) -> <B as Backend>::BoolTensorPrimitive
Applies element-wise non-equality comparison between the given tensors.
§Arguments
lhs- The left hand side tensor.rhs- The right hand side tensor.
§Returns
The tensor of booleans indicating whether the corresponding elements are equal.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For non-equality comparison of tensors, users should prefer the
Tensor::not_equal
function, which is more high-level and designed for public use.
Sourcefn not_equal_elem(
lhs: Self::Primitive,
rhs: Self::Elem,
) -> <B as Backend>::BoolTensorPrimitive
fn not_equal_elem( lhs: Self::Primitive, rhs: Self::Elem, ) -> <B as Backend>::BoolTensorPrimitive
Element-wise non-equality between two tensors.
§Arguments
lhs- The left hand side tensor.rhs- The right hand side tensor.
§Returns
A boolean tensor with the same shape as the input tensors, where each element is true if the corresponding elements of the input tensors are equal, and false otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.
For element-wise non-equality between two tensors, users should prefer the
Tensor::not_equal_elem
function, which is more high-level and designed for public use.
Sourcefn any(tensor: Self::Primitive) -> <B as Backend>::BoolTensorPrimitive
fn any(tensor: Self::Primitive) -> <B as Backend>::BoolTensorPrimitive
Tests if any element in the tensor evaluates to True.
§Arguments
tensor- The tensor to test.
§Returns
A boolean tensor with a single element, True if any element in the input tensor evaluates to True, False otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions
with static dispatch. It is not designed for direct usage by users, and not recommended to import
or use this function directly. Users should prefer the
Tensor::any
function, which is more high-level and designed for public use.
Sourcefn any_dim(
tensor: Self::Primitive,
dim: usize,
) -> <B as Backend>::BoolTensorPrimitive
fn any_dim( tensor: Self::Primitive, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive
Tests if any element in the tensor evaluates to True along a given dimension dim.
§Arguments
- tensor - The tensor to test.
- dim - The axis along which to test.
§Returns
A boolean tensor with the same size as input tensor, except in the dim axis where the size is 1. Returns True if any element in the input tensor along the given dimension evaluates to True, False otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions
with static dispatch. It is not designed for direct usage by users, and not recommended to import
or use this function directly. Users should prefer the
Tensor::any_dim
function, which is more high-level and designed for public use.
Sourcefn all(tensor: Self::Primitive) -> <B as Backend>::BoolTensorPrimitive
fn all(tensor: Self::Primitive) -> <B as Backend>::BoolTensorPrimitive
Tests if all elements in the tensor evaluate to True.
§Arguments
tensor- The tensor to test.
§Returns
A boolean tensor with a single element, True if all elements in the input tensor evaluates to True, False otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions
with static dispatch. It is not designed for direct usage by users, and not recommended to import
or use this function directly. Users should prefer the
Tensor::all
function, which is more high-level and designed for public use.
Sourcefn all_dim(
tensor: Self::Primitive,
dim: usize,
) -> <B as Backend>::BoolTensorPrimitive
fn all_dim( tensor: Self::Primitive, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive
Tests if all elements in the tensor evaluate to True along a given dimension dim.
§Arguments
tensor- The tensor to test.
§Returns
A boolean tensor with the same size as input tensor, except in the dim axis where the size is 1.
Returns True if all elements in the input tensor along the given dimension evaluate to True, False otherwise.
§Remarks
This is a low-level function used internally by the library to call different backend functions
with static dispatch. It is not designed for direct usage by users, and not recommended to import
or use this function directly. Users should prefer the
Tensor::all_dim
function, which is more high-level and designed for public use.
Sourcefn unfold(
tensor: Self::Primitive,
dim: usize,
size: usize,
step: usize,
) -> Self::Primitive
fn unfold( tensor: Self::Primitive, dim: usize, size: usize, step: usize, ) -> Self::Primitive
Unfold windows along a dimension.
Returns a view of the tensor with all complete windows of size size in dimension dim;
where windows are advanced by step at each index.
The number of windows is max(0, (shape[dim] - size).ceil_div(step)).
§Warning
For the ndarray and candle backends; this is not a view but a full copy.
§Arguments
tensor- The input tensor to unfold; of shape[pre=..., dim shape, post=...]dim- the dimension to unfold.size- the size of each unfolded window.step- the step between each window.
§Returns
A tensor view with shape [pre=..., windows, post=..., size].
Provided Methods§
Sourcefn elem_type_name() -> &'static str
fn elem_type_name() -> &'static str
Returns the name of the element type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.