MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / custom_reduce_vec_helper

Function custom_reduce_vec_helper

ciphercore-base/src/ops/utils.rs:470–485  ·  view source on GitHub ↗
(
        arrays: Vec<TypedValue>,
        combine: impl Fn(Vec<Node>, Vec<Node>) -> Result<Vec<Node>>,
    )

Source from the content-addressed store, hash-verified

468 }
469
470 fn custom_reduce_vec_helper(
471 arrays: Vec<TypedValue>,
472 combine: impl Fn(Vec<Node>, Vec<Node>) -> Result<Vec<Node>>,
473 ) -> Result<Vec<Value>> {
474 let c = simple_context(|g| {
475 let inputs = arrays
476 .iter()
477 .map(|array| g.input(array.t.clone()))
478 .collect::<Result<_>>()?;
479 g.create_tuple(custom_reduce_vec(inputs, combine)?)
480 })?;
481 let c = run_instantiation_pass(c)?.context;
482 let inputs = arrays.into_iter().map(|array| array.value).collect();
483 let outputs = random_evaluate(c.get_main_graph()?, inputs)?;
484 outputs.to_vector()
485 }
486
487 #[test]
488 fn test_custom_reduce_vec_sum_and_multiply_rows() -> Result<()> {

Calls 9

simple_contextFunction · 0.85
custom_reduce_vecFunction · 0.85
run_instantiation_passFunction · 0.85
random_evaluateFunction · 0.85
cloneMethod · 0.80
inputMethod · 0.45
create_tupleMethod · 0.45
get_main_graphMethod · 0.45
to_vectorMethod · 0.45