Skip to main content

NormalBinOps

Trait NormalBinOps 

Source
pub trait NormalBinOps<RHS = Self>
where <Self::OutputMeta as TypeCommon>::Vec: Send + Sync,
{ type Output; type OutputMeta: CommonBounds; type InplaceOutput; // Required methods fn add_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError> where U: BorrowMut<Self::InplaceOutput>; fn sub_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError> where U: BorrowMut<Self::InplaceOutput>; fn mul_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError> where U: BorrowMut<Self::InplaceOutput>; fn rem_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError> where U: BorrowMut<Self::InplaceOutput>; }
Expand description

A trait for binary operations on tensors.

Required Associated Types§

Source

type Output

The output tensor type.

Source

type OutputMeta: CommonBounds

The output tensor data type.

Source

type InplaceOutput

The inplace output tensor type.

Required Methods§

Source

fn add_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError>
where U: BorrowMut<Self::InplaceOutput>,

add with specified output tensor

§Parameters:

rhs: The right-hand side tensor.

out: The output tensor.

§Example:
let a = Tensor::<f32>::new([2.0]);
let b = Tensor::<f32>::new([3.0]);
let c = a.add_(&b, &mut a.clone())?; // c and a point to the same memory
println!("{}", c); // [5.0]
Source

fn sub_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError>
where U: BorrowMut<Self::InplaceOutput>,

subtract with specified output tensor

§Parameters:

rhs: The right-hand side tensor.

out: The output tensor.

§Example:
let a = Tensor::<f32>::new([2.0]);
let b = Tensor::<f32>::new([3.0]);
let c = a.sub_(&b, &mut a.clone())?; // c and a point to the same memory
println!("{}", c); // [-1.0]
Source

fn mul_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError>
where U: BorrowMut<Self::InplaceOutput>,

multiply with specified output tensor

§Parameters:

rhs: The right-hand side tensor.

out: The output tensor.

§Example:
let a = Tensor::<f32>::new([2.0]);
let b = Tensor::<f32>::new([3.0]);
let c = a.mul_(&b, &mut a.clone())?; // c and a point to the same memory
println!("{}", c); // [6.0]
Source

fn rem_<U>(&self, rhs: RHS, out: U) -> Result<Self::Output, TensorError>
where U: BorrowMut<Self::InplaceOutput>,

rem with specified output tensor

§Parameters:

rhs: The right-hand side tensor.

out: The output tensor.

§Example:
let a = Tensor::<f32>::new([2.0]);
let b = Tensor::<f32>::new([3.0]);
let c = a.mul_(&b, &mut a.clone())?; // c and a point to the same memory
println!("{}", c); // [6.0]

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§