ubiquity_hyperquiver/
lib.rs1use ndarray::{Array1, Array2};
4use ubiquity_kernel::UbiqError;
5
6pub struct HyperEdge {
8 pub dims: Vec<usize>, pub out_dim: usize,
10 pub weights: Vec<Array2<f32>>, }
12
13impl HyperEdge {
14 pub fn apply(&self, inputs: &[Array1<f32>]) -> Result<Array1<f32>, UbiqError> {
15 if inputs.len() != self.dims.len() { return Err(UbiqError::Dim("arity mismatch".into())); }
16 let mut acc = inputs[0].clone();
18 for (i, w) in self.weights.iter().enumerate() {
19 if i+1 >= inputs.len() { break; }
20 let next = &inputs[i+1];
21 let mut cat = Array1::<f32>::zeros(acc.len() + next.len());
23 cat.slice_mut(ndarray::s![..acc.len()]).assign(&acc);
24 cat.slice_mut(ndarray::s![acc.len()..]).assign(next);
25 acc = w.dot(&cat);
26 }
27 Ok(acc)
28 }
29}