pub struct Df64EinsumJvp { /* private fields */ }Expand description
The forward tangent of a two-input contraction.
The tangent of out = einsum(lhs, rhs) is einsum(lhs_dot, rhs) + einsum(lhs, rhs_dot), so the
helper contracts each tangent with the other operand and adds the two results in the extended
scalar. Its tangent availability is a payload field, because a linearization need not have a
tangent for both operands, and the rule must not materialise a zero tangent for one that is
absent.
§Examples
use tenferro_ad::extension::ExtensionOp;
use tenferro_df64_proof::extension::Df64EinsumJvp;
let tangent = Df64EinsumJvp::of(&[&[0, 1], &[1, 2]], &[0, 2], &[true, false]).expect("a contraction");
assert_eq!(<Df64EinsumJvp as ExtensionOp>::input_count(&tangent), 3);
assert_eq!(<Df64EinsumJvp as ExtensionOp>::output_count(&tangent), 1);Implementations§
Source§impl Df64EinsumJvp
impl Df64EinsumJvp
Sourcepub fn of(inputs: &[&[u32]], out: &[u32], tangents: &[bool]) -> Result<Self>
pub fn of(inputs: &[&[u32]], out: &[u32], tangents: &[bool]) -> Result<Self>
Build the tangent for a pattern and one tangent availability.
§Errors
Returns an error when the operand list is not a valid pattern (an operand carries no label, or an output label appears in no operand), when the tangent mask does not have one entry per operand, or when no operand carries a tangent, because then there is nothing to differentiate.
§Examples
use tenferro_df64_proof::extension::Df64EinsumJvp;
assert!(Df64EinsumJvp::of(&[&[0, 1], &[1, 2]], &[0, 2], &[true, true]).is_ok());
assert!(Df64EinsumJvp::of(&[&[0, 1], &[1, 2]], &[0, 2], &[false, false]).is_err());Sourcepub fn input_labels(&self) -> &[Vec<u32>]
pub fn input_labels(&self) -> &[Vec<u32>]
The tangent’s pattern and the availability of each operand’s tangent.
§Examples
use tenferro_df64_proof::extension::Df64EinsumJvp;
let tangent = Df64EinsumJvp::of(&[&[0, 1], &[1, 2]], &[0, 2], &[true, true]).expect("a tangent");
assert_eq!(tangent.tangents(), &[true, true]);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::Df64EinsumJvp;
let tangent = Df64EinsumJvp::of(&[&[0, 1], &[1, 2]], &[0, 2], &[true, false])
.expect("a tangent");
assert_eq!(tangent.out_labels(), &[0, 2]);Trait Implementations§
Source§impl Clone for Df64EinsumJvp
impl Clone for Df64EinsumJvp
Source§fn clone(&self) -> Df64EinsumJvp
fn clone(&self) -> Df64EinsumJvp
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 Df64EinsumJvp
impl Debug for Df64EinsumJvp
impl Eq for Df64EinsumJvp
Source§impl ExtensionOp for Df64EinsumJvp
impl ExtensionOp for Df64EinsumJvp
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 Df64EinsumJvp
impl PartialEq for Df64EinsumJvp
impl StructuralPartialEq for Df64EinsumJvp
Auto Trait Implementations§
impl Freeze for Df64EinsumJvp
impl RefUnwindSafe for Df64EinsumJvp
impl Send for Df64EinsumJvp
impl Sync for Df64EinsumJvp
impl Unpin for Df64EinsumJvp
impl UnsafeUnpin for Df64EinsumJvp
impl UnwindSafe for Df64EinsumJvp
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