tensorflow/core/grappler/optimizers/inference/batch_op_rewriter_test.cc
// Tests that reserved attributes relevant with adaptive scheduler are
// overridden in the output GraphDef.
Tests that reserved attributes relevant with adaptive scheduler are
overridden in the output GraphDef.
Tests that reserved attributes relevant with adaptive scheduler are overridden in the output GraphDef .
TEST_P(BatchOpRewriterTest, AdaptiveBatchScheduler) {
  BatchOpRewriteConfig config;
  config.set_enable_adaptive_shared_batching_thread_pool(GetParam());
  (*config.mutable_model_scheduler_options())["model_with_override"]
      .mutable_batches_to_average_over()
      ->set_value(1000);
  (*config.mutable_model_scheduler_options())["model_with_override"]
      .mutable_initial_inflight_batches_limit()
      ->set_value(16);
  (*config.mutable_model_scheduler_options())["model_with_override"]
      .mutable_min_inflight_batches_limit()
      ->set_value(8);
  (*config.mutable_model_scheduler_options())["model_with_override"]
      .mutable_max_inflight_batches_limit()
      ->set_value(32);
  RewriterConfig_CustomGraphOptimizer rewriter_config = MakeConfig(config);
  ConfigProto config_proto;
  config_proto.mutable_experimental()->mutable_session_metadata()->set_version(
      123);
  config_proto.mutable_experimental()->mutable_session_metadata()->set_name(
      "model_with_override");
  BatchOpRewriter optimizer;
  TF_ASSERT_OK(optimizer.InitWithConfig(config_proto, &rewriter_config));
  GraphDef optimized_graph;
  GrapplerItem item;
  AddBatchOp(&item.graph, 16);
  TF_ASSERT_OK(optimizer.Optimize(nullptr, item, &optimized_graph));
  GraphDef expected_graph;
  AddBatchOp(&expected_graph, 16 ,
             {
                 {kBatchesToAverageOverAttr, 1000},
                 {kInitialInflightBatchesAttr, 16},
                 {kMinInflightBatchesAttr, 8},
                 {kMaxInflightBatchesAttr, 32},
             });
  EXPECT_EQ(optimized_graph.DebugString(), expected_graph.DebugString());
}
TEST_P ( BatchOpRewriterTest , AdaptiveBatchScheduler ) { BatchOpRewriteConfig config ; config . set_enable_adaptive_shared_batching_thread_pool ( GetParam ( ) ) ; ( * config . mutable_model_scheduler_options ( ) ) [ " " ] . mutable_batches_to_average_over ( ) -> set_value ( 1000 ) ; ( * config . mutable_model_scheduler_options ( ) ) [ " " ] . mutable_initial_inflight_batches_limit ( ) -> set_value ( 16 ) ; ( * config . mutable_model_scheduler_options ( ) ) [ " " ] . mutable_min_inflight_batches_limit ( ) -> set_value ( 8 ) ; ( * config . mutable_model_scheduler_options ( ) ) [ " " ] . mutable_max_inflight_batches_limit ( ) -> set_value ( 32 ) ; RewriterConfig_CustomGraphOptimizer rewriter_config = MakeConfig ( config ) ; ConfigProto config_proto ; config_proto . mutable_experimental ( ) -> mutable_session_metadata ( ) -> set_version ( 123 ) ; config_proto . mutable_experimental ( ) -> mutable_session_metadata ( ) -> set_name ( " " ) ; BatchOpRewriter optimizer ; TF_ASSERT_OK ( optimizer . InitWithConfig ( config_proto , & rewriter_config ) ) ; GraphDef optimized_graph ; GrapplerItem item ; AddBatchOp ( & item . graph , 16 ) ; TF_ASSERT_OK ( optimizer . Optimize ( nullptr , item , & optimized_graph ) ) ; GraphDef expected_graph ; AddBatchOp ( & expected_graph , 16 , { { kBatchesToAverageOverAttr , 1000 } , { kInitialInflightBatchesAttr , 16 } , { kMinInflightBatchesAttr , 8 } , { kMaxInflightBatchesAttr , 32 } , } ) ; EXPECT_EQ ( optimized_graph . DebugString ( ) , expected_graph . DebugString ( ) ) ; }
Tests that reserved attributes relevant with adaptive scheduler are
overridden in the output GraphDef.
Tests that reserved attributes relevant with adaptive scheduler are overridden in the output GraphDef .
// PARSE_TEXT_PROTO isn't available in TF OSS. // We can't use the testing::EqualsProto matcher because it is not available // in OSS. // For `model_with_override`, attribute `num_batch_threads` is 16 and not // overridden to zero regardless of // `enable_adaptive_shared_batching_thread_pool`, since `model_with_override` // override its scheduler options in `model_scheduler_options`. /* num_batch_threads */