in gad/src/core.rs [239:256]
fn add_all(&mut self, values: &[&Value<D>]) -> Result<Value<D>> {
let result = self
.eval()
.add_all(&values.iter().map(|v| v.data()).collect::<Vec<_>>())?;
let inputs = values.iter().map(|v| v.input()).collect::<Vec<_>>();
let value = self.make_node(result, inputs, {
let ids = values.iter().map(|v| v.id()).collect::<Vec<_>>();
move |graph, store, gradient| {
for id in &ids {
if let Some(id) = id {
store.add_gradient(graph, *id, &gradient)?;
}
}
Ok(())
}
});
Ok(value)
}