pub trait FloatOps<D: Device> {
Show 41 methods
// Required methods
fn f_zeros(
shape: &Shape,
device: &D,
dtype: FloatDType,
) -> Result<D::FloatStorage>;
fn f_ones(
shape: &Shape,
device: &D,
dtype: FloatDType,
) -> Result<D::FloatStorage>;
fn f_full(
shape: &Shape,
value: f64,
device: &D,
dtype: FloatDType,
) -> Result<D::FloatStorage>;
fn f_from_f64<'a>(
data: impl Into<Cow<'a, [f64]>>,
device: &D,
) -> Result<D::FloatStorage>;
fn f_from_f32<'a>(
data: impl Into<Cow<'a, [f32]>>,
device: &D,
) -> Result<D::FloatStorage>;
fn f_from_bytes<'a>(
bytes: impl Into<Cow<'a, [u8]>>,
shape: &Shape,
device: &D,
dtype: FloatDType,
) -> Result<D::FloatStorage>;
fn f_rand_uniform(
shape: &Shape,
lo: f64,
hi: f64,
device: &D,
dtype: FloatDType,
) -> Result<D::FloatStorage>;
fn f_rand_normal(
shape: &Shape,
mean: f64,
std: f64,
device: &D,
dtype: FloatDType,
) -> Result<D::FloatStorage>;
fn f_contiguous(
x: &D::FloatStorage,
layout: &Layout,
) -> Result<D::FloatStorage>;
fn f_cast_float(
x: &D::FloatStorage,
layout: &Layout,
to: FloatDType,
) -> Result<D::FloatStorage>;
fn f_cast_int(
x: &D::FloatStorage,
layout: &Layout,
to: IntDType,
) -> Result<D::IntStorage>;
fn f_cast_bool(
x: &D::FloatStorage,
layout: &Layout,
to: BoolDType,
) -> Result<D::BoolStorage>;
fn f_to_vec(x: &D::FloatStorage, layout: &Layout) -> Result<Vec<f64>>;
fn f_to_bytes<'a>(
x: &'a D::FloatStorage,
layout: &Layout,
) -> Result<Cow<'a, [u8]>>;
fn f_binary(
lhs: &D::FloatStorage,
lhs_l: &Layout,
rhs: &D::FloatStorage,
rhs_l: &Layout,
op: BinaryOp,
) -> Result<D::FloatStorage>;
fn f_binary_(
dst: &mut D::FloatStorage,
dst_l: &Layout,
src: &D::FloatStorage,
src_l: &Layout,
op: BinaryOp,
) -> Result<()>;
fn f_binary_scalar(
lhs: &D::FloatStorage,
lhs_l: &Layout,
rhs: f64,
op: BinaryOp,
) -> Result<D::FloatStorage>;
fn f_binary_scalar_(
dst: &mut D::FloatStorage,
dst_l: &Layout,
rhs: f64,
op: BinaryOp,
) -> Result<()>;
fn f_binary_scalar_lhs(
scalar: f64,
rhs: &D::FloatStorage,
rhs_l: &Layout,
op: BinaryOp,
) -> Result<D::FloatStorage>;
fn f_cmp(
lhs: &D::FloatStorage,
lhs_l: &Layout,
rhs: &D::FloatStorage,
rhs_l: &Layout,
op: CmpOp,
) -> Result<D::BoolStorage>;
fn f_cmp_scalar(
lhs: &D::FloatStorage,
lhs_l: &Layout,
rhs: f64,
op: CmpOp,
) -> Result<D::BoolStorage>;
fn f_unary(
x: &D::FloatStorage,
layout: &Layout,
op: UnaryOp<f64>,
) -> Result<D::FloatStorage>;
fn f_unary_(
dst: &mut D::FloatStorage,
dst_l: &Layout,
op: UnaryOp<f64>,
) -> Result<()>;
fn f_float_unary(
x: &D::FloatStorage,
layout: &Layout,
op: FloatUnaryOp,
) -> Result<D::FloatStorage>;
fn f_float_unary_(
dst: &mut D::FloatStorage,
dst_l: &Layout,
op: FloatUnaryOp,
) -> Result<()>;
fn f_reduce(
x: &D::FloatStorage,
layout: &Layout,
dims: &[usize],
keepdim: bool,
op: ReduceOp,
) -> Result<(D::FloatStorage, Shape)>;
fn f_arg_reduce(
x: &D::FloatStorage,
layout: &Layout,
dim: usize,
keepdim: bool,
take_max: bool,
) -> Result<(D::IntStorage, Shape)>;
fn f_matmul(
lhs: &D::FloatStorage,
lhs_l: &Layout,
rhs: &D::FloatStorage,
rhs_l: &Layout,
) -> Result<(D::FloatStorage, Shape)>;
fn f_add_matmul_(
dst: &mut D::FloatStorage,
dst_l: &Layout,
lhs: &D::FloatStorage,
lhs_l: &Layout,
rhs: &D::FloatStorage,
rhs_l: &Layout,
) -> Result<()>;
fn f_index_select(
x: &D::FloatStorage,
x_l: &Layout,
idx: &D::IntStorage,
idx_l: &Layout,
dim: usize,
) -> Result<(D::FloatStorage, Shape)>;
fn f_gather(
x: &D::FloatStorage,
x_l: &Layout,
idx: &D::IntStorage,
idx_l: &Layout,
dim: usize,
) -> Result<(D::FloatStorage, Shape)>;
fn f_index_add(
init: &D::FloatStorage,
init_l: &Layout,
idx: &D::IntStorage,
idx_l: &Layout,
src: &D::FloatStorage,
src_l: &Layout,
dim: usize,
) -> Result<D::FloatStorage>;
fn f_scatter_add(
init: &D::FloatStorage,
init_l: &Layout,
idx: &D::IntStorage,
idx_l: &Layout,
src: &D::FloatStorage,
src_l: &Layout,
dim: usize,
) -> Result<D::FloatStorage>;
fn f_cat(
srcs: &[(&D::FloatStorage, &Layout)],
dim: usize,
) -> Result<(D::FloatStorage, Shape)>;
fn f_softmax(
x: &D::FloatStorage,
layout: &Layout,
dim: usize,
) -> Result<D::FloatStorage>;
fn f_rms_norm(
x: &D::FloatStorage,
x_l: &Layout,
weight: &D::FloatStorage,
weight_l: &Layout,
eps: f64,
) -> Result<D::FloatStorage>;
fn f_pick(
mask: &D::BoolStorage,
mask_l: &Layout,
on_true: &D::FloatStorage,
true_l: &Layout,
on_false: &D::FloatStorage,
false_l: &Layout,
) -> Result<D::FloatStorage>;
fn f_pick_true(
mask: &D::BoolStorage,
mask_l: &Layout,
value: f64,
on_false: &D::FloatStorage,
false_l: &Layout,
) -> Result<D::FloatStorage>;
fn f_pick_false(
mask: &D::BoolStorage,
mask_l: &Layout,
on_true: &D::FloatStorage,
true_l: &Layout,
value: f64,
) -> Result<D::FloatStorage>;
fn f_allclose(
a: &D::FloatStorage,
a_l: &Layout,
b: &D::FloatStorage,
b_l: &Layout,
rtol: f64,
atol: f64,
) -> Result<bool>;
// Provided method
fn f_view(
_src: &D::FloatStorage,
_src_l: &Layout,
_dst_l: &Layout,
_view: ViewOp,
) -> Result<Option<D::FloatStorage>> { ... }
}Expand description
Operations for floating-point tensors.
Required Methods§
fn f_zeros( shape: &Shape, device: &D, dtype: FloatDType, ) -> Result<D::FloatStorage>
fn f_ones( shape: &Shape, device: &D, dtype: FloatDType, ) -> Result<D::FloatStorage>
fn f_full( shape: &Shape, value: f64, device: &D, dtype: FloatDType, ) -> Result<D::FloatStorage>
fn f_from_f64<'a>( data: impl Into<Cow<'a, [f64]>>, device: &D, ) -> Result<D::FloatStorage>
fn f_from_f32<'a>( data: impl Into<Cow<'a, [f32]>>, device: &D, ) -> Result<D::FloatStorage>
fn f_from_bytes<'a>( bytes: impl Into<Cow<'a, [u8]>>, shape: &Shape, device: &D, dtype: FloatDType, ) -> Result<D::FloatStorage>
fn f_rand_uniform( shape: &Shape, lo: f64, hi: f64, device: &D, dtype: FloatDType, ) -> Result<D::FloatStorage>
fn f_rand_normal( shape: &Shape, mean: f64, std: f64, device: &D, dtype: FloatDType, ) -> Result<D::FloatStorage>
fn f_contiguous(x: &D::FloatStorage, layout: &Layout) -> Result<D::FloatStorage>
fn f_cast_float( x: &D::FloatStorage, layout: &Layout, to: FloatDType, ) -> Result<D::FloatStorage>
fn f_cast_int( x: &D::FloatStorage, layout: &Layout, to: IntDType, ) -> Result<D::IntStorage>
fn f_cast_bool( x: &D::FloatStorage, layout: &Layout, to: BoolDType, ) -> Result<D::BoolStorage>
Sourcefn f_to_vec(x: &D::FloatStorage, layout: &Layout) -> Result<Vec<f64>>
fn f_to_vec(x: &D::FloatStorage, layout: &Layout) -> Result<Vec<f64>>
Read all elements into a Vec<f64> in logical (layout) order.
Sourcefn f_to_bytes<'a>(
x: &'a D::FloatStorage,
layout: &Layout,
) -> Result<Cow<'a, [u8]>>
fn f_to_bytes<'a>( x: &'a D::FloatStorage, layout: &Layout, ) -> Result<Cow<'a, [u8]>>
Read raw little-endian bytes in logical (layout) order.
Returns Cow::Borrowed when the underlying storage is already contiguous
(zero-copy); Cow::Owned otherwise.
fn f_binary( lhs: &D::FloatStorage, lhs_l: &Layout, rhs: &D::FloatStorage, rhs_l: &Layout, op: BinaryOp, ) -> Result<D::FloatStorage>
fn f_binary_( dst: &mut D::FloatStorage, dst_l: &Layout, src: &D::FloatStorage, src_l: &Layout, op: BinaryOp, ) -> Result<()>
fn f_binary_scalar( lhs: &D::FloatStorage, lhs_l: &Layout, rhs: f64, op: BinaryOp, ) -> Result<D::FloatStorage>
fn f_binary_scalar_( dst: &mut D::FloatStorage, dst_l: &Layout, rhs: f64, op: BinaryOp, ) -> Result<()>
fn f_binary_scalar_lhs( scalar: f64, rhs: &D::FloatStorage, rhs_l: &Layout, op: BinaryOp, ) -> Result<D::FloatStorage>
fn f_cmp( lhs: &D::FloatStorage, lhs_l: &Layout, rhs: &D::FloatStorage, rhs_l: &Layout, op: CmpOp, ) -> Result<D::BoolStorage>
fn f_cmp_scalar( lhs: &D::FloatStorage, lhs_l: &Layout, rhs: f64, op: CmpOp, ) -> Result<D::BoolStorage>
fn f_unary( x: &D::FloatStorage, layout: &Layout, op: UnaryOp<f64>, ) -> Result<D::FloatStorage>
fn f_unary_( dst: &mut D::FloatStorage, dst_l: &Layout, op: UnaryOp<f64>, ) -> Result<()>
fn f_float_unary( x: &D::FloatStorage, layout: &Layout, op: FloatUnaryOp, ) -> Result<D::FloatStorage>
fn f_float_unary_( dst: &mut D::FloatStorage, dst_l: &Layout, op: FloatUnaryOp, ) -> Result<()>
fn f_reduce( x: &D::FloatStorage, layout: &Layout, dims: &[usize], keepdim: bool, op: ReduceOp, ) -> Result<(D::FloatStorage, Shape)>
fn f_arg_reduce( x: &D::FloatStorage, layout: &Layout, dim: usize, keepdim: bool, take_max: bool, ) -> Result<(D::IntStorage, Shape)>
fn f_matmul( lhs: &D::FloatStorage, lhs_l: &Layout, rhs: &D::FloatStorage, rhs_l: &Layout, ) -> Result<(D::FloatStorage, Shape)>
fn f_add_matmul_( dst: &mut D::FloatStorage, dst_l: &Layout, lhs: &D::FloatStorage, lhs_l: &Layout, rhs: &D::FloatStorage, rhs_l: &Layout, ) -> Result<()>
fn f_index_select( x: &D::FloatStorage, x_l: &Layout, idx: &D::IntStorage, idx_l: &Layout, dim: usize, ) -> Result<(D::FloatStorage, Shape)>
fn f_gather( x: &D::FloatStorage, x_l: &Layout, idx: &D::IntStorage, idx_l: &Layout, dim: usize, ) -> Result<(D::FloatStorage, Shape)>
fn f_index_add( init: &D::FloatStorage, init_l: &Layout, idx: &D::IntStorage, idx_l: &Layout, src: &D::FloatStorage, src_l: &Layout, dim: usize, ) -> Result<D::FloatStorage>
fn f_scatter_add( init: &D::FloatStorage, init_l: &Layout, idx: &D::IntStorage, idx_l: &Layout, src: &D::FloatStorage, src_l: &Layout, dim: usize, ) -> Result<D::FloatStorage>
fn f_cat( srcs: &[(&D::FloatStorage, &Layout)], dim: usize, ) -> Result<(D::FloatStorage, Shape)>
fn f_softmax( x: &D::FloatStorage, layout: &Layout, dim: usize, ) -> Result<D::FloatStorage>
fn f_rms_norm( x: &D::FloatStorage, x_l: &Layout, weight: &D::FloatStorage, weight_l: &Layout, eps: f64, ) -> Result<D::FloatStorage>
fn f_pick( mask: &D::BoolStorage, mask_l: &Layout, on_true: &D::FloatStorage, true_l: &Layout, on_false: &D::FloatStorage, false_l: &Layout, ) -> Result<D::FloatStorage>
fn f_pick_true( mask: &D::BoolStorage, mask_l: &Layout, value: f64, on_false: &D::FloatStorage, false_l: &Layout, ) -> Result<D::FloatStorage>
fn f_pick_false( mask: &D::BoolStorage, mask_l: &Layout, on_true: &D::FloatStorage, true_l: &Layout, value: f64, ) -> Result<D::FloatStorage>
fn f_allclose( a: &D::FloatStorage, a_l: &Layout, b: &D::FloatStorage, b_l: &Layout, rtol: f64, atol: f64, ) -> Result<bool>
Provided Methods§
fn f_view( _src: &D::FloatStorage, _src_l: &Layout, _dst_l: &Layout, _view: ViewOp, ) -> Result<Option<D::FloatStorage>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".