Clones node_index_map and update the child pointers
| 24 | |
| 25 | /// Clones node_index_map and update the child pointers |
| 26 | std::vector<std::shared_ptr<common::Node>> cloneNodes( |
| 27 | const std::vector<common::Node *> &node_index_map, |
| 28 | const std::vector<common::Node_ids> &ids) { |
| 29 | using arrayfire::common::Node; |
| 30 | // find all moddims in the tree |
| 31 | std::vector<std::shared_ptr<Node>> node_clones; |
| 32 | node_clones.reserve(node_index_map.size()); |
| 33 | transform(begin(node_index_map), end(node_index_map), |
| 34 | back_inserter(node_clones), [](Node *n) { return n->clone(); }); |
| 35 | |
| 36 | for (common::Node_ids id : ids) { |
| 37 | auto &children = node_clones[id.id]->m_children; |
| 38 | for (int i = 0; i < Node::kMaxChildren && children[i] != nullptr; i++) { |
| 39 | children[i] = node_clones[id.child_ids[i]]; |
| 40 | } |
| 41 | } |
| 42 | return node_clones; |
| 43 | } |
| 44 | |
| 45 | /// Sets the shape of the buffer node_index_map under the moddims node to the |
| 46 | /// new shape |
no test coverage detected