This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from winstywang/master
static graph
- Loading branch information
Showing
3 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*! | ||
* Copyright (c) 2015 by Contributors | ||
* \file static_graph.h | ||
* \brief the static graph of symbols | ||
*/ | ||
#ifndef MXNET_STATIC_GRAPH_H_ | ||
#define MXNET_STATIC_GRAPH_H_ | ||
|
||
#include <vector> | ||
#include <unordered_map> | ||
#include <string> | ||
#include <memory> | ||
#include "./atomic_symbol.h" | ||
namespace mxnet { | ||
|
||
struct StaticGraph { | ||
struct StaticNode { | ||
/*! \brief wrapped atomic symbol */ | ||
AtomicSymbol* sym_; | ||
/*! \brief name of the node */ | ||
std::string name_; | ||
}; | ||
std::unordered_map<std::string, int> name_id_map; | ||
std::vector<StaticNode> nodes; | ||
std::vector<std::vector<int> > output_index; | ||
std::vector<std::vector<int> > connected_graph; | ||
int FindNodeByName(const std::string& name, const AtomicSymbol* sym) { | ||
int id = 0; | ||
if (name_id_map.find(name) == name_id_map.end()) { | ||
name_id_map[name] = name_id_map.size(); | ||
StaticNode static_node; | ||
static_node.sym_ = sym->Copy(); | ||
static_node.name_ = name; | ||
nodes.push_back(static_node); | ||
output_index.push_back(std::vector<int>()); | ||
connected_graph.push_back(std::vector<int>()); | ||
id = name_id_map.size(); | ||
} else { | ||
id = name_id_map[name]; | ||
} | ||
return id; | ||
} | ||
}; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters