@@ -18,8 +18,8 @@ struct VariableParam {
1818 uint32_t version{0 };
1919};
2020
21- std::shared_ptr<Node> CreateVariableNode (const std::string& name) {
22- std::shared_ptr<Node> n = Node::Create ();
21+ NodePtr CreateVariableNode (const std::string& name) {
22+ NodePtr n = Node::Create ();
2323 n->op = nullptr ;
2424 n->attrs .name = name;
2525 n->attrs .parsed = VariableParam ();
@@ -95,10 +95,10 @@ inline bool IsAtomic(const std::vector<NodeEntry>& outputs) {
9595
9696// public functions
9797Symbol Symbol::Copy () const {
98- std::unordered_map<Node*, std::shared_ptr<Node> > old_new;
98+ std::unordered_map<Node*, NodePtr > old_new;
9999 // use DFSVisit to copy all the nodes
100- DFSVisit (this ->outputs , [&old_new](const std::shared_ptr<Node> & node) {
101- std::shared_ptr<Node> np = Node::Create ();
100+ DFSVisit (this ->outputs , [&old_new](const NodePtr & node) {
101+ NodePtr np = Node::Create ();
102102 np->op = node->op ;
103103 np->attrs = node->attrs ;
104104 old_new[node.get ()] = std::move (np);
@@ -109,7 +109,7 @@ Symbol Symbol::Copy() const {
109109 Node *ptr = e.node .get ();
110110 kv.second ->inputs .emplace_back (NodeEntry{old_new[ptr], e.index , e.version });
111111 }
112- for (const std::shared_ptr<Node> & p : kv.first ->control_deps ) {
112+ for (const NodePtr & p : kv.first ->control_deps ) {
113113 kv.second ->control_deps .emplace_back (old_new[p.get ()]);
114114 }
115115 }
@@ -131,7 +131,7 @@ void Symbol::Print(std::ostream &os) const {
131131 os << " \t output[" << i << " ]=" << outputs[i].node ->attrs .name
132132 << ' (' << outputs[i].index << " )\n " ;
133133 }
134- DFSVisit (this ->outputs , [&os](const std::shared_ptr<Node> & node) {
134+ DFSVisit (this ->outputs , [&os](const NodePtr & node) {
135135 if (node->is_variable ()) {
136136 os << " Variable:" << node->attrs .name << ' \n ' ;
137137 } else {
@@ -179,7 +179,7 @@ Symbol Symbol::operator[] (size_t index) const {
179179
180180std::vector<std::string> Symbol::ListArguments () const {
181181 std::vector<std::string> ret;
182- DFSVisit (this ->outputs , [&ret](const std::shared_ptr<Node> &node) {
182+ DFSVisit (this ->outputs , [&ret](const NodePtr &node) {
183183 if (node->is_variable ()) {
184184 ret.push_back (node->attrs .name );
185185 }
@@ -295,7 +295,7 @@ void Symbol::Compose(const array_view<const Symbol*>& args,
295295 std::unordered_map<Node *, const NodeEntry*> replace_map;
296296 // replace map stores the existing replacement plan for arguments node
297297 auto find_replace_map = [&nmatched, &arg_counter, &args, &kwargs, &replace_map]
298- (const std::shared_ptr<Node> &node) {
298+ (const NodePtr &node) {
299299 if (node->is_variable ()) {
300300 if (arg_counter < args.size ()) {
301301 replace_map[node.get ()] = &(args[arg_counter]->outputs [0 ]);
@@ -316,7 +316,7 @@ void Symbol::Compose(const array_view<const Symbol*>& args,
316316 std::vector<Node*> update_nodes;
317317 std::vector<std::pair<NodeEntry*, const NodeEntry*> > replace_plan;
318318 auto find_replace_plan = [&replace_map, &replace_plan, &update_nodes]
319- (const std::shared_ptr<Node> &node) {
319+ (const NodePtr &node) {
320320 // visit all the childs, find possible replacement
321321 bool repl = false ;
322322 for (size_t i = 0 ; i < node->inputs .size (); ++i) {
@@ -368,7 +368,7 @@ void Symbol::AddControlDeps(const Symbol& src) {
368368
369369Symbol Symbol::GetInternals () const {
370370 Symbol ret;
371- DFSVisit (this ->outputs , [&ret](const std::shared_ptr<Node> & node) {
371+ DFSVisit (this ->outputs , [&ret](const NodePtr & node) {
372372 Node* n = node.get ();
373373 if (n->is_variable ()) {
374374 // grab version from variable.
@@ -421,7 +421,7 @@ bool Symbol::GetAttr(const std::string& key, std::string* out) const {
421421std::unordered_map<std::string, std::string> Symbol::ListAttrs (ListAttrOption option) const {
422422 if (option == kRecursive ) {
423423 std::unordered_map<std::string, std::string> ret;
424- DFSVisit (this ->outputs , [&ret](const std::shared_ptr<Node> & n) {
424+ DFSVisit (this ->outputs , [&ret](const NodePtr & n) {
425425 for (const auto & it : n->attrs .dict ) {
426426 ret[n->attrs .name + symbol_constants::kNamespaceSeparator + it.first ] = it.second ;
427427 }
@@ -435,7 +435,7 @@ std::unordered_map<std::string, std::string> Symbol::ListAttrs(ListAttrOption op
435435Symbol Symbol::CreateFunctor (const Op* op,
436436 std::unordered_map<std::string, std::string>&& attrs) {
437437 Symbol s;
438- std::shared_ptr<Node> n = Node::Create ();
438+ NodePtr n = Node::Create ();
439439 n->op = op;
440440 n->attrs .dict = std::move (attrs);
441441 if (n->op ->attr_parser != nullptr ) {
0 commit comments