Skip to content

Commit

Permalink
Merge pull request #3669 from OXPHOS/linalg_temp
Browse files Browse the repository at this point in the history
LinalgRefactor - remove HAVE_LINALG_LIB
  • Loading branch information
karlnapf committed Mar 2, 2017
2 parents 65effed + 3316f24 commit e4e6def
Show file tree
Hide file tree
Showing 22 changed files with 2 additions and 91 deletions.
4 changes: 0 additions & 4 deletions src/interfaces/modular/Kernel.i
Expand Up @@ -104,12 +104,10 @@ PROTOCOLS_CUSTOMKERNEL(CustomKernel, float32_t, "f\0", NPY_FLOAT32)
%rename(MultiquadricKernel) CMultiquadricKernel;
%rename(JensenShannonKernel) CJensenShannonKernel;

#ifdef HAVE_LINALG_LIB
%rename(ExponentialARDKernel) CExponentialARDKernel;
%rename(GaussianARDKernel) CGaussianARDKernel;

%rename(GaussianARDSparseKernel) CGaussianARDSparseKernel;
#endif

%rename(SubsequenceStringKernel) CSubsequenceStringKernel;
%rename(PeriodicKernel) CPeriodicKernel;
Expand Down Expand Up @@ -227,11 +225,9 @@ namespace shogun
%include <shogun/kernel/MultiquadricKernel.h>
%include <shogun/kernel/RationalQuadraticKernel.h>
%include <shogun/kernel/JensenShannonKernel.h>
#ifdef HAVE_LINALG_LIB
%include <shogun/kernel/ExponentialARDKernel.h>
%include <shogun/kernel/GaussianARDKernel.h>
%include <shogun/machine/gp/GaussianARDSparseKernel.h>
#endif
%include <shogun/kernel/string/SubsequenceStringKernel.h>
%include <shogun/kernel/PeriodicKernel.h>

Expand Down
2 changes: 0 additions & 2 deletions src/interfaces/modular/Kernel_includes.i
Expand Up @@ -76,9 +76,7 @@
#include <shogun/kernel/string/SubsequenceStringKernel.h>
#include <shogun/kernel/PeriodicKernel.h>
#include <shogun/kernel/LinearKernel.h>
#ifdef HAVE_LINALG_LIB
#include <shogun/kernel/ExponentialARDKernel.h>
#include <shogun/kernel/GaussianARDKernel.h>
#include <shogun/machine/gp/GaussianARDSparseKernel.h>
#endif
%}
12 changes: 0 additions & 12 deletions src/shogun/CMakeLists.txt
Expand Up @@ -231,22 +231,10 @@ SHOGUN_DEPENDENCIES(
VERSION ${VIENNACL_VERSION_MINIMUM}
CONFIG_FLAG HAVE_VIENNACL)

# Check if supported linear algebra backend is found
IF (HAVE_CXX0X OR HAVE_CXX11)
SET(HAVE_LINALG_LIB 1)
ELSE ()
MESSAGE (STATUS "LINALG uses c++11 features. Please use a supported compiler")
ENDIF ()

# Linear algebra default global backend setups
SET_LINALG_BACKEND(LINALG_DEFAULT_BACKEND GLOBAL)

# Linear algebra default module specific backend setup
# Core module
SET_LINALG_BACKEND(LINALG_CORE_LIB CORE)
# Reduction module
SET_LINALG_BACKEND(LINALG_REDUX_LIB REDUX)

# Linear solver module
SET_LINALG_BACKEND(LINALG_LINEAR_SOLVER_LIB LINSLV)

Expand Down
10 changes: 0 additions & 10 deletions src/shogun/clustering/KMeansBase.cpp
Expand Up @@ -18,10 +18,6 @@
#include <shogun/base/Parallel.h>
#include <shogun/mathematics/eigen3.h>

#ifdef HAVE_LINALG_LIB
#include <shogun/mathematics/linalg/linalg.h>
#endif

using namespace shogun;
using namespace Eigen;

Expand Down Expand Up @@ -160,13 +156,7 @@ void CKMeansBase::initialize_training(CFeatures* data)

/* if kmeans++ to be used */
if (use_kmeanspp)
{
#ifdef HAVE_LINALG_LIB
mus_initial=kmeanspp();
#else
SG_WARNING("LINALG library not available for KMeans++, resorting to random initialisation");
#endif
}

R=SGVector<float64_t>(k);

Expand Down
7 changes: 0 additions & 7 deletions src/shogun/kernel/CustomKernel.cpp
Expand Up @@ -18,12 +18,7 @@
#include <shogun/mathematics/linalg/LinalgNamespace.h>

using namespace shogun;

#ifdef HAVE_LINALG_LIB
#include <shogun/mathematics/linalg/linalg.h>

using namespace linalg;
#endif // HAVE_LINALG_LIB

void CCustomKernel::init()
{
Expand Down Expand Up @@ -161,7 +156,6 @@ bool CCustomKernel::init(CFeatures* l, CFeatures* r)
return init_normalizer();
}

#ifdef HAVE_LINALG_LIB
float64_t CCustomKernel::sum_symmetric_block(index_t block_begin,
index_t block_size, bool no_diag)
{
Expand Down Expand Up @@ -366,7 +360,6 @@ SGVector<float64_t> CCustomKernel::row_col_wise_sum_block(index_t

return sum;
}
#endif // HAVE_LINALG_LIB

void CCustomKernel::cleanup_custom()
{
Expand Down
3 changes: 0 additions & 3 deletions src/shogun/kernel/CustomKernel.h
Expand Up @@ -318,8 +318,6 @@ class CCustomKernel: public CKernel
return true;
}

#ifdef HAVE_LINALG_LIB

/**
* Overrides the sum_symmetric_block method of CKernel to compute the
* sum directly from the precomputed kernel matrix.
Expand Down Expand Up @@ -439,7 +437,6 @@ class CCustomKernel: public CKernel
index_t block_begin_row, index_t block_begin_col,
index_t block_size_row, index_t block_size_col,
bool no_diag=false);
#endif // HAVE_LINALG_LIB

/** Adds a row subset of indices on top of the current subsets (possibly
* subset of subset). Every call causes a new active index vector
Expand Down
7 changes: 1 addition & 6 deletions src/shogun/kernel/ExponentialARDKernel.cpp
Expand Up @@ -14,10 +14,7 @@
#include <shogun/features/DenseFeatures.h>
#include <shogun/mathematics/Math.h>
#include <shogun/mathematics/linalg/LinalgNamespace.h>

#ifdef HAVE_LINALG_LIB
#include <shogun/mathematics/linalg/linalg.h>
#endif

using namespace shogun;

Expand Down Expand Up @@ -67,7 +64,6 @@ SGVector<float64_t> CExponentialARDKernel::get_feature_vector(int32_t idx, CFeat

}

#ifdef HAVE_LINALG_LIB

void CExponentialARDKernel::set_weights(SGMatrix<float64_t> weights)
{
Expand Down Expand Up @@ -169,7 +165,7 @@ void CExponentialARDKernel::set_matrix_weights(SGMatrix<float64_t> weights)
m_ARD_type=KT_FULL;
index_t len=(2*m_weights_rows+1-m_weights_cols)*m_weights_cols/2;
m_log_weights=SGVector<float64_t>(len);

index_t offset=0;
for (int i=0; i<weights.num_cols && i<weights.num_rows; i++)
{
Expand Down Expand Up @@ -280,4 +276,3 @@ void CExponentialARDKernel::check_weight_gradient_index(index_t index)
index, m_log_weights.vlen);
}
}
#endif //HAVE_LINALG_LIB
2 changes: 0 additions & 2 deletions src/shogun/kernel/ExponentialARDKernel.h
Expand Up @@ -150,7 +150,6 @@ class CExponentialARDKernel: public CDotKernel
return CMath::exp(-distance(idx_a,idx_b));
}

#ifdef HAVE_LINALG_LIB
public:
/** constructor
*
Expand Down Expand Up @@ -250,7 +249,6 @@ class CExponentialARDKernel: public CDotKernel
*
*/
virtual void check_weight_gradient_index(index_t index);
#endif /* HAVE_LINALG_LIB */
};
}
#endif /* EXPONENTIALARDKERNEL_H */
3 changes: 0 additions & 3 deletions src/shogun/kernel/GaussianARDKernel.h
Expand Up @@ -93,7 +93,6 @@ class CGaussianARDKernel: public CExponentialARDKernel
*/
virtual float64_t distance(int32_t idx_a, int32_t idx_b);

#ifdef HAVE_LINALG_LIB
public:
/** constructor
*
Expand Down Expand Up @@ -205,8 +204,6 @@ class CGaussianARDKernel: public CExponentialARDKernel
virtual float64_t get_parameter_gradient_helper(const TParameter* param,
index_t index, int32_t idx_a, int32_t idx_b,
SGVector<float64_t> avec, SGVector<float64_t> bvec);

#endif /* HAVE_LINALG_LIB */
};
}
#endif /* _GAUSSIANARDKERNEL_H_ */
8 changes: 0 additions & 8 deletions src/shogun/lib/config.h.in
Expand Up @@ -43,17 +43,9 @@
#cmakedefine VIENNACL_WITH_OPENCL 1

/* for linear algebra global backend setups */
#cmakedefine HAVE_LINALG_LIB 1

#cmakedefine USE_EIGEN3_GLOBAL 1
#cmakedefine USE_VIENNACL_GLOBAL 1

#cmakedefine USE_EIGEN3_CORE 1
#cmakedefine USE_VIENNACL_CORE 1

#cmakedefine USE_EIGEN3_REDUX 1
#cmakedefine USE_VIENNACL_REDUX 1

#cmakedefine USE_EIGEN3_LINSLV 1
#cmakedefine USE_VIENNACL_LINSLV 1

Expand Down
3 changes: 0 additions & 3 deletions src/shogun/machine/gp/GaussianARDSparseKernel.cpp
Expand Up @@ -46,7 +46,6 @@ CGaussianARDSparseKernel::~CGaussianARDSparseKernel()
{
}

#ifdef HAVE_LINALG_LIB
using namespace Eigen;

CGaussianARDSparseKernel::CGaussianARDSparseKernel(int32_t size)
Expand Down Expand Up @@ -146,5 +145,3 @@ SGMatrix<float64_t> CGaussianARDSparseKernel::get_parameter_gradient(
return CGaussianARDKernel::get_parameter_gradient(param, index);
}
}
#endif /* HAVE_LINALG_LIB */

2 changes: 0 additions & 2 deletions src/shogun/machine/gp/GaussianARDSparseKernel.h
Expand Up @@ -71,7 +71,6 @@ class CGaussianARDSparseKernel: public CGaussianARDKernel
private:
void initialize_sparse_kernel();

#ifdef HAVE_LINALG_LIB
public:
/** constructor
*
Expand Down Expand Up @@ -115,7 +114,6 @@ class CGaussianARDSparseKernel: public CGaussianARDKernel
*/
virtual SGVector<float64_t> get_parameter_gradient_diagonal(
const TParameter* param, index_t index=-1);
#endif /* HAVE_LINALG_LIB */
};
}

Expand Down
Expand Up @@ -32,8 +32,6 @@
#ifndef SPECIAL_PURPOSE_H_
#define SPECIAL_PURPOSE_H_

#ifdef HAVE_LINALG_LIB

#include <shogun/mathematics/linalg/internal/implementation/SpecialPurpose.h>

namespace shogun
Expand Down Expand Up @@ -108,5 +106,4 @@ typename Matrix::Scalar squared_error(Matrix P, Matrix Q)
}

}
#endif // HAVE_LINALG_LIB
#endif // SPECIAL_PURPOSE_H_
Expand Up @@ -33,10 +33,7 @@
*/

#include <shogun/lib/config.h>
#ifdef HAVE_LINALG_LIB
#include <shogun/machine/gp/GaussianARDSparseKernel.h>
#endif


#include <shogun/labels/BinaryLabels.h>
#include <shogun/features/DenseFeatures.h>
Expand Down Expand Up @@ -3703,7 +3700,6 @@ TEST(GaussianProcessClassificationUsingSingleLaplaceWithNLOPT,get_variance_vecto



#ifdef HAVE_LINALG_LIB
TEST(GaussianProcessClassificationUsingSingleFITCLaplace,get_mean_vector)
{
index_t n=6;
Expand Down Expand Up @@ -4046,5 +4042,3 @@ TEST(GaussianProcessClassificationUsingSingleFITCLaplace,get_probabilities)
SG_UNREF(gpc);
SG_UNREF(latent_features_train);
}

#endif /* HAVE_LINALG_LIB */
2 changes: 0 additions & 2 deletions tests/unit/kernel/GaussianARDKernel_unittest.cc
Expand Up @@ -30,7 +30,6 @@

#include <shogun/lib/config.h>

#ifdef HAVE_LINALG_LIB
#include <shogun/lib/common.h>
#include <shogun/lib/SGVector.h>
#include <shogun/lib/SGMatrix.h>
Expand Down Expand Up @@ -730,4 +729,3 @@ TEST(GaussianARDKernel,get_parameter_gradient_diagonal)
SG_UNREF(features_train)
SG_UNREF(latent_features_train)
}
#endif /* HAVE_LINALG_LIB */
4 changes: 1 addition & 3 deletions tests/unit/machine/gp/FITCInferenceMethod_unittest.cc
Expand Up @@ -661,7 +661,7 @@ TEST(FITCInferenceMethod,get_marginal_likelihood_derivatives_sparse)
SG_UNREF(inf);
SG_UNREF(inducing_features_train);
}
#ifdef HAVE_LINALG_LIB

TEST(FITCInferenceMethod,get_marginal_likelihood_derivatives_for_ARD_kernel1)
{
index_t n=6;
Expand Down Expand Up @@ -1070,5 +1070,3 @@ TEST(FITCInferenceMethod,get_marginal_likelihood_derivatives_for_inducing_featur
SG_UNREF(inf);
SG_UNREF(latent_features_train);
}

#endif /* HAVE_LINALG_LIB */
2 changes: 0 additions & 2 deletions tests/unit/machine/gp/SingleFITCInference_unittest.cc
Expand Up @@ -30,7 +30,6 @@
*/

#include <shogun/lib/config.h>
#if defined(HAVE_LINALG_LIB)

#include <shogun/labels/RegressionLabels.h>
#include <shogun/features/DenseFeatures.h>
Expand Down Expand Up @@ -209,4 +208,3 @@ TEST(SingleFITCInference,set_kernel)

SG_UNREF(inf);
}
#endif /* HAVE_LINALG_LIB */
Expand Up @@ -31,7 +31,6 @@


#include <shogun/lib/config.h>
#if defined(HAVE_LINALG_LIB)
#include <shogun/labels/BinaryLabels.h>
#include <shogun/features/DenseFeatures.h>
#include <shogun/kernel/GaussianKernel.h>
Expand Down Expand Up @@ -466,5 +465,3 @@ TEST(SingleFITCLaplaceInferenceMethodWithLBFGS,get_marginal_likelihood_derivativ
SG_UNREF(inf);
SG_UNREF(latent_features_train);
}

#endif /* HAVE_LINALG_LIB */
Expand Up @@ -31,7 +31,6 @@


#include <shogun/lib/config.h>
#if defined(HAVE_LINALG_LIB)
#include <shogun/labels/BinaryLabels.h>
#include <shogun/features/DenseFeatures.h>
#include <shogun/kernel/GaussianKernel.h>
Expand Down Expand Up @@ -472,5 +471,3 @@ TEST(SingleFITCLaplaceInferenceMethod,get_marginal_likelihood_derivatives)
SG_UNREF(latent_features_train);
SG_UNREF(inf);
}

#endif /* HAVE_LINALG_LIB */
2 changes: 0 additions & 2 deletions tests/unit/machine/gp/VarDTCInferenceMethod_unittest.cc
Expand Up @@ -225,7 +225,6 @@ TEST(VarDTCInferenceMethod,get_marginal_likelihood_derivatives)
SG_UNREF(inducing_features_train);
}

#ifdef HAVE_LINALG_LIB
TEST(VarDTCInferenceMethod,get_marginal_likelihood_derivative_wrt_inducing_features)
{
float64_t rel_tolerance=1e-5;
Expand Down Expand Up @@ -333,4 +332,3 @@ TEST(VarDTCInferenceMethod,get_marginal_likelihood_derivative_wrt_inducing_featu
SG_UNREF(inf);
SG_UNREF(inducing_features_train);
}
#endif /* HAVE_LINALG_LIB */
3 changes: 0 additions & 3 deletions tests/unit/mathematics/linalg/SpecialPurpose_unittest.cc
Expand Up @@ -30,7 +30,6 @@

#include <shogun/lib/config.h>

#ifdef HAVE_LINALG_LIB
#include <shogun/mathematics/linalg/linalg.h>
#include <shogun/mathematics/Math.h>
#include <shogun/lib/SGMatrix.h>
Expand Down Expand Up @@ -317,5 +316,3 @@ TEST(SpecialPurpose, squared_error_viennacl_backend)
EXPECT_NEAR(se, linalg::special_purpose::squared_error<linalg::Backend::VIENNACL>(A, B), 1e-15);
}
#endif // HAVE_VIENNACL

#endif // HAVE_LINALG_LIB
2 changes: 0 additions & 2 deletions tests/unit/regression/GaussianProcessRegression_unittest.cc
Expand Up @@ -613,7 +613,6 @@ TEST(GaussianProcessRegression,var_dtc_regression)
SG_UNREF(inducing_features_train);
}

#ifdef HAVE_LINALG_LIB
TEST(GaussianProcessRegression,fitc_regression)
{
index_t n=6;
Expand Down Expand Up @@ -738,4 +737,3 @@ TEST(GaussianProcessRegression,fitc_regression)
SG_UNREF(latent_features_train);
SG_UNREF(gpr);
}
#endif /* HAVE_LINALG_LIB */

0 comments on commit e4e6def

Please sign in to comment.