pub trait HostReference:
Debug
+ Send
+ Sync
+ 'static {
// Required method
fn execute(&self, inputs: &[&Tensor]) -> Result<Vec<Tensor>>;
}Expand description
Host/reference implementation for an extension family.
This capability is optional. Backend-only extension families can omit it
and still implement ExtensionOp; runtimes that specifically delegate to
host reference execution must report a typed capability-missing error when
this hook is absent.
§Examples
use tenferro_ops::ext_op::HostReference;
use tenferro_tensor::Tensor;
#[derive(Debug)]
struct IdentityHost;
impl HostReference for IdentityHost {
fn execute(&self, inputs: &[&Tensor]) -> tenferro_tensor::Result<Vec<Tensor>> {
Ok(vec![inputs[0].clone()])
}
}
let input = Tensor::from_vec_col_major(vec![1], vec![3.0_f64]).unwrap();
let output = IdentityHost.execute(&[&input]).unwrap();
assert_eq!(output[0].as_slice::<f64>().unwrap(), &[3.0]);