From 4979e1d55783d05520fda56fd89641f817daf119 Mon Sep 17 00:00:00 2001 From: Max Galkin Date: Tue, 27 Mar 2018 18:06:30 -0700 Subject: [PATCH] Disable new Gather/Slice estimators for now to fix the crashes during some TF graphs optimizations. PiperOrigin-RevId: 190705686 --- .../core/grappler/costs/op_level_cost_estimator.cc | 3 ++ .../grappler/costs/op_level_cost_estimator_test.cc | 61 ++++++++++++---------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/tensorflow/core/grappler/costs/op_level_cost_estimator.cc b/tensorflow/core/grappler/costs/op_level_cost_estimator.cc index fdbc61f..905cc2a 100644 --- a/tensorflow/core/grappler/costs/op_level_cost_estimator.cc +++ b/tensorflow/core/grappler/costs/op_level_cost_estimator.cc @@ -171,9 +171,12 @@ OpLevelCostEstimator::OpLevelCostEstimator() { {kNoOp, wrap(&OpLevelCostEstimator::PredictNoOp)}, + // TODO(76227186): re-enable with output size check & test + /* {kGather, wrap(&OpLevelCostEstimator::PredictGatherOrSlice)}, {kGatherV2, wrap(&OpLevelCostEstimator::PredictGatherOrSlice)}, {kSlice, wrap(&OpLevelCostEstimator::PredictGatherOrSlice)}, + */ {kPlaceholder, wrap(&OpLevelCostEstimator::PredictIdentity)}, {kIdentity, wrap(&OpLevelCostEstimator::PredictIdentity)}, diff --git a/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc b/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc index f2a9615..99bf28f 100644 --- a/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc +++ b/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc @@ -195,40 +195,43 @@ class OpLevelCostEstimatorTest : public ::testing::Test { OpLevelCostEstimator estimator_; }; +// TODO(76227186): re-enable with output size check & test +/* TEST_F(OpLevelCostEstimatorTest, TestGatherCosts) { - OpContext op_context; - SetCpuDevice(&op_context.op_info); - op_context.op_info.set_op("Gather"); - - // Huge first input shouldn't affect Gather execution and memory costs. - DescribeArbitraryRankInput({10000000, 10}, DT_FLOAT, &op_context.op_info); - DescribeArbitraryRankInput({16}, DT_INT64, &op_context.op_info); - DescribeArbitraryRankOutput({16, 10}, DT_FLOAT, &op_context.op_info); - - auto cost = estimator_.PredictCosts(op_context); - EXPECT_EQ(Costs::Duration(130), cost.memory_time); - EXPECT_EQ(Costs::Duration(16), cost.compute_time); - EXPECT_EQ(Costs::Duration(146), cost.execution_time); - EXPECT_FALSE(cost.inaccurate); +OpContext op_context; +SetCpuDevice(&op_context.op_info); +op_context.op_info.set_op("Gather"); + +// Huge first input shouldn't affect Gather execution and memory costs. +DescribeArbitraryRankInput({10000000, 10}, DT_FLOAT, &op_context.op_info); +DescribeArbitraryRankInput({16}, DT_INT64, &op_context.op_info); +DescribeArbitraryRankOutput({16, 10}, DT_FLOAT, &op_context.op_info); + +auto cost = estimator_.PredictCosts(op_context); +EXPECT_EQ(Costs::Duration(130), cost.memory_time); +EXPECT_EQ(Costs::Duration(16), cost.compute_time); +EXPECT_EQ(Costs::Duration(146), cost.execution_time); +EXPECT_FALSE(cost.inaccurate); } TEST_F(OpLevelCostEstimatorTest, TestSliceCosts) { - OpContext op_context; - SetCpuDevice(&op_context.op_info); - op_context.op_info.set_op("Slice"); - - // Huge first input shouldn't affect Slice execution and memory costs. - DescribeArbitraryRankInput({10000000, 10}, DT_FLOAT, &op_context.op_info); - DescribeArbitraryRankInput({2}, DT_INT64, &op_context.op_info); - DescribeArbitraryRankInput({2}, DT_INT64, &op_context.op_info); - DescribeArbitraryRankOutput({10, 10}, DT_FLOAT, &op_context.op_info); - - auto cost = estimator_.PredictCosts(op_context); - EXPECT_EQ(Costs::Duration(81), cost.memory_time); - EXPECT_EQ(Costs::Duration(10), cost.compute_time); - EXPECT_EQ(Costs::Duration(91), cost.execution_time); - EXPECT_FALSE(cost.inaccurate); +OpContext op_context; +SetCpuDevice(&op_context.op_info); +op_context.op_info.set_op("Slice"); + +// Huge first input shouldn't affect Slice execution and memory costs. +DescribeArbitraryRankInput({10000000, 10}, DT_FLOAT, &op_context.op_info); +DescribeArbitraryRankInput({2}, DT_INT64, &op_context.op_info); +DescribeArbitraryRankInput({2}, DT_INT64, &op_context.op_info); +DescribeArbitraryRankOutput({10, 10}, DT_FLOAT, &op_context.op_info); + +auto cost = estimator_.PredictCosts(op_context); +EXPECT_EQ(Costs::Duration(81), cost.memory_time); +EXPECT_EQ(Costs::Duration(10), cost.compute_time); +EXPECT_EQ(Costs::Duration(91), cost.execution_time); +EXPECT_FALSE(cost.inaccurate); } +*/ TEST_F(OpLevelCostEstimatorTest, BiasAddExecutionTime) { auto cost = PredictCosts(DescribeBiasAdd(1000, 10)); -- 2.7.4