MCPcopy Create free account
hub / github.com/apache/singa / TEST

Function TEST

test/singa/test_operation_benchmark.cc:36–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35#ifdef USE_CUDNN
36TEST(OperationBenchmark, CrossEntropyFwd) {
37 auto cuda = std::make_shared<singa::CudaGPU>();
38 auto ctx = cuda->context(0);
39 int bs = 64;
40 int dim = 10;
41 vector<DataType> dtypes = {kFloat16, kFloat32};
42
43 Tensor t(Shape{bs}, cuda);
44 t.SetValue(0.0f);
45 t = t.AsType(kInt);
46
47 for (auto dtype : dtypes) {
48 Tensor p(Shape{bs, dim}, cuda, dtype);
49 Uniform(0.0f, 1.0f, &p);
50
51 high_resolution_clock::time_point t1 = high_resolution_clock::now();
52
53 for (int i = 0; i < 1000; ++i) {
54 auto l = CrossEntropyFwd(p, t);
55 cudaStreamSynchronize(cuda->context(0)->stream);
56 }
57
58 high_resolution_clock::time_point t2 = high_resolution_clock::now();
59 duration<double> time_span = duration_cast<duration<double>>(t2 - t1);
60 cout << " dtype " << dtype;
61 cout << " - " << time_span.count() << " sec";
62 cout << endl;
63 }
64}
65
66TEST(OperationBenchmark, Mult) {
67 auto cuda = std::make_shared<singa::CudaGPU>();

Callers

nothing calls this directly

Calls 9

CrossEntropyFwdFunction · 0.85
MultFunction · 0.85
CudnnConvHandleClass · 0.85
GpuConvForwardFunction · 0.85
contextMethod · 0.80
UniformFunction · 0.50
GaussianFunction · 0.50
SetValueMethod · 0.45
AsTypeMethod · 0.45

Tested by

no test coverage detected