Trait QTensorOps

Source
pub trait QTensorOps<B: Backend> {
Show 80 methods // Required methods fn q_from_data(data: TensorData, device: &Device<B>) -> QuantizedTensor<B>; fn quantize( tensor: FloatTensor<B>, scheme: &QuantizationScheme, qparams: QuantizationParametersPrimitive<B>, ) -> QuantizedTensor<B>; fn dequantize(tensor: QuantizedTensor<B>) -> FloatTensor<B>; fn q_device(tensor: &QuantizedTensor<B>) -> Device<B>; fn q_to_device( tensor: QuantizedTensor<B>, device: &Device<B>, ) -> QuantizedTensor<B>; fn q_reshape(tensor: QuantizedTensor<B>, shape: Shape) -> QuantizedTensor<B>; fn q_into_data( tensor: QuantizedTensor<B>, ) -> impl Future<Output = TensorData> + 'static + Send; fn q_swap_dims( tensor: QuantizedTensor<B>, dim1: usize, dim2: usize, ) -> QuantizedTensor<B>; fn q_permute( tensor: QuantizedTensor<B>, axes: &[usize], ) -> QuantizedTensor<B>; fn q_flip(tensor: QuantizedTensor<B>, axes: &[usize]) -> QuantizedTensor<B>; fn q_select( tensor: QuantizedTensor<B>, dim: usize, indices: IntTensor<B>, ) -> QuantizedTensor<B>; fn q_slice( tensor: QuantizedTensor<B>, ranges: &[Range<usize>], ) -> QuantizedTensor<B>; fn q_expand(tensor: QuantizedTensor<B>, shape: Shape) -> QuantizedTensor<B>; // Provided methods fn quantize_dynamic( tensor: FloatTensor<B>, scheme: &QuantizationScheme, ) -> QuantizedTensor<B> { ... } fn q_detach(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_set_require_grad( tensor: QuantizedTensor<B>, _require_grad: bool, ) -> QuantizedTensor<B> { ... } fn q_is_require_grad(_tensor: &QuantizedTensor<B>) -> bool { ... } fn q_repeat_dim( tensor: QuantizedTensor<B>, dim: usize, times: usize, ) -> QuantizedTensor<B> { ... } fn q_add( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_add_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_clamp_min( tensor: QuantizedTensor<B>, min: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_clamp_max( tensor: QuantizedTensor<B>, max: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_clamp( tensor: QuantizedTensor<B>, min: FloatElem<B>, max: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_sub( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_sub_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_mul( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_mul_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_div( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_div_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_remainder( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_remainder_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_matmul( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_neg(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_recip(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_transpose(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_gather( dim: usize, tensor: QuantizedTensor<B>, indices: IntTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_scatter( dim: usize, tensor: QuantizedTensor<B>, indices: IntTensor<B>, value: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_select_assign( tensor: QuantizedTensor<B>, dim: usize, indices: IntTensor<B>, value: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_slice_assign( tensor: QuantizedTensor<B>, ranges: &[Range<usize>], value: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_mask_where( tensor: QuantizedTensor<B>, mask: BoolTensor<B>, value: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_mask_fill( tensor: QuantizedTensor<B>, mask: BoolTensor<B>, value: FloatElem<B>, ) -> QuantizedTensor<B> { ... } fn q_sum(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_sum_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B> { ... } fn q_prod(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_prod_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B> { ... } fn q_mean(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_mean_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B> { ... } fn q_exp(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_log(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_log1p(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_powf( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B> { ... } fn q_powi(lhs: QuantizedTensor<B>, rhs: IntTensor<B>) -> QuantizedTensor<B> { ... } fn q_powi_scalar( lhs: QuantizedTensor<B>, rhs: IntElem<B>, ) -> QuantizedTensor<B> { ... } fn q_powf_scalar( tensor: QuantizedTensor<B>, value: f32, ) -> QuantizedTensor<B> { ... } fn q_sqrt(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_abs(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_cos(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_sin(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_tanh(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_erf(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_cat(tensors: Vec<QuantizedTensor<B>>, dim: usize) -> QuantizedTensor<B> { ... } fn q_argmax(tensor: QuantizedTensor<B>, dim: usize) -> IntTensor<B> { ... } fn q_argmin(tensor: QuantizedTensor<B>, dim: usize) -> IntTensor<B> { ... } fn q_max(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_max_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B> { ... } fn q_max_dim_with_indices( tensor: QuantizedTensor<B>, dim: usize, ) -> (QuantizedTensor<B>, IntTensor<B>) { ... } fn q_min(tensor: QuantizedTensor<B>) -> QuantizedTensor<B> { ... } fn q_min_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B> { ... } fn q_min_dim_with_indices( tensor: QuantizedTensor<B>, dim: usize, ) -> (QuantizedTensor<B>, IntTensor<B>) { ... } fn q_narrow( tensor: QuantizedTensor<B>, dim: usize, start: usize, length: usize, ) -> QuantizedTensor<B> { ... } fn q_chunk( tensor: QuantizedTensor<B>, chunks: usize, dim: usize, ) -> Vec<QuantizedTensor<B>> { ... } fn q_split( tensor: QuantizedTensor<B>, split_size: usize, dim: usize, ) -> Vec<QuantizedTensor<B>> { ... } fn q_split_with_sizes( tensor: QuantizedTensor<B>, split_sizes: Vec<usize>, dim: usize, ) -> Vec<QuantizedTensor<B>> { ... } fn q_any(tensor: QuantizedTensor<B>) -> BoolTensor<B> { ... } fn q_any_dim(tensor: QuantizedTensor<B>, dim: usize) -> BoolTensor<B> { ... } fn q_all(tensor: QuantizedTensor<B>) -> BoolTensor<B> { ... } fn q_all_dim(tensor: QuantizedTensor<B>, dim: usize) -> BoolTensor<B> { ... } fn q_sort( tensor: QuantizedTensor<B>, dim: usize, descending: bool, ) -> QuantizedTensor<B> { ... } fn q_sort_with_indices( tensor: QuantizedTensor<B>, dim: usize, descending: bool, ) -> (QuantizedTensor<B>, IntTensor<B>) { ... } fn q_argsort( tensor: QuantizedTensor<B>, dim: usize, descending: bool, ) -> IntTensor<B> { ... }
}
Expand description

Quantized Tensor API for basic operations, see tensor for documentation on each function.

Required Methods§

Source

fn q_from_data(data: TensorData, device: &Device<B>) -> QuantizedTensor<B>

Creates a new tensor from the data structure.

§Arguments
  • data - The data structure.
  • device - The device to create the tensor on.
§Returns

The tensor with the given data.

Source

fn quantize( tensor: FloatTensor<B>, scheme: &QuantizationScheme, qparams: QuantizationParametersPrimitive<B>, ) -> QuantizedTensor<B>

Convert the tensor to a lower precision data type based on the quantization scheme and parameters.

Source

fn dequantize(tensor: QuantizedTensor<B>) -> FloatTensor<B>

Convert the tensor back to a higher precision data type.

Source

fn q_device(tensor: &QuantizedTensor<B>) -> Device<B>

Gets the device of the tensor.

§Arguments
  • tensor - The tensor.
§Returns

The device of the tensor.

Source

fn q_to_device( tensor: QuantizedTensor<B>, device: &Device<B>, ) -> QuantizedTensor<B>

Moves the tensor to the given device.

§Arguments
  • tensor - The tensor.
  • device - The device to move the tensor to.
§Returns

The tensor on the given device.

Source

fn q_reshape(tensor: QuantizedTensor<B>, shape: Shape) -> QuantizedTensor<B>

Reshapes a tensor.

§Arguments
  • tensor - The tensor to reshape.
  • shape - The new shape of the tensor.
§Returns

The tensor with the new shape.

Source

fn q_into_data( tensor: QuantizedTensor<B>, ) -> impl Future<Output = TensorData> + 'static + Send

Converts the tensor to a data structure.

§Arguments
  • tensor - The tensor.
§Returns

The data structure with the tensor’s data.

Source

fn q_swap_dims( tensor: QuantizedTensor<B>, dim1: usize, dim2: usize, ) -> QuantizedTensor<B>

Swaps two dimensions of a tensor.

§Arguments
  • tensor - The tensor to swap the dimensions of.
  • dim1 - The first dimension to swap.
  • dim2 - The second dimension to swap.
§Returns

The tensor with the dimensions swapped.

Source

fn q_permute(tensor: QuantizedTensor<B>, axes: &[usize]) -> QuantizedTensor<B>

Permutes the dimensions of a tensor.

§Arguments
  • tensor - The tensor to permute the dimensions of.
  • axes - The new order of the dimensions.
§Returns

The tensor with the dimensions permuted.

Source

fn q_flip(tensor: QuantizedTensor<B>, axes: &[usize]) -> QuantizedTensor<B>

Reverse the order of elements in a tensor along the given axes.

§Arguments
  • tensor - The tensor to reverse.
  • axes - The axes to reverse.

The tensor with the elements reversed.

Source

fn q_select( tensor: QuantizedTensor<B>, dim: usize, indices: IntTensor<B>, ) -> QuantizedTensor<B>

Select tensor elements along the given dimension corresponding for the given indices.

§Arguments
  • tensor - The tensor to select from.
  • dim - The dimension to select from.
  • indices - The indices to select.
§Returns

The selected elements.

Source

fn q_slice( tensor: QuantizedTensor<B>, ranges: &[Range<usize>], ) -> QuantizedTensor<B>

Select tensor elements corresponding for the given ranges.

§Arguments
  • tensor - The tensor to select from.
  • ranges - The ranges to select.
§Returns

The selected elements in a new tensor.

Source

fn q_expand(tensor: QuantizedTensor<B>, shape: Shape) -> QuantizedTensor<B>

Broadcasts the tensor to the given shape.

Provided Methods§

Source

fn quantize_dynamic( tensor: FloatTensor<B>, scheme: &QuantizationScheme, ) -> QuantizedTensor<B>

Dynamically convert the tensor to a lower precision data type based on the quantization scheme.

Source

fn q_detach(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Detaches a tensor from the computation graph.

Source

fn q_set_require_grad( tensor: QuantizedTensor<B>, _require_grad: bool, ) -> QuantizedTensor<B>

Sets the require_grad flag of a tensor.

Source

fn q_is_require_grad(_tensor: &QuantizedTensor<B>) -> bool

Returns the require_grad flag of a tensor.

Source

fn q_repeat_dim( tensor: QuantizedTensor<B>, dim: usize, times: usize, ) -> QuantizedTensor<B>

Repeat the tensor along the given dimension.

§Arguments
  • tensor - The tensor.
  • dim - The dimension to repeat.
  • times - The number of times to repeat the dimension.
§Returns

The tensor with the given dimension repeated.

Source

fn q_add(lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>) -> QuantizedTensor<B>

Adds two tensors together.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side tensor.
§Returns

The result of adding the two tensors together.

Source

fn q_add_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B>

Adds a scalar to a tensor.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side scalar.
§Returns

The result of adding the scalar to the tensor.

Source

fn q_clamp_min( tensor: QuantizedTensor<B>, min: FloatElem<B>, ) -> QuantizedTensor<B>

Clamps a tensor under a minimum value.

§Arguments
  • tensor - The tensor to clamp.
  • min - The minimum value.
§Returns

The clamped tensor.

Source

fn q_clamp_max( tensor: QuantizedTensor<B>, max: FloatElem<B>, ) -> QuantizedTensor<B>

Clamps a tensor over a maximum value.

§Arguments
  • tensor - The tensor to clamp.
  • max - The maximum value.
§Returns

The clamped tensor.

Source

fn q_clamp( tensor: QuantizedTensor<B>, min: FloatElem<B>, max: FloatElem<B>, ) -> QuantizedTensor<B>

Clamps a tensor between a minimum and maximum value.

§Arguments
  • tensor - The tensor to clamp.
  • min - The minimum value.
  • max - The maximum value.
§Returns

The clamped tensor.

Source

fn q_sub(lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>) -> QuantizedTensor<B>

Subtracts two tensors.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side tensor.
§Returns

The result of subtracting the two tensors.

Source

fn q_sub_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B>

Subtracts a scalar from a tensor.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side scalar.
§Returns

The result of subtracting the scalar from the tensor.

Source

fn q_mul(lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>) -> QuantizedTensor<B>

Multiplies two tensors together element-wise.

Source

fn q_mul_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B>

Multiplies a tensor by a scalar.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side scalar.
§Returns

The result of multiplying the tensor by the scalar.

Source

fn q_div(lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>) -> QuantizedTensor<B>

Divides two tensors element-wise.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side tensor.
§Returns

The result of dividing the two tensors.

Source

fn q_div_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B>

Divides a tensor by a scalar.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side scalar.
§Returns

The result of dividing the tensor by the scalar.

Source

fn q_remainder( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B>

Computes the remainder of division between two tensors element-wise.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side tensor.
§Returns

The element-wise remainder when dividing lhs by rhs.

Source

fn q_remainder_scalar( lhs: QuantizedTensor<B>, rhs: FloatElem<B>, ) -> QuantizedTensor<B>

Computes the modulus of a tensor given a scalar.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side scalar.
§Returns

The result of applying the modulus of the scalar to the tensor.

Source

fn q_matmul( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B>

Multiplies two tensors together using matrix multiplication.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side tensor.
§Returns

The result of multiplying the two tensors together using matrix multiplication.

Source

fn q_neg(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Negates a tensor element-wise.

Source

fn q_recip(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Calculates the reciprocals element-wise

Source

fn q_transpose(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Transposes a tensor.

§Arguments
  • tensor - The tensor to transpose.
§Returns

The transposed tensor.

Source

fn q_gather( dim: usize, tensor: QuantizedTensor<B>, indices: IntTensor<B>, ) -> QuantizedTensor<B>

Gather elements from a tensor.

§Arguments
  • dim - The dimension to gather from.
  • tensor - The tensor to gather from.
  • indices - The indices to gather.
§Returns

The gathered elements.

Source

fn q_scatter( dim: usize, tensor: QuantizedTensor<B>, indices: IntTensor<B>, value: QuantizedTensor<B>, ) -> QuantizedTensor<B>

Scatter elements into a tensor.

§Arguments
  • dim - The dimension to scatter into.
  • tensor - The tensor to scatter into.
  • indices - The indices to scatter into.
  • value - The value to scatter.
§Returns

The tensor with the scattered elements.

Source

fn q_select_assign( tensor: QuantizedTensor<B>, dim: usize, indices: IntTensor<B>, value: QuantizedTensor<B>, ) -> QuantizedTensor<B>

Assign the selected elements along the given dimension corresponding for the given indices to the given value.

§Arguments
  • tensor - The tensor to select from.
  • dim - The dimension to select from.
  • indices - The indices to select.
  • value - The value to assign.
§Returns

The tensor with the selected elements assigned to the given value.

Source

fn q_slice_assign( tensor: QuantizedTensor<B>, ranges: &[Range<usize>], value: QuantizedTensor<B>, ) -> QuantizedTensor<B>

Assign the selected elements corresponding for the given ranges to the given value.

§Arguments
  • tensor - The tensor to select from.
  • ranges - The ranges to select.
  • value - The value to assign.
§Returns

The tensor with the selected elements assigned to the given value.

Source

fn q_mask_where( tensor: QuantizedTensor<B>, mask: BoolTensor<B>, value: QuantizedTensor<B>, ) -> QuantizedTensor<B>

Update the given tensor with the value tensor where the mask is true.

§Arguments
  • tensor - The tensor to select from.
  • mask - The boolean mask to select with.
  • value - The value to assign to the selected elements from the value tensor.
§Returns

The tensor with the selected elements assigned to the given value.

Source

fn q_mask_fill( tensor: QuantizedTensor<B>, mask: BoolTensor<B>, value: FloatElem<B>, ) -> QuantizedTensor<B>

Update the given tensor with the value where the mask is true.

§Arguments
  • tensor - The tensor to select from.
  • mask - The boolean mask to select with.
  • value - The value to assign to the selected elements.
§Returns

The tensor with the selected elements assigned to the given value.

Source

fn q_sum(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Sum of all elements in a tensor.

§Arguments
  • tensor - The tensor to sum.
§Returns

A scalar tensor with the sum of all elements in tensor.

Source

fn q_sum_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B>

Sum of all elements in a tensor along a dimension.

§Arguments
  • tensor - The tensor to sum.
  • dim - The dimension along which to sum.
§Returns

A tensor with the sum of all elements in tensor along dim.

Source

fn q_prod(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Product of all elements in a tensor.

§Arguments
  • tensor - The tensor to product.
§Returns

A scalar tensor with the product of all elements in tensor.

Source

fn q_prod_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B>

Product of all elements in a tensor along a dimension.

§Arguments
  • tensor - The tensor to product.
§Returns

A tensor with the product of all elements in tensor along dim.

Source

fn q_mean(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Mean of all elements in a tensor.

§Arguments
  • tensor - The tensor to mean.
§Returns

A scalar tensor with the mean of all elements in tensor.

Source

fn q_mean_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B>

Mean of all elements in a tensor along a dimension.

§Arguments
  • tensor - The tensor to mean.
  • dim - The dimension along which to mean.
§Returns

A tensor with the mean of all elements in tensor along dim.

Source

fn q_exp(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with exponential values.

§Arguments
  • tensor - The tensor to exponentiate.
§Returns

A tensor with the same shape as tensor with exponential values.

Source

fn q_log(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with natural logarithm values.

§Arguments
  • tensor - The tensor to take the logarithm of.
§Returns

A tensor with the same shape as tensor with natural logarithm values.

Source

fn q_log1p(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with logarithm values of (1 + Xi).

§Arguments
  • tensor - The tensor to take the logarithm of.
§Returns

A tensor with the same shape as tensor with logarithm values of (1 + Xi).

Source

fn q_powf( lhs: QuantizedTensor<B>, rhs: QuantizedTensor<B>, ) -> QuantizedTensor<B>

Element-wise power with another tensor.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side tensor.
§Returns

The elements of lhs raised to the power of the elements of rhs.

Source

fn q_powi(lhs: QuantizedTensor<B>, rhs: IntTensor<B>) -> QuantizedTensor<B>

Element-wise power with an IntTensor.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side floatTensor.
§Returns

The elements of lhs raised to the value of rhs. Result is an IntTensor.

Source

fn q_powi_scalar(lhs: QuantizedTensor<B>, rhs: IntElem<B>) -> QuantizedTensor<B>

Element-wise power with an int scalar.

§Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side scalar.
§Returns

The elements of lhs raised to the value of rhs.

Source

fn q_powf_scalar(tensor: QuantizedTensor<B>, value: f32) -> QuantizedTensor<B>

Element-wise power with a float scalar.

§Arguments
  • tensor - The tensor to exponentiate.
  • value - The exponent.
§Returns

A tensor with the same shape as tensor with values raised to the power of value.

Source

fn q_sqrt(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with square root values.

§Arguments
  • tensor - The tensor to take the square root of.
§Returns

A tensor with the same shape as tensor with square root values.

Source

fn q_abs(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with absolute values.

§Arguments
  • tensor - The tensor to take absolute value of.
§Returns

A tensor with the same shape as tensor with absolute values.

Source

fn q_cos(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with cosine values.

§Arguments
  • tensor - The tensor to take the cosine of.
§Returns

A tensor with the same shape as tensor with cosine values.

Source

fn q_sin(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with sine values.

§Arguments
  • tensor - The tensor to take the sine of.
§Returns

A tensor with the same shape as tensor with sine values.

Source

fn q_tanh(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with tangent values.

§Arguments
  • tensor - The tensor to take the tangent of.
§Returns

A tensor with the same shape as tensor with tangent values.

Source

fn q_erf(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Returns a new tensor with the error function values.

§Arguments
  • tensor - The tensor to take the error function of.
§Returns

A tensor with the same shape as tensor with error function values.

Source

fn q_cat(tensors: Vec<QuantizedTensor<B>>, dim: usize) -> QuantizedTensor<B>

Concatenates tensors along a dimension.

§Arguments
  • tensors - The tensors to concatenate.
  • dim - The dimension along which to concatenate.
§Returns

A tensor with the concatenated tensors along dim.

Source

fn q_argmax(tensor: QuantizedTensor<B>, dim: usize) -> IntTensor<B>

Gets the indices of the maximum elements of a tensor along an axis.

§Arguments
  • tensor - The tensor to get the maximum elements of.
  • dim - The dimension along which to get the maximum elements.
§Returns

A tensor with the indices of the maximum elements of tensor along dim.

Source

fn q_argmin(tensor: QuantizedTensor<B>, dim: usize) -> IntTensor<B>

Gets the indices of the minimum elements of a tensor along an axis.

§Arguments
  • tensor - The tensor to get the minimum elements of.
  • dim - The dimension along which to get the minimum elements.
§Returns

A tensor with the indices of the minimum elements of tensor along dim.

Source

fn q_max(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Gets the maximum element of a tensor.

§Arguments
  • tensor - The tensor to get the maximum elements of.
§Returns

A tensor with the maximum element of tensor.

Source

fn q_max_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B>

Gets the maximum elements of a tensor along an axis.

§Arguments
  • tensor - The tensor to get the maximum elements of.
  • dim - The dimension along which to get the maximum elements.
§Returns

A tensor with the maximum elements of tensor along dim.

Source

fn q_max_dim_with_indices( tensor: QuantizedTensor<B>, dim: usize, ) -> (QuantizedTensor<B>, IntTensor<B>)

Gets the maximum elements of a tensor along an axis and their indices.

§Arguments
  • tensor - The tensor to get the maximum elements of.
  • dim - The dimension along which to get the maximum elements.
§Returns

A tuple with the maximum elements of tensor along dim and their indices.

Source

fn q_min(tensor: QuantizedTensor<B>) -> QuantizedTensor<B>

Gets the minimum element of a tensor.

§Arguments
  • tensor - The tensor to get the minimum elements of.
§Returns

A tensor with the minimum element of tensor.

Source

fn q_min_dim(tensor: QuantizedTensor<B>, dim: usize) -> QuantizedTensor<B>

Gets the minimum elements of a tensor along an axis.

§Arguments
  • tensor - The tensor to get the minimum elements of.
  • dim - The dimension along which to get the minimum elements.
§Returns

A tensor with the minimum elements of tensor along dim.

Source

fn q_min_dim_with_indices( tensor: QuantizedTensor<B>, dim: usize, ) -> (QuantizedTensor<B>, IntTensor<B>)

Gets the minimum elements of a tensor along an axis and their indices.

§Arguments
  • tensor - The tensor to get the minimum elements of.
  • dim - The dimension along which to get the minimum elements.
§Returns

A tuple with the minimum elements of tensor along dim and their indices.

Source

fn q_narrow( tensor: QuantizedTensor<B>, dim: usize, start: usize, length: usize, ) -> QuantizedTensor<B>

Returns a new tensor with the given dimension narrowed to the given range.

§Arguments
  • dim - The dimension along which the tensor will be narrowed.
  • start - The starting point of the given range.
  • length - The ending point of the given range.
§Panics
  • If the dimension is greater than the number of dimensions of the tensor.
  • If the given range exceeds the number of elements on the given dimension.
§Returns

A new tensor with the given dimension narrowed to the given range.

Source

fn q_chunk( tensor: QuantizedTensor<B>, chunks: usize, dim: usize, ) -> Vec<QuantizedTensor<B>>

Split the tensor along the given dimension into chunks.

§Arguments
  • tensor - The tensor.
  • chunks - The number of chunks to be produced.
  • times - The dimension along which the tensor will be split.
§Returns

A vector of tensors.

Source

fn q_split( tensor: QuantizedTensor<B>, split_size: usize, dim: usize, ) -> Vec<QuantizedTensor<B>>

Split the tensor along the given dimension into chunks of split_size.

§Arguments
  • tensor - The tensor.
  • split_size - The size of a single chunk.
  • times - The dimension along which the tensor will be split.
§Returns

A vector of tensors.

Source

fn q_split_with_sizes( tensor: QuantizedTensor<B>, split_sizes: Vec<usize>, dim: usize, ) -> Vec<QuantizedTensor<B>>

Split the tensor along the given dimension into chunks with sizes in dim according to split_sizes.

§Arguments
  • tensor - The tensor.
  • split_sizes - Vector of sizes for each chunk.
  • times - The dimension along which the tensor will be split.
§Returns

A vector of tensors.

Source

fn q_any(tensor: QuantizedTensor<B>) -> BoolTensor<B>

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 tensor is True, False otherwise.

Source

fn q_any_dim(tensor: QuantizedTensor<B>, dim: usize) -> BoolTensor<B>

Tests if any element in the float 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 Tensor<B, D, Bool> with the same size as input tensor, except in the dim axis where the size is 1. The elem in the dim axis is True if any element along this dim in the input evaluates to True, False otherwise.

Source

fn q_all(tensor: QuantizedTensor<B>) -> BoolTensor<B>

Tests if all elements in the tensor evaluate to True.

§Arguments
  • tensor - The tensor to test.
§Returns

A boolean tensor Tensor<B, 1, Bool> with a single element, True if all elements in the input tensor evaluate to True, False otherwise.

Source

fn q_all_dim(tensor: QuantizedTensor<B>, dim: usize) -> BoolTensor<B>

Tests if all elements in the tensor evaluate to True along a given dimension dim.

§Arguments
  • tensor - The tensor to test.
  • dim - The axis along which to test.
§Returns

A boolean tensor Tensor<B, D, Bool> with the same size as input tensor, except in the dim axis where the size is 1. The elem in the dim axis is True if all elements along this dim in the input evaluates to True, False otherwise.

Source

fn q_sort( tensor: QuantizedTensor<B>, dim: usize, descending: bool, ) -> QuantizedTensor<B>

Sort the elements of the input tensor by value in along a given dimension.

This sort is unstable (i.e., may reorder equal elements).

§Arguments
  • tensor - The input tensor.
  • dim - The axis along which to sort.
  • descending - The sorting order.
§Returns

A tensor with the same shape as the input tensor, where the elements are sorted by value.

Source

fn q_sort_with_indices( tensor: QuantizedTensor<B>, dim: usize, descending: bool, ) -> (QuantizedTensor<B>, IntTensor<B>)

Sort the elements of the input tensor by value in along a given dimension.

This sort is unstable (i.e., may reorder equal elements).

§Arguments
  • tensor - The input tensor.
  • dim - The axis along which to sort.
  • descending - The sorting order.
§Returns

A tensor with the same shape as the input tensor and corresponding indices, where the elements are sorted by value and the indices map back to the original input tensor.

Source

fn q_argsort( tensor: QuantizedTensor<B>, dim: usize, descending: bool, ) -> IntTensor<B>

Returns the indices that sort the elements of the input tensor by value along a given dimension.

This sort is unstable (i.e., may reorder equal elements).

§Arguments
  • tensor - The input tensor.
  • dim - The axis along which to sort.
  • descending - The sorting order.
§Returns

A tensor with the same shape as the input tensor the indices map back to the original input tensor.

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.

Implementors§