pub struct CustomOpRegistry { /* private fields */ }Expand description
Registry for custom operations.
Implementations§
Source§impl CustomOpRegistry
impl CustomOpRegistry
Sourcepub fn register(
&mut self,
name: impl Into<String>,
metadata: CustomOpMetadata,
handler: CustomOpHandler,
) -> Result<()>
pub fn register( &mut self, name: impl Into<String>, metadata: CustomOpMetadata, handler: CustomOpHandler, ) -> Result<()>
Register a custom operation.
§Examples
use tensorlogic_compiler::compile::CustomOpRegistry;
use tensorlogic_compiler::compile::CustomOpMetadata;
use std::sync::Arc;
let mut registry = CustomOpRegistry::new();
let metadata = CustomOpMetadata {
name: "custom_and".to_string(),
description: "Custom AND with threshold".to_string(),
expected_arity: Some(2),
is_differentiable: true,
};
registry.register(
"custom_and",
metadata,
Arc::new(|expr, ctx, graph, data| {
// Custom compilation logic here
Ok(0)
}),
).unwrap();Sourcepub fn unregister(&mut self, name: &str) -> Result<()>
pub fn unregister(&mut self, name: &str) -> Result<()>
Unregister a custom operation.
Sourcepub fn has_operation(&self, name: &str) -> bool
pub fn has_operation(&self, name: &str) -> bool
Check if an operation is registered.
Sourcepub fn get_metadata(&self, name: &str) -> Option<CustomOpMetadata>
pub fn get_metadata(&self, name: &str) -> Option<CustomOpMetadata>
Get metadata for an operation.
Sourcepub fn list_operations(&self) -> Vec<String>
pub fn list_operations(&self) -> Vec<String>
List all registered operations.
Sourcepub fn invoke(
&self,
name: &str,
expr: &TLExpr,
ctx: &mut CompilerContext,
graph: &mut EinsumGraph,
data: &CustomOpData,
) -> Result<usize>
pub fn invoke( &self, name: &str, expr: &TLExpr, ctx: &mut CompilerContext, graph: &mut EinsumGraph, data: &CustomOpData, ) -> Result<usize>
Invoke a custom operation.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CustomOpRegistry
impl RefUnwindSafe for CustomOpRegistry
impl Send for CustomOpRegistry
impl Sync for CustomOpRegistry
impl Unpin for CustomOpRegistry
impl UnwindSafe for CustomOpRegistry
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
Mutably borrows from an owned value. Read more