blob: 658f2282cf4617ea2349af5b34c86cb1e19a45be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <functional>
#include <memory>
#include <vector>
#include "tensorflow/core/common_runtime/kernel_benchmark_testlib.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/graph/testlib.h"
#include "tensorflow/core/graph/node_builder.h"
#include "tensorflow/core/kernels/ops_testutil.h"
#include "tensorflow/core/kernels/ops_util.h"
#include "tensorflow/core/platform/test_benchmark.h"
#include "tensorflow/core/public/tensor.h"
#include <gtest/gtest.h>
#include "tensorflow/core/lib/core/status_test_util.h"
namespace tensorflow {
namespace {
static void BM_Unique(int iters, int dim) {
testing::StopTiming();
RequireDefaultOps();
Graph* g = new Graph(OpRegistry::Global());
Tensor input(DT_INT32, TensorShape({dim}));
input.flat<int32>().setRandom();
Node* node;
TF_CHECK_OK(NodeBuilder(g->NewName("n"), "Unique")
.Input(test::graph::Constant(g, input))
.Attr("T", DT_INT32)
.Finalize(g, &node));
testing::BytesProcessed(static_cast<int64>(iters) * dim * sizeof(int32));
testing::UseRealTime();
testing::StartTiming();
test::Benchmark("cpu", g).Run(iters);
}
BENCHMARK(BM_Unique)
->Arg(32)
->Arg(256)
->Arg(1024)
->Arg(4 * 1024)
->Arg(16 * 1024)
->Arg(64 * 1024)
->Arg(256 * 1024);
} // namespace
} // namespace tensorflow
|