blob: 716f09bcfab6d98b4e8850630eacdf65a8ffb275 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* 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_IR_SUBGRAPHS_H__
#define __NEURUN_IR_SUBGRAPHS_H__
#include "ir/Index.h"
#include "ir/OpSequence.h"
#include "util/ObjectManager.h"
namespace neurun
{
namespace ir
{
/**
* @brief Class that manages OpSequence objects
*/
class Subgraphs : public util::ObjectManager<SubgraphIndex, OpSequence>
{
public:
/**
* @brief Create an instance of OpSequence 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 OpSequence's layout
* @return SubgraphIndex
*/
SubgraphIndex emplace(const OperationIndex &op_index, const Operation &op, Layout layout);
/**
* @brief Push an instance of OpSequence to objects
*
* @param[in] subg An instance of OpSequence
* @return SubgraphIndex
*/
SubgraphIndex emplace(std::unique_ptr<OpSequence> &&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 OpSequence 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;
/**
* @brief Remove an operation from OpSequence
*
* @param operation_index Operation index to be removed
*/
void removeFromSubgraph(const OperationIndex &operation_index);
private:
SubgraphIndex findOperation(const OperationIndex &operation_index) const;
};
} // namespace ir
} // namespace neurun
#endif // __NEURUN_IR_SUBGRAPHS_H__
|