| 29 | namespace { |
| 30 | |
| 31 | TEST(MakeStateless, ParallelMap) { |
| 32 | using test::function::NDef; |
| 33 | GrapplerItem item; |
| 34 | item.graph = test::function::GDef( |
| 35 | {NDef("start", "Const", {}, {{"value", 0}, {"dtype", DT_INT32}}), |
| 36 | NDef("stop", "Const", {}, {{"value", 10}, {"dtype", DT_INT32}}), |
| 37 | NDef("step", "Const", {}, {{"value", 1}, {"dtype", DT_INT32}}), |
| 38 | NDef("range", "RangeDataset", {"start", "stop", "step"}, {}), |
| 39 | NDef("num_parallel_calls", "Const", {}, |
| 40 | {{"value", 1}, {"dtype", DT_INT32}}), |
| 41 | graph_tests_utils::MakeParallelMapNode("map", "range", |
| 42 | "num_parallel_calls", "XTimesTwo", |
| 43 | /*sloppy=*/false)}, |
| 44 | // FunctionLib |
| 45 | { |
| 46 | test::function::XTimesTwo(), |
| 47 | }); |
| 48 | |
| 49 | InjectPrefetch optimizer; |
| 50 | GraphDef output; |
| 51 | TF_ASSERT_OK(optimizer.Optimize(nullptr, item, &output)); |
| 52 | EXPECT_TRUE(graph_utils::ContainsNodeWithOp("PrefetchDataset", output)); |
| 53 | int index = graph_utils::FindGraphNodeWithOp("PrefetchDataset", output); |
| 54 | EXPECT_FALSE(output.node(index).attr().at("legacy_autotune").b()); |
| 55 | } |
| 56 | |
| 57 | TEST(MakeStateless, ParallelInterleave) { |
| 58 | using test::function::NDef; |
nothing calls this directly
no test coverage detected