@@ -35,6 +35,21 @@ void save_string(std::string content,
3535 fout.close ();
3636}
3737
38+ void save_graph_compilation_key (int64_t graph_compilation_key,
39+ std::string type,
40+ std::string saved_path) {
41+ VLOG (6 ) << type << " will be saved to " << saved_path;
42+ MkDirRecursively (DirName (saved_path).c_str ());
43+
44+ std::ofstream fout (saved_path);
45+ PADDLE_ENFORCE_EQ (
46+ static_cast <bool >(fout),
47+ true ,
48+ phi::errors::Unavailable (" Cannot open %s to save " , saved_path));
49+ fout << std::to_string (graph_compilation_key);
50+ fout.close ();
51+ }
52+
3853std::string node_format (const ir::Node& node, int number) {
3954 return " node_" + std::to_string (number) + " : " + " [" + node.Name () + " , " +
4055 (node.IsOp () ? " op" : " var" ) + " ]" ;
@@ -78,6 +93,7 @@ void save_graph(const ir::Graph& graph,
7893}
7994
8095void save_runtime_cinn_graph (const ir::Graph& graph,
96+ int64_t graph_compilation_key,
8197 std::string clusters_ops,
8298 std::string clusters_inputs,
8399 std::string cluster_outputs,
@@ -91,7 +107,9 @@ void save_runtime_cinn_graph(const ir::Graph& graph,
91107 save_string (cluster_intervals,
92108 " cluster_intervals" ,
93109 saved_path + " /cluster_intervals.txt" );
94-
110+ save_graph_compilation_key (graph_compilation_key,
111+ " graph_compilation_key" ,
112+ saved_path + " /graph_compilation_key.txt" );
95113 save_graph (graph, " graph" , saved_path + " /subgraph.txt" );
96114}
97115
0 commit comments