pub struct Df64EinsumVjp { /* private fields */ }Expand description
The adjoint of a two-input contraction.
The adjoint of out = einsum(lhs, rhs) contracts the output cotangent with the other operand,
which is the same operation with the labels rotated: lhs_bar = einsum(out, rhs -> lhs) and
rhs_bar = einsum(lhs, out -> rhs). It carries the pattern so the adjoint uses exactly the
labels the primal used, and it has two outputs because the contraction has two inputs.
§Examples
use tenferro_ad::extension::ExtensionOp;
use tenferro_df64_proof::extension::Df64EinsumVjp;
let adjoint = Df64EinsumVjp::of(&[&[0, 1], &[1, 2]], &[0, 2]).expect("a contraction");
assert_eq!(<Df64EinsumVjp as ExtensionOp>::input_count(&adjoint), 3);
assert_eq!(<Df64EinsumVjp as ExtensionOp>::output_count(&adjoint), 2);Implementations§
Source§impl Df64EinsumVjp
impl Df64EinsumVjp
Sourcepub fn of(inputs: &[&[u32]], out: &[u32]) -> Result<Self>
pub fn of(inputs: &[&[u32]], out: &[u32]) -> Result<Self>
Build the adjoint for the same labels as the primal contraction.
§Errors
Returns [tenferro_tensor::Error::InvalidArgument] when the pattern is not a pairwise contraction: an operand
carries no label, a label repeats inside one operand, the operands share no contracted
label, or an output label appears in no operand.
§Examples
use tenferro_df64_proof::extension::Df64EinsumVjp;
assert!(Df64EinsumVjp::of(&[&[0, 1], &[1, 2]], &[0, 2]).is_ok());
assert!(Df64EinsumVjp::of(&[&[], &[1, 2]], &[0, 2]).is_err());Sourcepub fn input_labels(&self) -> &[Vec<u32>]
pub fn input_labels(&self) -> &[Vec<u32>]
The primal pattern’s label lists.
Every operand’s labels, in operand order.
§Examples
use tenferro_df64_proof::extension::Df64EinsumVjp;
let adjoint = Df64EinsumVjp::of(&[&[0, 1], &[1, 2]], &[0, 2]).expect("a contraction");
assert_eq!(adjoint.input_labels(), &[vec![0, 1], vec![1, 2]]);Sourcepub fn out_labels(&self) -> &[u32]
pub fn out_labels(&self) -> &[u32]
The output’s labels, in the output’s axis order.
§Examples
use tenferro_df64_proof::extension::Df64EinsumVjp;
let adjoint = Df64EinsumVjp::of(&[&[0, 1], &[1, 2]], &[0, 2]).expect("a contraction");
assert_eq!(adjoint.out_labels(), &[0, 2]);Trait Implementations§
Source§impl Clone for Df64EinsumVjp
impl Clone for Df64EinsumVjp
Source§fn clone(&self) -> Df64EinsumVjp
fn clone(&self) -> Df64EinsumVjp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Df64EinsumVjp
impl Debug for Df64EinsumVjp
impl Eq for Df64EinsumVjp
Source§impl ExtensionOp for Df64EinsumVjp
impl ExtensionOp for Df64EinsumVjp
Source§fn payload_hash(&self, hasher: &mut dyn Hasher)
fn payload_hash(&self, hasher: &mut dyn Hasher)
family_id). Read moreSource§fn payload_eq(&self, other: &dyn ExtensionOp) -> bool
fn payload_eq(&self, other: &dyn ExtensionOp) -> bool
Source§fn input_count(&self) -> usize
fn input_count(&self) -> usize
Arc<dyn ExtensionOp> value.Source§fn output_count(&self) -> usize
fn output_count(&self) -> usize
Self::infer_output_meta call.Source§fn semantic_effects(&self) -> ExtensionEffectDeclaration<'_>
fn semantic_effects(&self) -> ExtensionEffectDeclaration<'_>
Source§fn semantic_aliases(&self) -> ExtensionAliasDeclaration<'_>
fn semantic_aliases(&self) -> ExtensionAliasDeclaration<'_>
Source§fn scalar_identity(&self) -> Option<&'static str>
fn scalar_identity(&self) -> Option<&'static str>
Source§fn infer_output_meta(
&self,
ctx: &mut ExtensionShapeContext<'_>,
) -> Result<Vec<(DType, Vec<SymDim>)>>
fn infer_output_meta( &self, ctx: &mut ExtensionShapeContext<'_>, ) -> Result<Vec<(DType, Vec<SymDim>)>>
Source§fn lower_to_standard_ops(
&self,
_builder: &mut GraphBuilder<StdTensorOp>,
_inputs: &[ValueRef<StdTensorOp>],
_input_dtypes: &[DType],
_input_shapes: &[&[SymDim]],
) -> Result<ExtensionStandardLowering, ExtensionLoweringError>
fn lower_to_standard_ops( &self, _builder: &mut GraphBuilder<StdTensorOp>, _inputs: &[ValueRef<StdTensorOp>], _input_dtypes: &[DType], _input_shapes: &[&[SymDim]], ) -> Result<ExtensionStandardLowering, ExtensionLoweringError>
Source§fn prune_outputs(&self, _live_outputs: &[bool]) -> Option<Arc<dyn ExtensionOp>>
fn prune_outputs(&self, _live_outputs: &[bool]) -> Option<Arc<dyn ExtensionOp>>
Source§impl PartialEq for Df64EinsumVjp
impl PartialEq for Df64EinsumVjp
impl StructuralPartialEq for Df64EinsumVjp
Auto Trait Implementations§
impl Freeze for Df64EinsumVjp
impl RefUnwindSafe for Df64EinsumVjp
impl Send for Df64EinsumVjp
impl Sync for Df64EinsumVjp
impl Unpin for Df64EinsumVjp
impl UnsafeUnpin for Df64EinsumVjp
impl UnwindSafe for Df64EinsumVjp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more