| 47 | } |
| 48 | |
| 49 | void AnalyzeAndVerify( |
| 50 | const GraphDef& graphdef, FunctionLibraryDefinition* flib_def, |
| 51 | const absl::flat_hash_map<std::string, absl::flat_hash_set<std::string>>& |
| 52 | expected) { |
| 53 | auto graph = absl::make_unique<Graph>(flib_def); |
| 54 | TF_EXPECT_OK( |
| 55 | ConvertGraphDefToGraph(GraphConstructorOptions(), graphdef, graph.get())); |
| 56 | |
| 57 | auto pflr = absl::make_unique<ProcessFunctionLibraryRuntime>( |
| 58 | nullptr, Env::Default(), TF_GRAPH_DEF_VERSION, flib_def, |
| 59 | OptimizerOptions()); |
| 60 | FunctionLibraryRuntime* lib_runtime = |
| 61 | pflr->GetFLR(ProcessFunctionLibraryRuntime::kDefaultFLRDevice); |
| 62 | absl::flat_hash_map<ResourceUsageAnalysis::NodeInfo, |
| 63 | absl::flat_hash_set<ResourceUsageAnalysis::NodeInfo>> |
| 64 | source_to_path; |
| 65 | TF_EXPECT_OK(ResourceUsageAnalysis::Analyze(graph.get(), lib_runtime, |
| 66 | &source_to_path)); |
| 67 | |
| 68 | absl::flat_hash_map<ResourceUsageAnalysis::NodeInfo, |
| 69 | absl::flat_hash_set<ResourceUsageAnalysis::NodeInfo>> |
| 70 | expected_source_to_path; |
| 71 | for (auto it : expected) { |
| 72 | auto src_node_info = node_info_from_string(it.first); |
| 73 | for (const std::string& user : it.second) { |
| 74 | expected_source_to_path[src_node_info].emplace( |
| 75 | node_info_from_string(user)); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | EXPECT_EQ(source_to_path, expected_source_to_path); |
| 80 | } |
| 81 | |
| 82 | } // anonymous namespace |
| 83 |
no test coverage detected