提交 a235ab0c 编写于 作者: S ShawnXuan

node to Json


Former-commit-id: eef978462c30f95f374e59aa383796f68fb1f1cb
上级 c0e1504d
......@@ -275,8 +275,9 @@ void LogicalGraph::SetDepthAndBranchId4Nodes() {
// print depth for check
ForEachLogicalNode<LogicalNode>([&](LogicalNode* node) {
LOG(INFO) << node->op_vec().at(0)->op_name() << " " << node->depth() << " "
<< node->branch_id();
// LOG(INFO) << node->op_vec().at(0)->op_name() << " " << node->depth() << " "
// << node->branch_id();
LOG(INFO) << node->JsonStr();
});
}
......
......@@ -182,6 +182,14 @@ std::string LogicalNode::VisualStr() const {
return ss.str();
}
std::string LogicalNode::JsonStr() const {
std::stringstream ss;
ss << "{\"type\": \"" << TypeName() << "\", \"op_names\": \"";
for (std::shared_ptr<Operator> op : op_vec_) { ss << " " << op->op_name(); }
ss << "\", \"depth\": " << depth() << ", \"branch\": " << branch_id() << " }";
return ss.str();
}
bool LogicalNode::HasOpWithModelOrConstModelBlob() const {
return HasOpWithCondition([](const Operator* op) {
return op->model_bns().empty() == false || op->const_model_bns().empty() == false;
......
......@@ -45,6 +45,7 @@ class LogicalNode : public Node<LogicalNode, LogicalEdge> {
// util
virtual std::string TypeName() const = 0;
std::string VisualStr() const;
std::string JsonStr() const;
bool HasOpWithModelOrConstModelBlob() const;
bool HasOpWithModelBlob() const;
bool HasOpWithForwardModelBlob() const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册