MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / load_static

Function load_static

flow-rs/src/node/mod.rs:59–85  ·  view source on GitHub ↗
(
    local_key: u64,
    config: &crate::config::interlayer::Node,
)

Source from the content-addressed store, hash-verified

57}
58
59pub(crate) fn load_static(
60 local_key: u64,
61 config: &crate::config::interlayer::Node,
62) -> Result<Vec<Box<dyn Actor>>> {
63 if config.entity.ty.len() > 1 {
64 return Err(anyhow!("static subgraph/node dont support dyn type"));
65 }
66 let ty = config.entity.ty.first().unwrap();
67 if let Some(node) = NodeSlice::registry_local().get(local_key).get(ty) {
68 Ok((0..config.cloned.unwrap_or(1))
69 .into_iter()
70 .map(|_| (node.cons)(config.entity.name.clone(), &config.entity.args))
71 .collect())
72 } else if let Some(graph) = GraphSlice::registry_local().get(local_key).get(ty) {
73 (0..config.cloned.unwrap_or(1))
74 .into_iter()
75 .map(|_| (graph.cons)(config.entity.name.clone(), &config.entity.args))
76 .map(|g| g.map(|g| Box::new(g) as Box<dyn Actor>))
77 .collect()
78 } else {
79 Err(anyhow!(
80 "unexpected node {}:{:?}",
81 config.entity.name,
82 config.entity.ty
83 ))
84 }
85}
86
87pub(crate) fn inputs(local_key: u64, ty: &str) -> Result<BTreeSet<String>> {
88 if let Some(node) = NodeSlice::registry_local().get(local_key).get(ty) {

Callers 3

newMethod · 0.85
newMethod · 0.85
newMethod · 0.85

Calls 4

firstMethod · 0.80
lenMethod · 0.45
getMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected