Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Into<OpType> for custom ops #731

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/ops/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ impl From<ExternalOp> for LeafOp {
}
}

impl From<ExternalOp> for OpType {
fn from(value: ExternalOp) -> Self {
let leaf: LeafOp = value.into();
leaf.into()
}
}

impl ExternalOp {
/// Name of the ExternalOp
pub fn name(&self) -> SmolStr {
Expand Down Expand Up @@ -235,6 +242,19 @@ impl OpaqueOp {
}
}

impl From<OpaqueOp> for LeafOp {
fn from(value: OpaqueOp) -> Self {
LeafOp::CustomOp(Box::new(ExternalOp::Opaque(value)))
}
}

impl From<OpaqueOp> for OpType {
fn from(value: OpaqueOp) -> Self {
let leaf: LeafOp = value.into();
leaf.into()
}
}

/// Resolve serialized names of operations into concrete implementation (OpDefs) where possible
#[allow(dead_code)]
pub fn resolve_extension_ops(
Expand Down