pub trait TensorDot: TensorElementwise {
// Required method
fn dot_general(
&mut self,
lhs: &Tensor,
rhs: &Tensor,
config: &DotGeneralConfig,
) -> Result<Tensor>;
// Provided methods
fn dot_general_read_into(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
out: TensorWrite<'_>,
) -> Result<()> { ... }
fn dot_general_read_into_accum(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
accumulation: DotGeneralAccumulation,
out: TensorWrite<'_>,
) -> Result<()> { ... }
}Expand description
Dot-general operations.
§Examples
use tenferro_tensor::TensorDot;
fn accepts_dot<B: TensorDot>(_backend: &mut B) {}Required Methods§
fn dot_general( &mut self, lhs: &Tensor, rhs: &Tensor, config: &DotGeneralConfig, ) -> Result<Tensor>
Provided Methods§
Sourcefn dot_general_read_into(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
out: TensorWrite<'_>,
) -> Result<()>
fn dot_general_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, config: &DotGeneralConfig, out: TensorWrite<'_>, ) -> Result<()>
Overwrite caller-provided output with dot-general from read inputs.
This is the dot/GEMM spelling of _into: the previous output value is
not read. Use TensorDot::dot_general_read_into_accum for explicit
read-modify-write accumulation.
§Examples
use tenferro_tensor::{DotGeneralConfig, TensorDot, TensorRead, TensorWrite};
fn dot_into<B: TensorDot>(
backend: &mut B,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
out: TensorWrite<'_>,
) -> tenferro_tensor::Result<()> {
backend.dot_general_read_into(lhs, rhs, config, out)
}Sourcefn dot_general_read_into_accum(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
accumulation: DotGeneralAccumulation,
out: TensorWrite<'_>,
) -> Result<()>
fn dot_general_read_into_accum( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, config: &DotGeneralConfig, accumulation: DotGeneralAccumulation, out: TensorWrite<'_>, ) -> Result<()>
Apply scaled dot-general accumulation into caller-provided output.
This is explicitly read-modify-write when accumulation.beta is nonzero:
out = alpha * dot_general(lhs, rhs) + beta * out.
§Examples
use tenferro_tensor::{
DotGeneralAccumulation, DotGeneralConfig, TensorDot, TensorRead, TensorWrite,
};
fn dot_add_to<B: TensorDot>(
backend: &mut B,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
out: TensorWrite<'_>,
) -> tenferro_tensor::Result<()> {
let accumulation = DotGeneralAccumulation::add_to(lhs.dtype())?;
backend.dot_general_read_into_accum(lhs, rhs, config, accumulation, out)
}