pub struct SemanticExtensionRuleSet { /* private fields */ }Expand description
Explicit clone-on-write set of semantic extension AD rules.
Implementations§
Source§impl SemanticExtensionRuleSet
impl SemanticExtensionRuleSet
Sourcepub fn register_linearize(
&mut self,
rule: Arc<dyn SemanticLinearizeRule>,
) -> Result<(), SemanticExtensionRegistryError>
pub fn register_linearize( &mut self, rule: Arc<dyn SemanticLinearizeRule>, ) -> Result<(), SemanticExtensionRegistryError>
Register one semantic linearize rule.
§Errors
Returns SemanticExtensionRegistryError::MalformedFamilyId for an
invalid family or SemanticExtensionRegistryError::DuplicateRule for
an existing family in this role.
Sourcepub fn register_linear_transpose(
&mut self,
rule: Arc<dyn SemanticLinearTransposeRule>,
) -> Result<(), SemanticExtensionRegistryError>
pub fn register_linear_transpose( &mut self, rule: Arc<dyn SemanticLinearTransposeRule>, ) -> Result<(), SemanticExtensionRegistryError>
Register one semantic linear-transpose rule.
§Errors
Returns SemanticExtensionRegistryError::MalformedFamilyId for an
invalid family or SemanticExtensionRegistryError::DuplicateRule for
an existing family in this role.
Sourcepub fn register_primal_vjp(
&mut self,
rule: Arc<dyn SemanticPrimalVjpRule>,
) -> Result<(), SemanticExtensionRegistryError>
pub fn register_primal_vjp( &mut self, rule: Arc<dyn SemanticPrimalVjpRule>, ) -> Result<(), SemanticExtensionRegistryError>
Register one direct semantic primal-VJP rule.
§Errors
Returns SemanticExtensionRegistryError::MalformedFamilyId for an
invalid family or SemanticExtensionRegistryError::DuplicateRule for
an existing family in this role.
Sourcepub fn with_linearize(
self,
rule: Arc<dyn SemanticLinearizeRule>,
) -> Result<Self, SemanticExtensionRegistryError>
pub fn with_linearize( self, rule: Arc<dyn SemanticLinearizeRule>, ) -> Result<Self, SemanticExtensionRegistryError>
Return a rule set containing one semantic linearize rule.
§Errors
Returns SemanticExtensionRegistryError::MalformedFamilyId for an
invalid family or SemanticExtensionRegistryError::DuplicateRule for
an existing linearize rule.
Sourcepub fn with_linear_transpose(
self,
rule: Arc<dyn SemanticLinearTransposeRule>,
) -> Result<Self, SemanticExtensionRegistryError>
pub fn with_linear_transpose( self, rule: Arc<dyn SemanticLinearTransposeRule>, ) -> Result<Self, SemanticExtensionRegistryError>
Return a rule set containing one semantic linear-transpose rule.
§Errors
Returns SemanticExtensionRegistryError::MalformedFamilyId for an
invalid family or SemanticExtensionRegistryError::DuplicateRule for
an existing linear-transpose rule.
Sourcepub fn with_primal_vjp(
self,
rule: Arc<dyn SemanticPrimalVjpRule>,
) -> Result<Self, SemanticExtensionRegistryError>
pub fn with_primal_vjp( self, rule: Arc<dyn SemanticPrimalVjpRule>, ) -> Result<Self, SemanticExtensionRegistryError>
Return a rule set containing one direct semantic primal-VJP rule.
§Errors
Returns SemanticExtensionRegistryError::MalformedFamilyId for an
invalid family or SemanticExtensionRegistryError::DuplicateRule for
an existing primal-VJP rule.
Sourcepub fn merge(
&mut self,
other: Self,
) -> Result<(), SemanticExtensionRegistryError>
pub fn merge( &mut self, other: Self, ) -> Result<(), SemanticExtensionRegistryError>
Merge another rule set atomically.
§Errors
Returns SemanticExtensionRegistryError::MalformedFamilyId for an
invalid family or SemanticExtensionRegistryError::DuplicateRule for
a role-equivalent duplicate. The receiver is unchanged on failure.
Sourcepub fn lookup_linearize(
&self,
family_id: &str,
) -> Option<Arc<dyn SemanticLinearizeRule>>
pub fn lookup_linearize( &self, family_id: &str, ) -> Option<Arc<dyn SemanticLinearizeRule>>
Look up a semantic linearize rule by extension family.
Sourcepub fn lookup_linear_transpose(
&self,
family_id: &str,
) -> Option<Arc<dyn SemanticLinearTransposeRule>>
pub fn lookup_linear_transpose( &self, family_id: &str, ) -> Option<Arc<dyn SemanticLinearTransposeRule>>
Look up a semantic linear-transpose rule by extension family.
Sourcepub fn lookup_primal_vjp(
&self,
family_id: &str,
) -> Option<Arc<dyn SemanticPrimalVjpRule>>
pub fn lookup_primal_vjp( &self, family_id: &str, ) -> Option<Arc<dyn SemanticPrimalVjpRule>>
Look up a direct semantic primal-VJP rule by extension family.
Sourcepub fn linearize_operation(
&self,
operation: SemanticOperationView<'_>,
primal_inputs: &[ProgramValue],
primal_outputs: &[ProgramValue],
tangent_inputs: &[AdValue],
active_outputs: &[bool],
builder: &mut SemanticProgramBuilder,
) -> Result<SemanticLinearizeResult, SemanticAdError>
pub fn linearize_operation( &self, operation: SemanticOperationView<'_>, primal_inputs: &[ProgramValue], primal_outputs: &[ProgramValue], tangent_inputs: &[AdValue], active_outputs: &[bool], builder: &mut SemanticProgramBuilder, ) -> Result<SemanticLinearizeResult, SemanticAdError>
Validate and dispatch one semantic extension linearization.
§Errors
Returns SemanticAdError::CoreOperation for a core operation,
SemanticAdError::EffectfulExtension before rule dispatch for an
effectful extension, or typed rule/arity/ownership/build failures.
Sourcepub fn linear_transpose_operation(
&self,
operation: SemanticOperationView<'_>,
primal_inputs: &[ProgramValue],
primal_outputs: &[ProgramValue],
cotangent_outputs: &[AdValue],
active_inputs: &[bool],
residuals: &[ProgramValue],
builder: &mut SemanticProgramBuilder,
) -> Result<Box<[AdValue]>, SemanticAdError>
pub fn linear_transpose_operation( &self, operation: SemanticOperationView<'_>, primal_inputs: &[ProgramValue], primal_outputs: &[ProgramValue], cotangent_outputs: &[AdValue], active_inputs: &[bool], residuals: &[ProgramValue], builder: &mut SemanticProgramBuilder, ) -> Result<Box<[AdValue]>, SemanticAdError>
Validate and dispatch one semantic extension linear transpose.
§Errors
Returns SemanticAdError::EffectfulExtension before rule dispatch,
SemanticAdError::MissingRule when no transpose rule exists,
SemanticAdError::Arity / SemanticAdError::ForeignValue for an
invalid request or result, or a typed family-rule failure.
Sourcepub fn primal_vjp_operation(
&self,
operation: SemanticOperationView<'_>,
primal_inputs: &[ProgramValue],
primal_outputs: &[ProgramValue],
cotangent_outputs: &[AdValue],
active_inputs: &[bool],
builder: &mut SemanticProgramBuilder,
) -> Result<Box<[AdValue]>, SemanticAdError>
pub fn primal_vjp_operation( &self, operation: SemanticOperationView<'_>, primal_inputs: &[ProgramValue], primal_outputs: &[ProgramValue], cotangent_outputs: &[AdValue], active_inputs: &[bool], builder: &mut SemanticProgramBuilder, ) -> Result<Box<[AdValue]>, SemanticAdError>
Validate and dispatch one direct semantic primal VJP.
§Errors
Returns SemanticAdError::EffectfulExtension before rule dispatch,
SemanticAdError::MissingRule when no primal-VJP rule exists,
SemanticAdError::Arity / SemanticAdError::ForeignValue for an
invalid request or result, or a typed family-rule failure.
Trait Implementations§
Source§impl Clone for SemanticExtensionRuleSet
impl Clone for SemanticExtensionRuleSet
Source§fn clone(&self) -> SemanticExtensionRuleSet
fn clone(&self) -> SemanticExtensionRuleSet
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 SemanticExtensionRuleSet
impl Debug for SemanticExtensionRuleSet
Source§impl Default for SemanticExtensionRuleSet
impl Default for SemanticExtensionRuleSet
Source§fn default() -> SemanticExtensionRuleSet
fn default() -> SemanticExtensionRuleSet
Auto Trait Implementations§
impl Freeze for SemanticExtensionRuleSet
impl !RefUnwindSafe for SemanticExtensionRuleSet
impl Send for SemanticExtensionRuleSet
impl Sync for SemanticExtensionRuleSet
impl Unpin for SemanticExtensionRuleSet
impl UnsafeUnpin for SemanticExtensionRuleSet
impl !UnwindSafe for SemanticExtensionRuleSet
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,
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