diff options
Diffstat (limited to 'src/dynamic_fusion/sketch/utils/DependencyGraph.h')
-rw-r--r-- | src/dynamic_fusion/sketch/utils/DependencyGraph.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/dynamic_fusion/sketch/utils/DependencyGraph.h b/src/dynamic_fusion/sketch/utils/DependencyGraph.h index 03678defae..633c5e4263 100644 --- a/src/dynamic_fusion/sketch/utils/DependencyGraph.h +++ b/src/dynamic_fusion/sketch/utils/DependencyGraph.h @@ -417,6 +417,33 @@ public: } return tensors; } + /** Get intermediate tensors of the whole graph. + * + * @return std::vector<TensorId> + */ + std::vector<TensorId> intermediate_tensors() const + { + std::vector<TensorId> tensors; + + // If a tensor is used to connect the input of an operator and the output of another operator, + // it is not allocated in the memory. The tensor exists as a temporary variable only. + for(auto src_tensor : _adj_src_ops) + { + if(!src_tensor.second.empty()) + { + const auto dst_tensor = _adj_dst_ops.find(src_tensor.first); + if(dst_tensor != _adj_dst_ops.end()) + { + if(!dst_tensor->second.empty()) + { + tensors.push_back(src_tensor.first); + } + } + } + } + + return tensors; + } /** Get all root ops. Root ops can also be referred to as "src ops" of the whole graph * * @return std::vector<OperatorId> |