Final performance tuning on the dense version of the algorithm
This commit is contained in:
@@ -788,8 +788,8 @@ class DenseLpr {
|
||||
* for a given query and a reference node pair.
|
||||
*/
|
||||
void SqdistAndKernelRanges_(QueryTree *qnode, ReferenceTree *rnode,
|
||||
DRange &dsqd_range, DRange &kernel_value_range,
|
||||
Vector *furthest_point_in_qnode);
|
||||
DRange &dsqd_range,
|
||||
DRange &kernel_value_range);
|
||||
|
||||
/** @brief Resets bounds relevant to the given query point.
|
||||
*/
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
template<typename TKernel, typename TPruneRule>
|
||||
void DenseLpr<TKernel, TPruneRule>::SqdistAndKernelRanges_
|
||||
(QueryTree *qnode, ReferenceTree *rnode, DRange &dsqd_range,
|
||||
DRange &kernel_value_range, Vector *furthest_point_in_qnode) {
|
||||
DRange &kernel_value_range) {
|
||||
|
||||
furthest_point_in_qnode->Init(dimension_);
|
||||
dsqd_range = qnode->bound().RangeDistanceSq(rnode->bound());
|
||||
kernel_value_range = kernel_.RangeUnnormOnSq(dsqd_range);
|
||||
}
|
||||
@@ -425,9 +424,7 @@ void DenseLpr<TKernel, TPruneRule>::DualtreeLprCanonical_
|
||||
weight_diagram_numerator_de.Init(row_length_, row_length_);
|
||||
|
||||
// Compute distance ranges and kernel ranges first.
|
||||
Vector furthest_point_in_qnode;
|
||||
SqdistAndKernelRanges_(qnode, rnode, dsqd_range, kernel_value_range,
|
||||
&furthest_point_in_qnode);
|
||||
SqdistAndKernelRanges_(qnode, rnode, dsqd_range, kernel_value_range);
|
||||
|
||||
// Try finite difference pruning first
|
||||
if(TPruneRule::Prunable
|
||||
@@ -470,7 +467,8 @@ void DenseLpr<TKernel, TPruneRule>::DualtreeLprCanonical_
|
||||
// moments if the maximum distance between the two nodes is within
|
||||
// the bandwidth! This if-statement does not apply to the Gaussian
|
||||
// kernel, so I need to fix in the future!
|
||||
if(kernel_.bandwidth_sq() >= dsqd_range.hi) {
|
||||
if(kernel_.bandwidth_sq() >= dsqd_range.hi &&
|
||||
rnode->count() > dimension_ * dimension_) {
|
||||
|
||||
for(index_t j = 0; j < row_length_; j++) {
|
||||
|
||||
|
||||
@@ -88,7 +88,8 @@ class RelativePruneLpr {
|
||||
(relative_error * new_denominator_norm_l -
|
||||
qnode->stat().denominator_used_error_) /
|
||||
(denominator_total_alloc_error - qnode->stat().denominator_n_pruned_);
|
||||
|
||||
|
||||
/*
|
||||
// Refine the bound using the new info for the weight diagram
|
||||
// numerator matrix.
|
||||
la::AddOverwrite(qnode->stat().postponed_weight_diagram_numerator_l_,
|
||||
@@ -101,6 +102,7 @@ class RelativePruneLpr {
|
||||
(relative_error * new_weight_diagram_numerator_norm_l -
|
||||
qnode->stat().weight_diagram_numerator_used_error_) /
|
||||
(denominator_total_alloc_error - qnode->stat().denominator_n_pruned_);
|
||||
*/
|
||||
|
||||
// this is error per each query/reference pair for a fixed query
|
||||
// for the numerator and the denominator used for computing the
|
||||
@@ -109,7 +111,7 @@ class RelativePruneLpr {
|
||||
|
||||
// This is the error per each query/reference pair for a fixed
|
||||
// query for the weight diagram numerator matrix approximation.
|
||||
double squared_kernel_error = 0.5 * squared_kernel_value_range.width();
|
||||
//double squared_kernel_error = 0.5 * squared_kernel_value_range.width();
|
||||
|
||||
// This is total norm error for each query point for
|
||||
// approximating the B^T W(q) Y vector.
|
||||
@@ -123,18 +125,18 @@ class RelativePruneLpr {
|
||||
(rnode->stat().sum_data_outer_products_error_norm_);
|
||||
denominator_n_pruned = rnode->stat().sum_data_outer_products_alloc_norm_;
|
||||
|
||||
/*
|
||||
// The total norm error for each query point for approximating
|
||||
// the B^T W(q)^2 B matrix.
|
||||
weight_diagram_numerator_used_error = squared_kernel_error *
|
||||
(rnode->stat().sum_data_outer_products_error_norm_);
|
||||
*/
|
||||
|
||||
// Check pruning condition. Note that this pruning criterion
|
||||
// does not enforce error directly on the weight diagram
|
||||
// computation.
|
||||
return (numerator_used_error <= numerator_allowed_err &&
|
||||
denominator_used_error <= denominator_allowed_err &&
|
||||
weight_diagram_numerator_used_error <=
|
||||
weight_diagram_numerator_allowed_err);
|
||||
denominator_used_error <= denominator_allowed_err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user