Skip to content

Commit

Permalink
feat(python_ffi): 跳过未连接到图上的边
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <ydrml@hotmail.com>
  • Loading branch information
YdrMaster committed Dec 7, 2023
1 parent 0e4a3ce commit 369f109
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/09python_ffi/src/import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,21 @@ namespace refactor::python_ffi {
for (auto const &output : outputs) {
builder.edges.insert({output, {nullptr, output}});
}
builder.topology.insert(
{std::move(node), {std::move(inputs), std::move(outputs)}});
builder.topology.insert({
std::move(node),
{std::move(inputs), std::move(outputs)},
});
}
builder.nodes.reserve(nodes.size());
for (auto &[name, operator_] : nodes) {
auto node = Node{std::move(*operator_), name};
builder.nodes.insert({std::move(name), std::move(node)});
builder.nodes.insert({std::move(name), Node{std::move(*operator_), name}});
}
for (auto &[name, tensor] : edges) {
auto edge = Edge{std::move(tensor), name};
auto it = builder.edges.find(name);
ASSERT(it != builder.edges.end(), "edge {} not connected", name);
it->second.tensor = std::move(edge.tensor);
if (auto it = builder.edges.find(name); it != builder.edges.end()) {
it->second.tensor = std::move(tensor);
} else {
fmt::println("\x1b[93mWARNING: edge {} not connected\x1b[0m", name);
}
}
return std::make_shared<Compiler>(Graph(builder.build()));
}
Expand Down

0 comments on commit 369f109

Please sign in to comment.