图编译缓存功能支持将图编译结果进行磁盘持久化,当应用程序重新运行时直接加载磁盘上缓存的编译结果。在编译并运行Graph过程中,为了减少图编译时长,可以开启图编译缓存功能。
1 2 3 4 5 6 |
std::map<ge::AscendString, ge::AscendString> session_options = {{"ge.graph_compiler_cache_dir", "./build_cache_dir"}}; std::shared_ptr<ge::Session> session = std::make_shared<ge::Session>(session_options); const auto graph = CreateGraph(); std::map<ge::AscendString, ge::AscendString> graph_options = {{"ge.graph_key", "test_graph_001"}}; auto = session->AddGraph(0, graph, graph_options); ... |
生成文件包括:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{ "cache_file_list":[ { "cache_file_name":"./cache_dir/graph_$key1_20230117202307.om", "graph_key":"graph_$key1", "var_desc_file_name":"./cache_dir/graph_$key1_20230117202307.rdcpkt" }, { "cache_file_name":"./cache_dir/graph_$key1_20230117203007.om", "graph_key":"graph_$key1", "var_desc_file_name":"./cache_dir/graph_$key1_20230117203007.rdcpkt" } ] } |
文件名生成规则: