| 82 | } // anonymous namespace |
| 83 | |
| 84 | TEST(ResourceOpAnalyzerTest, SingleResourceSingleUserNoPassThrough) { |
| 85 | FunctionLibraryDefinition flib_def(OpRegistry::Global(), |
| 86 | FunctionDefLibrary()); |
| 87 | GraphDefBuilder builder(GraphDefBuilder::kFailImmediately, &flib_def); |
| 88 | auto opts = builder.opts(); |
| 89 | auto op_reg = opts.op_registry(); |
| 90 | |
| 91 | { |
| 92 | /* |
| 93 | * stack_size -> stack_op -> stack_close |
| 94 | */ |
| 95 | NodeBuilder stack_size_placeholder_builder("stack_size", "Placeholder", |
| 96 | op_reg); |
| 97 | stack_size_placeholder_builder.Attr("dtype", DT_INT32); |
| 98 | Node* stack_size_placeholder = |
| 99 | opts.FinalizeBuilder(&stack_size_placeholder_builder); |
| 100 | |
| 101 | NodeBuilder stack_op_builder("stack_op", "StackV2", op_reg); |
| 102 | stack_op_builder.Input(stack_size_placeholder).Attr("elem_type", DT_FLOAT); |
| 103 | Node* stack_op = opts.FinalizeBuilder(&stack_op_builder); |
| 104 | |
| 105 | NodeBuilder stack_close_builder("stack_close", "StackCloseV2", op_reg); |
| 106 | stack_close_builder.Input(stack_op); |
| 107 | opts.FinalizeBuilder(&stack_close_builder); |
| 108 | } |
| 109 | |
| 110 | GraphDef graphdef; |
| 111 | TF_EXPECT_OK(builder.ToGraphDef(&graphdef)); |
| 112 | |
| 113 | absl::flat_hash_map<std::string, absl::flat_hash_set<std::string>> expected; |
| 114 | expected[":stack_op:StackV2"] = |
| 115 | absl::flat_hash_set<std::string>({":stack_close:StackCloseV2"}); |
| 116 | AnalyzeAndVerify(graphdef, &flib_def, expected); |
| 117 | } |
| 118 | |
| 119 | TEST(ResourceOpAnalyzerTest, SingleResourceSingleUserWithPassThrough) { |
| 120 | FunctionLibraryDefinition flib_def(OpRegistry::Global(), |
nothing calls this directly
no test coverage detected