MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / TearDown

Method TearDown

src/test/test_kernelmatrix.cpp:89–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87 }
88
89 void TearDown() override {
90 KernelMatrix *kernelMatrix = new KernelMatrix(dataSet.instances(), param);
91 kernelMatrix->get_rows(rows, kernel_rows);
92
93 //test diagonal elements
94 for (unsigned i = 0; i < kernelMatrix->diag().size(); ++i) {
95 float_type cpu_kernel = get_cpu_kernel(dataSet.instances(), i, i, param);
96 float_type gpu_kernel = kernelMatrix->diag().host_data()[i];
97 EXPECT_NEAR(gpu_kernel, cpu_kernel, 1e-4) << i;
98 }
99
100 //test get rows with index
101 for (unsigned i = 0; i < rows.size(); ++i) {
102 for (unsigned j = 0; j < kernelMatrix->n_instances(); ++j) {
103 float_type gpu_kernel = kernel_rows.host_data()[i * kernelMatrix->n_instances() + j];
104 float_type cpu_kernel = get_cpu_kernel(dataSet.instances(), rows.host_data()[i], j, param);
105 EXPECT_NEAR(gpu_kernel, cpu_kernel, 1e-4) << rows.host_data()[i] << "," << j;
106 }
107 }
108
109 //test get rows with instances
110 kernelMatrix->get_rows(instances, kernel_rows);
111
112 for (unsigned i = 0; i < n_rows; ++i) {
113 for (unsigned j = 0; j < kernelMatrix->n_instances(); ++j) {
114 float_type gpu_kernel = kernel_rows.host_data()[i * kernelMatrix->n_instances() + j];
115 float_type cpu_kernel = get_cpu_kernel(dataSet.instances(), i, j, param);
116 EXPECT_NEAR(gpu_kernel, cpu_kernel, 1e-4) << i << "," << j;
117 }
118 }
119 delete kernelMatrix;
120 }
121};
122
123TEST_F(KernelMatrixTest, test_rbf) {

Callers

nothing calls this directly

Calls 6

get_cpu_kernelFunction · 0.85
instancesMethod · 0.80
get_rowsMethod · 0.80
sizeMethod · 0.45
host_dataMethod · 0.45
n_instancesMethod · 0.45

Tested by

no test coverage detected