MCPcopy Index your code
hub / github.com/ciphermodelabs/ciphercore / test_vector

Function test_vector

ciphercore-base/src/ops/min_max.rs:257–298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

255
256 #[test]
257 fn test_vector() {
258 || -> Result<()> {
259 let context = || -> Result<Context> {
260 let c = simple_context(|g| {
261 let i1 = g.input(array_type(vec![1, 3, 64], BIT))?;
262 let i2 = g.input(array_type(vec![3, 1, 64], BIT))?;
263 g.create_tuple(vec![
264 g.custom_op(
265 CustomOperation::new(Min {
266 signed_comparison: false,
267 }),
268 vec![i1.clone(), i2.clone()],
269 )?,
270 g.custom_op(
271 CustomOperation::new(Max {
272 signed_comparison: false,
273 }),
274 vec![i1.clone(), i2.clone()],
275 )?,
276 ])
277 })?;
278 let mapped_c = run_instantiation_pass(c)?;
279 Ok(mapped_c.get_context())
280 }()?;
281 let a = vec![0, 30, 100];
282 let b = vec![10, 50, 150];
283 let v = random_evaluate(
284 context.get_main_graph()?,
285 vec![
286 Value::from_flattened_array(&a, UINT64)?,
287 Value::from_flattened_array(&b, UINT64)?,
288 ],
289 )?
290 .to_vector()?;
291 let min_a_b = v[0].to_flattened_array_u64(array_type(vec![3, 3], UINT64))?;
292 let max_a_b = v[1].to_flattened_array_u64(array_type(vec![3, 3], UINT64))?;
293 assert_eq!(min_a_b, vec![0, 10, 10, 0, 30, 50, 0, 30, 100]);
294 assert_eq!(max_a_b, vec![10, 30, 100, 50, 50, 100, 150, 150, 150]);
295 Ok(())
296 }()
297 .unwrap();
298 }
299}

Callers

nothing calls this directly

Calls 10

simple_contextFunction · 0.85
run_instantiation_passFunction · 0.85
random_evaluateFunction · 0.85
array_typeFunction · 0.50
inputMethod · 0.45
create_tupleMethod · 0.45
get_contextMethod · 0.45
to_vectorMethod · 0.45
get_main_graphMethod · 0.45

Tested by

no test coverage detected