"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "060c681dbf79ab684c66a358156dfd96e47a16b9"
Commit 55cd6096 authored by Guolin Ke's avatar Guolin Ke
Browse files

update cmake to build library

parent 044f79aa
...@@ -21,6 +21,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fopenmp -O2 -std=c++11") ...@@ -21,6 +21,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fopenmp -O2 -std=c++11")
SET(LightGBM_HEADER_DIR ${PROJECT_SOURCE_DIR}/include) SET(LightGBM_HEADER_DIR ${PROJECT_SOURCE_DIR}/include)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
...@@ -67,10 +67,10 @@ DllExport int LGBM_CreateDatasetFromBinaryFile(const char* filename, ...@@ -67,10 +67,10 @@ DllExport int LGBM_CreateDatasetFromBinaryFile(const char* filename,
/*! /*!
* \brief create a dataset from CSR format * \brief create a dataset from CSR format
* \param indptr pointer to row headers * \param indptr pointer to row headers
* \param indptr_type 0:int_32 1:int_64 * \param indptr_type
* \param indices findex * \param indices findex
* \param data fvalue * \param data fvalue
* \param data_type 0 for float_32 1 for float_64 * \param data_type
* \param nindptr number of rows in the matix + 1 * \param nindptr number of rows in the matix + 1
* \param nelem number of nonzero elements in the matrix * \param nelem number of nonzero elements in the matrix
* \param num_col number of columns; when it's set to 0, then guess from data * \param num_col number of columns; when it's set to 0, then guess from data
...@@ -94,10 +94,10 @@ DllExport int LGBM_CreateDatasetFromCSR(const void* indptr, ...@@ -94,10 +94,10 @@ DllExport int LGBM_CreateDatasetFromCSR(const void* indptr,
/*! /*!
* \brief create a dataset from CSC format * \brief create a dataset from CSC format
* \param col_ptr pointer to col headers * \param col_ptr pointer to col headers
* \param col_ptr_type 0:int_32 1:int_64 * \param col_ptr_type
* \param indices findex * \param indices findex
* \param data fvalue * \param data fvalue
* \param data_type 0 for float_32 1 for float_64 * \param data_type
* \param ncol_ptr number of rows in the matix + 1 * \param ncol_ptr number of rows in the matix + 1
* \param nelem number of nonzero elements in the matrix * \param nelem number of nonzero elements in the matrix
* \param num_row number of rows; when it's set to 0, then guess from data * \param num_row number of rows; when it's set to 0, then guess from data
...@@ -121,7 +121,7 @@ DllExport int LGBM_CreateDatasetFromCSC(const void* col_ptr, ...@@ -121,7 +121,7 @@ DllExport int LGBM_CreateDatasetFromCSC(const void* col_ptr,
/*! /*!
* \brief create dataset from dense matrix * \brief create dataset from dense matrix
* \param data pointer to the data space * \param data pointer to the data space
* \param data_type 0 for float_32 1 for float_64 * \param data_type 0
* \param nrow number of rows * \param nrow number of rows
* \param ncol number columns * \param ncol number columns
* \param is_row_major 1 for row major, 0 for column major * \param is_row_major 1 for row major, 0 for column major
...@@ -302,10 +302,10 @@ DllExport int LGBM_BoosterGetPredict(BoosterHandle handle, ...@@ -302,10 +302,10 @@ DllExport int LGBM_BoosterGetPredict(BoosterHandle handle,
* \brief make prediction for an new data set * \brief make prediction for an new data set
* \param handle handle * \param handle handle
* \param indptr pointer to row headers * \param indptr pointer to row headers
* \param indptr_type 0:int_32 1:int_64 * \param indptr_type
* \param indices findex * \param indices findex
* \param data fvalue * \param data fvalue
* \param data_type 0:float_32 1:float64 * \param data_type
* \param nindptr number of rows in the matix + 1 * \param nindptr number of rows in the matix + 1
* \param nelem number of nonzero elements in the matrix * \param nelem number of nonzero elements in the matrix
* \param num_col number of columns; when it's set to 0, then guess from data * \param num_col number of columns; when it's set to 0, then guess from data
...@@ -334,7 +334,7 @@ DllExport int LGBM_BoosterPredictForCSR(BoosterHandle handle, ...@@ -334,7 +334,7 @@ DllExport int LGBM_BoosterPredictForCSR(BoosterHandle handle,
* \brief make prediction for an new data set * \brief make prediction for an new data set
* \param handle handle * \param handle handle
* \param data pointer to the data space * \param data pointer to the data space
* \param data_type 0:float_32 1:float64 * \param data_type
* \param nrow number of rows * \param nrow number of rows
* \param ncol number columns * \param ncol number columns
* \param is_row_major 1 for row major, 0 for column major * \param is_row_major 1 for row major, 0 for column major
...@@ -369,6 +369,8 @@ DllExport int LGBM_BoosterSaveModel(BoosterHandle handle, ...@@ -369,6 +369,8 @@ DllExport int LGBM_BoosterSaveModel(BoosterHandle handle,
// some help functions used to convert data
std::function<std::vector<double>(int row_idx)> std::function<std::vector<double>(int row_idx)>
RowFunctionFromDenseMatric(const void* data, int num_row, int num_col, int data_type, int is_row_major); RowFunctionFromDenseMatric(const void* data, int num_row, int num_col, int data_type, int is_row_major);
......
...@@ -14,6 +14,8 @@ AUX_SOURCE_DIRECTORY(./treelearner/ TREELEARNER_SRC) ...@@ -14,6 +14,8 @@ AUX_SOURCE_DIRECTORY(./treelearner/ TREELEARNER_SRC)
add_executable(lightgbm main.cpp ${APPLICATION_SRC} ${BOOSTING_SRC} ${IO_SRC} ${METRIC_SRC} ${OBJECTIVE_SRC} ${NETWORK_SRC} ${TREELEARNER_SRC}) add_executable(lightgbm main.cpp ${APPLICATION_SRC} ${BOOSTING_SRC} ${IO_SRC} ${METRIC_SRC} ${OBJECTIVE_SRC} ${NETWORK_SRC} ${TREELEARNER_SRC})
add_library(_lightgbm SHARED c_api.cpp ${APPLICATION_SRC} ${BOOSTING_SRC} ${IO_SRC} ${METRIC_SRC} ${OBJECTIVE_SRC} ${NETWORK_SRC} ${TREELEARNER_SRC})
if(USE_MPI) if(USE_MPI)
TARGET_LINK_LIBRARIES(lightgbm ${MPI_CXX_LIBRARIES}) TARGET_LINK_LIBRARIES(lightgbm ${MPI_CXX_LIBRARIES})
endif(USE_MPI) endif(USE_MPI)
......
...@@ -558,7 +558,7 @@ DllExport int LGBM_BoosterSaveModel(BoosterHandle handle, ...@@ -558,7 +558,7 @@ DllExport int LGBM_BoosterSaveModel(BoosterHandle handle,
return 0; return 0;
} }
// ---- start of some help functions
std::function<std::vector<double>(int row_idx)> std::function<std::vector<double>(int row_idx)>
RowFunctionFromDenseMatric(const void* data, int num_row, int num_col, int data_type, int is_row_major) { RowFunctionFromDenseMatric(const void* data, int num_row, int num_col, int data_type, int is_row_major) {
...@@ -609,6 +609,7 @@ RowFunctionFromDenseMatric(const void* data, int num_row, int num_col, int data_ ...@@ -609,6 +609,7 @@ RowFunctionFromDenseMatric(const void* data, int num_row, int num_col, int data_
} else { } else {
Log::Fatal("unknown data type in RowFunctionFromDenseMatric"); Log::Fatal("unknown data type in RowFunctionFromDenseMatric");
} }
return nullptr;
} }
std::function<std::vector<std::pair<int, double>>(int row_idx)> std::function<std::vector<std::pair<int, double>>(int row_idx)>
...@@ -660,6 +661,7 @@ RowPairFunctionFromDenseMatric(const void* data, int num_row, int num_col, int d ...@@ -660,6 +661,7 @@ RowPairFunctionFromDenseMatric(const void* data, int num_row, int num_col, int d
} else { } else {
Log::Fatal("unknown data type in RowPairFunctionFromDenseMatric"); Log::Fatal("unknown data type in RowPairFunctionFromDenseMatric");
} }
return nullptr;
} }
std::function<std::vector<std::pair<int, double>>(int idx)> std::function<std::vector<std::pair<int, double>>(int idx)>
...@@ -729,6 +731,7 @@ RowFunctionFromCSR(const void* indptr, int indptr_type, const int32_t* indices, ...@@ -729,6 +731,7 @@ RowFunctionFromCSR(const void* indptr, int indptr_type, const int32_t* indices,
} else { } else {
Log::Fatal("unknown data type in RowFunctionFromCSR"); Log::Fatal("unknown data type in RowFunctionFromCSR");
} }
return nullptr;
} }
std::function<std::vector<std::pair<int, double>>(int idx)> std::function<std::vector<std::pair<int, double>>(int idx)>
...@@ -798,6 +801,7 @@ ColumnFunctionFromCSC(const void* col_ptr, int col_ptr_type, const int32_t* indi ...@@ -798,6 +801,7 @@ ColumnFunctionFromCSC(const void* col_ptr, int col_ptr_type, const int32_t* indi
} else { } else {
Log::Fatal("unknown data type in ColumnFunctionFromCSC"); Log::Fatal("unknown data type in ColumnFunctionFromCSC");
} }
return nullptr;
} }
std::vector<double> SampleFromOneColumn(const std::vector<std::pair<int, double>>& data, const std::vector<size_t>& indices) { std::vector<double> SampleFromOneColumn(const std::vector<std::pair<int, double>>& data, const std::vector<size_t>& indices) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment