diff options
Diffstat (limited to 'runtimes/neurun/core/include/model/Subgraphs.h')
-rw-r--r-- | runtimes/neurun/core/include/model/Subgraphs.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/runtimes/neurun/core/include/model/Subgraphs.h b/runtimes/neurun/core/include/model/Subgraphs.h new file mode 100644 index 000000000..13bc549be --- /dev/null +++ b/runtimes/neurun/core/include/model/Subgraphs.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __NEURUN_MODEL_SUBGRAPHS_H__ +#define __NEURUN_MODEL_SUBGRAPHS_H__ + +#include "model/Index.h" +#include "model/Subgraph.h" +#include "util/ObjectManager.h" + +namespace neurun +{ +namespace model +{ + +/** + * @brief Class that manages Subgraph objects + */ +class Subgraphs : public util::ObjectManager<SubgraphIndex, Subgraph> +{ +public: + /** + * @brief Create an instance of Subgraph with given op and push it to objects + * + * @param[in] op_idx Operation index that is emplaced + * @param[in] op Operation that is emplaced + * @param[in] layout Subgraph's layout + * @return SubgraphIndex + */ + SubgraphIndex emplace(const OperationIndex &op_index, const Operation &op, Layout layout); + + /** + * @brief Push an instance of Subgraph to objects + * + * @param[in] subg An instance of Subgraph + * @return SubgraphIndex + */ + SubgraphIndex emplace(std::unique_ptr<Subgraph> &&subg); + + /** + * @brief Check if an operation does exist in any subgraphs + * + * @param operation_index Operation index to find + * @return true If such operation exists in any subgraphs otherwise false + */ + bool containsOperation(const OperationIndex &operation_index) const; + /** + * @brief Find an operation from all subgraphs + * + * @param operation_index Operation index to find + * @return SubgraphIndex Index of Subgraph that contains given operation index + */ + SubgraphIndex getOperation(const OperationIndex &operation_index) const; + /** + * @brief Dump subgraphs + * + * @param msg Message that will be displayed + */ + void dump(const std::string &msg) const; + +private: + SubgraphIndex findOperation(const OperationIndex &operation_index) const; +}; + +} // namespace model +} // namespace neurun + +#endif // __NEURUN_MODEL_SUBGRAPHS_H__ |