-
Notifications
You must be signed in to change notification settings - Fork 340
/
optimizer_fusion_engine_impl.h
46 lines (40 loc) · 1.34 KB
/
optimizer_fusion_engine_impl.h
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
#ifndef TENSORFLOW_CORE_GRAPH_OPTIMIZER_FUSION_ENGINE_IMPL_H_
#define TENSORFLOW_CORE_GRAPH_OPTIMIZER_FUSION_ENGINE_IMPL_H_
#include <map>
#include <vector>
#include "tensorflow/core/graph/template_base.h"
namespace tensorflow {
class Edge;
class Graph;
class Node;
class OptimizerFusionImpl {
public:
explicit OptimizerFusionImpl(Graph* g, TemplateBase* t);
bool Optimize();
private:
bool VisitMatchedNodes();
bool CheckOutputs(const Node* node,
const TempNode* temp_node);
bool CheckInputs(const Node* node,
const TempNode* temp_node);
bool CheckMatchedNodeInSameFrame();
private:
Graph* g_;
TemplateBase* t_;
std::map<const std::string, TempNode> temp_node_map_;
std::vector<const Edge*> fused_op_inputs_;
std::vector<const Edge*> fused_op_deps_inputs_;
std::vector<std::vector<const Edge*>> fused_op_outputs_;
std::map<std::string, MatchedNode> matched_node_map_;
int num_matched_;
// for dynamic outputs of templates
bool use_dynamic_output_keys_;
bool use_dynamic_input_keys_;
int dynamic_output_port_cur_;
int dynamic_input_port_cur_;
std::vector<std::vector<const Edge*>> fused_op_outputs_dynamic_;
std::vector<const Edge*> fused_op_input_dynamic_;
std::map<const Node *, std::string> node_frame_map_;
};
}
#endif // TENSORFLOW_CORE_GRAPH_OPTIMIZER_FUSION_ENGINE_IMPL_H_