Creates a computation context with a single graph within it. The graph is passed to the provided `build_graph_fn` function to specify the computation. The node returned by the function is marked as output. # Returns New computation context # Example ``` # use ciphercore_base::graphs::util::simple_context; # use ciphercore_base::data_types::{scalar_type, INT32}; let c = simple_context(|g| { le
(build_graph_fn: F)
| 4816 | /// }).unwrap(); |
| 4817 | /// ``` |
| 4818 | pub fn simple_context<F>(build_graph_fn: F) -> Result<Context> |
| 4819 | where |
| 4820 | F: FnOnce(&Graph) -> Result<Node>, |
| 4821 | { |
| 4822 | let c = create_context()?; |
| 4823 | let g = c.create_graph()?; |
| 4824 | let out = build_graph_fn(&g)?; |
| 4825 | out.set_as_output()?; |
| 4826 | g.finalize()?; |
| 4827 | g.set_as_main()?; |
| 4828 | c.finalize()?; |
| 4829 | Ok(c) |
| 4830 | } |
| 4831 | } |
| 4832 | |
| 4833 | #[cfg(test)] |