[Slice] Reduce variance in benchmark.
This change switches the various Slice benchmarks to run using tf.data's single-threaded executor. This eliminates noise from thread scheduling, which is often larger than the actual execution time for some of the benchmarks. PiperOrigin-RevId: 298638978 Change-Id: Id9472df0eea4a2ec56a3b88154b8069e92bc11dc
This commit is contained in:
parent
e4dc8c0ded
commit
8da96e9b52
tensorflow/core/kernels
@ -2280,6 +2280,7 @@ tf_cc_test(
|
|||||||
"//tensorflow/core:test",
|
"//tensorflow/core:test",
|
||||||
"//tensorflow/core:test_main",
|
"//tensorflow/core:test_main",
|
||||||
"//tensorflow/core:testlib",
|
"//tensorflow/core:testlib",
|
||||||
|
"//tensorflow/core/kernels/data:single_threaded_executor",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
#include "tensorflow/core/framework/types.h"
|
#include "tensorflow/core/framework/types.h"
|
||||||
#include "tensorflow/core/framework/types.pb.h"
|
#include "tensorflow/core/framework/types.pb.h"
|
||||||
|
#include "tensorflow/core/graph/algorithm.h"
|
||||||
#include "tensorflow/core/graph/node_builder.h"
|
#include "tensorflow/core/graph/node_builder.h"
|
||||||
#include "tensorflow/core/graph/testlib.h"
|
#include "tensorflow/core/graph/testlib.h"
|
||||||
#include "tensorflow/core/kernels/ops_testutil.h"
|
#include "tensorflow/core/kernels/ops_testutil.h"
|
||||||
@ -62,10 +63,14 @@ static void SliceHelper(int iters, int size) {
|
|||||||
.Input(test::graph::Constant(g, sizes))
|
.Input(test::graph::Constant(g, sizes))
|
||||||
.Attr("T", dt)
|
.Attr("T", dt)
|
||||||
.Finalize(g, &node));
|
.Finalize(g, &node));
|
||||||
|
FixupSourceAndSinkEdges(g);
|
||||||
|
|
||||||
testing::BytesProcessed(static_cast<int64>(iters) * kDim * size * sizeof(T));
|
testing::BytesProcessed(static_cast<int64>(iters) * kDim * size * sizeof(T));
|
||||||
testing::StartTiming();
|
testing::StartTiming();
|
||||||
test::Benchmark("cpu", g).Run(iters);
|
test::Benchmark("cpu", g, nullptr, nullptr, nullptr,
|
||||||
|
"SINGLE_THREADED_EXECUTOR")
|
||||||
|
.Run(iters);
|
||||||
|
|
||||||
testing::UseRealTime();
|
testing::UseRealTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user