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

Method instantiate

ciphercore-base/src/ops/min_max.rs:71–89  ·  view source on GitHub ↗
(&self, context: Context, arguments_types: Vec<Type>)

Source from the content-addressed store, hash-verified

69#[typetag::serde]
70impl CustomOperationBody for Min {
71 fn instantiate(&self, context: Context, arguments_types: Vec<Type>) -> Result<Graph> {
72 if arguments_types.len() != 2 {
73 return Err(runtime_error!("Invalid number of arguments for Min"));
74 }
75 let g = context.create_graph()?;
76 let i1 = g.input(arguments_types[0].clone())?;
77 let i2 = g.input(arguments_types[1].clone())?;
78 let cmp = g.custom_op(
79 CustomOperation::new(GreaterThan {
80 signed_comparison: self.signed_comparison,
81 }),
82 vec![i1.clone(), i2.clone()],
83 )?;
84 let normalized_cmp = normalize_cmp(cmp)?;
85 let o = g.custom_op(CustomOperation::new(Mux {}), vec![normalized_cmp, i2, i1])?;
86 g.set_output_node(o)?;
87 g.finalize()?;
88 Ok(g)
89 }
90
91 fn get_name(&self) -> String {
92 format!("Min(signed_comparison={})", self.signed_comparison)

Callers

nothing calls this directly

Calls 7

normalize_cmpFunction · 0.85
cloneMethod · 0.80
create_graphMethod · 0.45
inputMethod · 0.45
custom_opMethod · 0.45
set_output_nodeMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected