Trait burn::tensor::ops::QTensorOps

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

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

Required Methods§

fn q_from_data( data: TensorData, device: &<B as Backend>::Device, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn quantize( tensor: <B as Backend>::FloatTensorPrimitive, scheme: &QuantizationScheme, qparams: QuantizationParametersPrimitive<B>, ) -> <B as Backend>::QuantizedTensorPrimitive

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

fn dequantize( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::FloatTensorPrimitive

Convert the tensor back to a higher precision data type.

fn q_shape(tensor: &<B as Backend>::QuantizedTensorPrimitive) -> Shape

Gets the shape of the tensor.

§Arguments
  • tensor - The tensor.
§Returns

The shape of the tensor.

fn q_device( tensor: &<B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::Device

Gets the device of the tensor.

§Arguments
  • tensor - The tensor.
§Returns

The device of the tensor.

fn q_to_device( tensor: <B as Backend>::QuantizedTensorPrimitive, device: &<B as Backend>::Device, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_reshape( tensor: <B as Backend>::QuantizedTensorPrimitive, shape: Shape, ) -> <B as Backend>::QuantizedTensorPrimitive

Reshapes a tensor.

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

The tensor with the new shape.

fn q_into_data( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> impl Future<Output = TensorData> + Send

Converts the tensor to a data structure.

§Arguments
  • tensor - The tensor.
§Returns

The data structure with the tensor’s data.

fn q_swap_dims( tensor: <B as Backend>::QuantizedTensorPrimitive, dim1: usize, dim2: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

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

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.

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

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.

fn q_select( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, indices: <B as Backend>::IntTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

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

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.

fn q_expand( tensor: <B as Backend>::QuantizedTensorPrimitive, shape: Shape, ) -> <B as Backend>::QuantizedTensorPrimitive

Broadcasts the tensor to the given shape.

Provided Methods§

fn quantize_dynamic( tensor: <B as Backend>::FloatTensorPrimitive, scheme: &QuantizationScheme, ) -> <B as Backend>::QuantizedTensorPrimitive

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

fn q_detach( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

Detaches a tensor from the computation graph.

fn q_set_require_grad( tensor: <B as Backend>::QuantizedTensorPrimitive, _require_grad: bool, ) -> <B as Backend>::QuantizedTensorPrimitive

Sets the require_grad flag of a tensor.

fn q_is_require_grad(_tensor: &<B as Backend>::QuantizedTensorPrimitive) -> bool

Returns the require_grad flag of a tensor.

fn q_repeat_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, times: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_add( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_add_scalar( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_clamp_min( tensor: <B as Backend>::QuantizedTensorPrimitive, min: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

Clamps a tensor under a minimum value.

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

The clamped tensor.

fn q_clamp_max( tensor: <B as Backend>::QuantizedTensorPrimitive, max: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

Clamps a tensor over a maximum value.

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

The clamped tensor.

fn q_clamp( tensor: <B as Backend>::QuantizedTensorPrimitive, min: <B as Backend>::FloatElem, max: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_sub( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

Subtracts two tensors.

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

The result of subtracting the two tensors.

fn q_sub_scalar( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_mul( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

Multiplies two tensors together element-wise.

fn q_mul_scalar( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_div( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_div_scalar( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_remainder_scalar( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_matmul( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_neg( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

Negates a tensor element-wise.

fn q_recip( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

Calculates the reciprocals element-wise

fn q_transpose( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

Transposes a tensor.

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

The transposed tensor.

fn q_gather( dim: usize, tensor: <B as Backend>::QuantizedTensorPrimitive, indices: <B as Backend>::IntTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_scatter( dim: usize, tensor: <B as Backend>::QuantizedTensorPrimitive, indices: <B as Backend>::IntTensorPrimitive, value: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_select_assign( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, indices: <B as Backend>::IntTensorPrimitive, value: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

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

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.

fn q_mask_where( tensor: <B as Backend>::QuantizedTensorPrimitive, mask: <B as Backend>::BoolTensorPrimitive, value: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_mask_fill( tensor: <B as Backend>::QuantizedTensorPrimitive, mask: <B as Backend>::BoolTensorPrimitive, value: <B as Backend>::FloatElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_sum( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_sum_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_prod( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_prod_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_mean( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_mean_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_exp( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_log( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_log1p( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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).

fn q_powf( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_powi( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::IntTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_powi_scalar( lhs: <B as Backend>::QuantizedTensorPrimitive, rhs: <B as Backend>::IntElem, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_powf_scalar( tensor: <B as Backend>::QuantizedTensorPrimitive, value: f32, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_sqrt( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_abs( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_cos( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_sin( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_tanh( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_erf( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_cat( tensors: Vec<<B as Backend>::QuantizedTensorPrimitive>, dim: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_argmax( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::IntTensorPrimitive

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.

fn q_argmin( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::IntTensorPrimitive

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.

fn q_max( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_max_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_max_dim_with_indices( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> (<B as Backend>::QuantizedTensorPrimitive, <B as Backend>::IntTensorPrimitive)

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.

fn q_min( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_min_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_min_dim_with_indices( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> (<B as Backend>::QuantizedTensorPrimitive, <B as Backend>::IntTensorPrimitive)

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.

fn q_narrow( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, start: usize, length: usize, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_chunk( tensor: <B as Backend>::QuantizedTensorPrimitive, chunks: usize, dim: usize, ) -> Vec<<B as Backend>::QuantizedTensorPrimitive>

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

fn q_any( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <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 tensor is True, False otherwise.

fn q_any_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive

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.

fn q_all( tensor: <B as Backend>::QuantizedTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

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.

fn q_all_dim( tensor: <B as Backend>::QuantizedTensorPrimitive, 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.
  • 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.

fn q_sort( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, descending: bool, ) -> <B as Backend>::QuantizedTensorPrimitive

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.

fn q_sort_with_indices( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, descending: bool, ) -> (<B as Backend>::QuantizedTensorPrimitive, <B as Backend>::IntTensorPrimitive)

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.

fn q_argsort( tensor: <B as Backend>::QuantizedTensorPrimitive, dim: usize, descending: bool, ) -> <B as Backend>::IntTensorPrimitive

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<B> QTensorOps<Fusion<B>> for Fusion<B>
where B: FusionBackend,

§

fn q_from_data( data: TensorData, device: &<Fusion<B> as Backend>::Device, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn quantize( tensor: <Fusion<B> as Backend>::FloatTensorPrimitive, scheme: &QuantizationScheme, qparams: QuantizationParametersPrimitive<Fusion<B>>, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn dequantize( tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, ) -> <Fusion<B> as Backend>::FloatTensorPrimitive

§

fn q_shape(tensor: &<Fusion<B> as Backend>::QuantizedTensorPrimitive) -> Shape

§

fn q_device( tensor: &<Fusion<B> as Backend>::QuantizedTensorPrimitive, ) -> <Fusion<B> as Backend>::Device

§

fn q_to_device( tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, device: &<Fusion<B> as Backend>::Device, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn q_reshape( _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _shape: Shape, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

async fn q_into_data( tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, ) -> TensorData

§

fn q_swap_dims( _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _dim1: usize, _dim2: usize, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn q_permute( _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _axes: &[usize], ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn q_flip( _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _axes: &[usize], ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn q_gather( _dim: usize, _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _indices: <Fusion<B> as Backend>::IntTensorPrimitive, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn q_select( _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _dim: usize, _indices: <Fusion<B> as Backend>::IntTensorPrimitive, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn q_slice( _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _ranges: &[Range<usize>], ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

§

fn q_expand( _tensor: <Fusion<B> as Backend>::QuantizedTensorPrimitive, _shape: Shape, ) -> <Fusion<B> as Backend>::QuantizedTensorPrimitive

Implementors§

§

impl<B, C> QTensorOps<Autodiff<B, C>> for Autodiff<B, C>

§

impl<E, I, Q> QTensorOps<NdArray<E, I, Q>> for NdArray<E, I, Q>
where E: FloatNdArrayElement, I: IntNdArrayElement, Q: QuantElement,

§

impl<E, Q> QTensorOps<LibTorch<E, Q>> for LibTorch<E, Q>
where E: TchElement, Q: QuantElement,

§

impl<F, I> QTensorOps<Candle<F, I>> for Candle<F, I>
where F: FloatCandleElement, I: IntCandleElement,

§

impl<R, F, I> QTensorOps<JitBackend<R, F, I>> for JitBackend<R, F, I>
where R: JitRuntime, F: FloatElement, I: IntElement,