pub struct ValidationExecutor { /* private fields */ }Expand description
Compile-execute-validate pipeline for TensorLogic expressions.
§Example
use tensorlogic_ir::{TLExpr, Term};
use tensorlogic_oxirs_bridge::{ValidationExecutor, ValidationExecutorConfig};
let expr = TLExpr::pred("knows", vec![Term::var("x"), Term::var("y")]);
let executor = ValidationExecutor::new(ValidationExecutorConfig::default());
let result = executor.execute_rule(&expr).unwrap();
let report = executor.generate_validation_report(&result);
assert!(report.conforms);
let rdf = executor.export_as_rdf(&result);
assert!(rdf.contains("@prefix tl:"));Implementations§
Source§impl ValidationExecutor
impl ValidationExecutor
Sourcepub fn new(config: ValidationExecutorConfig) -> Self
pub fn new(config: ValidationExecutorConfig) -> Self
Create a new executor with the given configuration.
Sourcepub fn config(&self) -> &ValidationExecutorConfig
pub fn config(&self) -> &ValidationExecutorConfig
Return a reference to the active configuration.
Sourcepub fn execute_rule(
&self,
expr: &TLExpr,
) -> Result<ExecutionResult, ValidationExecutorError>
pub fn execute_rule( &self, expr: &TLExpr, ) -> Result<ExecutionResult, ValidationExecutorError>
Compile expr to an tensorlogic_ir::EinsumGraph, execute it with placeholder
input tensors via Scirs2Exec, and return an ExecutionResult.
§Errors
ValidationExecutorError::Compile— compiler rejected the expression.ValidationExecutorError::EmptyGraph— compiled graph is trivially empty.ValidationExecutorError::Execute— forward pass failed.ValidationExecutorError::TensorTooLarge— output exceeds configured limit.
Sourcepub fn generate_validation_report(
&self,
result: &ExecutionResult,
) -> ValidationReport
pub fn generate_validation_report( &self, result: &ExecutionResult, ) -> ValidationReport
Generate a SHACL-style ValidationReport from an ExecutionResult.
The report conforms (report.conforms == true) when every output tensor
contains only finite values. A sh:Violation-severity
ValidationResult is added for each tensor that contains NaN or Inf
elements, carrying the tensor name and non-finite count in the message.
Sourcepub fn export_as_rdf(&self, result: &ExecutionResult) -> String
pub fn export_as_rdf(&self, result: &ExecutionResult) -> String
Serialise an ExecutionResult as an RDF Turtle string.
The generated document uses a tl: prefix for the configured
base_iri and declares standard XSD types. Each execution is
identified by a stable IRI derived from the expression_repr hash so
that repeated calls for the same expression produce consistent IRIs.
Each output tensor is appended as a blank-node tl:OutputTensor with
shape, element count, allFinite, min, and max.
Auto Trait Implementations§
impl Freeze for ValidationExecutor
impl RefUnwindSafe for ValidationExecutor
impl Send for ValidationExecutor
impl Sync for ValidationExecutor
impl Unpin for ValidationExecutor
impl UnsafeUnpin for ValidationExecutor
impl UnwindSafe for ValidationExecutor
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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