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

Function test_instantiation_pass

ciphercore-base/src/custom_ops.rs:914–1121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

912
913 #[test]
914 fn test_instantiation_pass() {
915 || -> Result<()> {
916 let c = simple_context(|g| {
917 let i = g.input(scalar_type(BIT))?;
918 let o = g.custom_op(CustomOperation::new(A {}), vec![i])?;
919 o.set_name("A")?;
920 Ok(o)
921 })?;
922
923 let processed_c = run_instantiation_pass(c)?.context;
924
925 let expected_c = create_context()?;
926 let g2 = expected_c.create_graph()?;
927 let i = g2.input(scalar_type(BIT))?;
928 g2.set_output_node(i)?;
929 g2.set_name("__B::<bit>")?;
930 g2.finalize()?;
931 let g1 = expected_c.create_graph()?;
932 let i = g1.input(scalar_type(BIT))?;
933 g1.set_output_node(i)?;
934 g1.finalize()?;
935 let g3 = expected_c.create_graph()?;
936 let i = g3.input(scalar_type(BIT))?;
937 let o = g3.call(g2, vec![i])?;
938 g3.set_output_node(o)?;
939 g3.set_name("__A::<bit>")?;
940 g3.finalize()?;
941 let g4 = expected_c.create_graph()?;
942 let i = g4.input(scalar_type(BIT))?;
943 let o = g4.call(g3, vec![i])?;
944 o.set_name("A")?;
945 g4.set_output_node(o)?;
946 g4.finalize()?;
947 expected_c.set_main_graph(g4)?;
948 expected_c.finalize()?;
949 assert!(contexts_deep_equal(expected_c, processed_c));
950 Ok(())
951 }()
952 .unwrap();
953
954 || -> Result<()> {
955 let c = create_context()?;
956 let sub_g = c.create_graph()?;
957 let i = sub_g.input(scalar_type(BIT))?;
958 sub_g.set_output_node(i)?;
959 sub_g.finalize()?;
960 let g = c.create_graph()?;
961 let i = g.input(scalar_type(BIT))?;
962 let ii = g.call(sub_g, vec![i])?;
963 let o = g.custom_op(CustomOperation::new(B {}), vec![ii])?;
964 o.set_name("B")?;
965 g.set_output_node(o)?;
966 g.finalize()?;
967 c.set_main_graph(g)?;
968 c.finalize()?;
969
970 let processed_c = run_instantiation_pass(c)?.context;
971

Callers

nothing calls this directly

Calls 15

simple_contextFunction · 0.85
run_instantiation_passFunction · 0.85
onesMethod · 0.80
cloneMethod · 0.80
scalar_typeFunction · 0.70
create_contextFunction · 0.70
array_typeFunction · 0.70
inputMethod · 0.45
custom_opMethod · 0.45
set_nameMethod · 0.45
create_graphMethod · 0.45
set_output_nodeMethod · 0.45

Tested by

no test coverage detected