()
| 4901 | |
| 4902 | #[test] |
| 4903 | fn call_iterate_test() { |
| 4904 | let context = create_unchecked_context().unwrap(); |
| 4905 | let single_bit_adder = context.create_graph().unwrap(); |
| 4906 | { |
| 4907 | let carry = single_bit_adder.input(scalar_type(BIT)).unwrap(); |
| 4908 | let inputs = single_bit_adder |
| 4909 | .input(tuple_type(vec![scalar_type(BIT), scalar_type(BIT)])) |
| 4910 | .unwrap(); |
| 4911 | let a = single_bit_adder.tuple_get(inputs.clone(), 0).unwrap(); |
| 4912 | let b = single_bit_adder.tuple_get(inputs.clone(), 1).unwrap(); |
| 4913 | let ac = single_bit_adder.add(carry.clone(), a.clone()).unwrap(); |
| 4914 | let bc = single_bit_adder.add(carry.clone(), b.clone()).unwrap(); |
| 4915 | let result = single_bit_adder.add(ac.clone(), b.clone()).unwrap(); |
| 4916 | let result_carry = single_bit_adder |
| 4917 | .add( |
| 4918 | single_bit_adder.multiply(ac.clone(), bc.clone()).unwrap(), |
| 4919 | carry, |
| 4920 | ) |
| 4921 | .unwrap(); |
| 4922 | let output = single_bit_adder |
| 4923 | .create_tuple(vec![result_carry.clone(), result.clone()]) |
| 4924 | .unwrap(); |
| 4925 | single_bit_adder.set_output_node(output).unwrap(); |
| 4926 | single_bit_adder.finalize().unwrap(); |
| 4927 | } |
| 4928 | let v32 = vector_type(32, scalar_type(BIT)); |
| 4929 | let adder = context.create_graph().unwrap(); |
| 4930 | { |
| 4931 | let a = adder.input(v32.clone()).unwrap(); |
| 4932 | let b = adder.input(v32.clone()).unwrap(); |
| 4933 | let azb = adder.zip(vec![a, b]).unwrap(); |
| 4934 | let c = adder |
| 4935 | .constant(scalar_type(BIT), Value::from_bytes(vec![0])) |
| 4936 | .unwrap(); |
| 4937 | let cr = adder.iterate(single_bit_adder, c, azb).unwrap(); |
| 4938 | let r = adder.tuple_get(cr, 1).unwrap(); |
| 4939 | adder.set_output_node(r).unwrap(); |
| 4940 | adder.finalize().unwrap(); |
| 4941 | } |
| 4942 | let three_adder = context.create_graph().unwrap(); |
| 4943 | let a = three_adder.input(v32.clone()).unwrap(); |
| 4944 | let b = three_adder.input(v32.clone()).unwrap(); |
| 4945 | let c = three_adder.input(v32.clone()).unwrap(); |
| 4946 | let result = three_adder |
| 4947 | .call( |
| 4948 | adder.clone(), |
| 4949 | vec![three_adder.call(adder.clone(), vec![a, b]).unwrap(), c], |
| 4950 | ) |
| 4951 | .unwrap(); |
| 4952 | three_adder.set_output_node(result).unwrap(); |
| 4953 | three_adder.finalize().unwrap(); |
| 4954 | context.set_main_graph(three_adder).unwrap(); |
| 4955 | context.finalize().unwrap(); |
| 4956 | } |
| 4957 | |
| 4958 | #[test] |
| 4959 | fn test_malformed_graphs() { |
nothing calls this directly
no test coverage detected