Skip to main content

Df64EinsumJvp

Struct Df64EinsumJvp 

Source
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

Source

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());
Source

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]);
Source

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]);
Source

pub fn tangents(&self) -> &[bool]

Which operands carry a tangent, in operand 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.tangents(), &[true, false]);

Trait Implementations§

Source§

impl Clone for Df64EinsumJvp

Source§

fn clone(&self) -> Df64EinsumJvp

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Df64EinsumJvp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Df64EinsumJvp

Source§

impl ExtensionOp for Df64EinsumJvp

Source§

fn family_id(&self) -> &'static str

Stable, process-independent family identifier. Read more
Source§

fn payload_hash(&self, hasher: &mut dyn Hasher)

Hash the payload (everything except family_id). Read more
Source§

fn payload_eq(&self, other: &dyn ExtensionOp) -> bool

Structural equality against another extension value. Read more
Source§

fn clone_arc(&self) -> Arc<dyn ExtensionOp> ⓘ

Deep-clone the payload behind an Arc. Read more
Source§

fn as_any(&self) -> &dyn Any

Upcast this extension to &dyn Any for downcasting in payload_eq. Read more
Source§

fn input_count(&self) -> usize

Number of primal inputs. MUST be constant for any given Arc<dyn ExtensionOp> value.
Source§

fn output_count(&self) -> usize

Number of outputs. MUST match the length of the vector returned by a successful Self::infer_output_meta call.
Source§

fn semantic_effects(&self) -> ExtensionEffectDeclaration<'_>

Declare observable semantic effects for this extension payload. Read more
Source§

fn semantic_aliases(&self) -> ExtensionAliasDeclaration<'_>

Declare semantic output aliasing for this extension payload. Read more
Source§

fn scalar_identity(&self) -> Option<&'static str>

Canonical identity of an externally defined scalar this operation carries. Read more
Source§

fn infer_output_meta( &self, ctx: &mut ExtensionShapeContext<'_>, ) -> Result<Vec<(DType, Vec<SymDim>)>>

Infer output dtypes and shapes for each output slot. Read more
Source§

fn lower_to_standard_ops( &self, _builder: &mut GraphBuilder<StdTensorOp>, _inputs: &[ValueRef<StdTensorOp>], _input_dtypes: &[DType], _input_shapes: &[&[SymDim]], ) -> Result<ExtensionStandardLowering, ExtensionLoweringError>

Try to expand this extension into standard tensor graph operations. Read more
Source§

fn prune_outputs(&self, _live_outputs: &[bool]) -> Option<Arc<dyn ExtensionOp>>

Optionally return an equivalent op that produces only live outputs. Read more
Source§

impl PartialEq for Df64EinsumJvp

Source§

fn eq(&self, other: &Df64EinsumJvp) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Df64EinsumJvp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.