Skip to content

Commit

Permalink
Merge branch 'master' into nccl-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyu1994 authored Dec 15, 2023
2 parents 839c375 + 2dfb9a4 commit 8eaf3ad
Show file tree
Hide file tree
Showing 94 changed files with 1,320 additions and 413 deletions.
3 changes: 1 addition & 2 deletions .ci/lint-cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ get_omp_pragmas_without_num_threads() {
--include='*.h' \
--include='*.hpp' \
'pragma omp parallel' \
| grep -v ' num_threads' \
| grep -v 'openmp_wrapper.h'
| grep -v ' num_threads'
}
PROBLEMATIC_LINES=$(
get_omp_pragmas_without_num_threads
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ file(
src/objective/*.cpp
src/network/*.cpp
src/treelearner/*.cpp
src/utils/*.cpp
if(USE_CUDA)
src/treelearner/*.cu
src/boosting/cuda/*.cpp
Expand Down
4 changes: 2 additions & 2 deletions R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Title: Light Gradient Boosting Machine
Version: ~~VERSION~~
Date: ~~DATE~~
Authors@R: c(
person("Yu", "Shi", email = "[email protected]", role = c("aut", "cre")),
person("Yu", "Shi", email = "[email protected]", role = c("aut")),
person("Guolin", "Ke", email = "[email protected]", role = c("aut")),
person("Damien", "Soukhavong", email = "[email protected]", role = c("aut")),
person("James", "Lamb", email="[email protected]", role = c("aut")),
person("James", "Lamb", email="[email protected]", role = c("aut", "cre")),
person("Qi", "Meng", role = c("aut")),
person("Thomas", "Finley", role = c("aut")),
person("Taifeng", "Wang", role = c("aut")),
Expand Down
2 changes: 2 additions & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ S3method(print,lgb.Booster)
S3method(set_field,lgb.Dataset)
S3method(slice,lgb.Dataset)
S3method(summary,lgb.Booster)
export(getLGBMthreads)
export(get_field)
export(lgb.Dataset)
export(lgb.Dataset.construct)
Expand All @@ -35,6 +36,7 @@ export(lgb.train)
export(lightgbm)
export(readRDS.lgb.Booster)
export(saveRDS.lgb.Booster)
export(setLGBMthreads)
export(set_field)
export(slice)
import(methods)
Expand Down
8 changes: 4 additions & 4 deletions R-package/R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,17 @@ cb_early_stop <- function(stopping_rounds, first_metric_only, verbose) {
}

# Extract callback names from the list of callbacks
callback.names <- function(cb_list) {
.callback_names <- function(cb_list) {
return(unlist(lapply(cb_list, attr, "name")))
}

add.cb <- function(cb_list, cb) {
.add_cb <- function(cb_list, cb) {

# Combine two elements
cb_list <- c(cb_list, cb)

# Set names of elements
names(cb_list) <- callback.names(cb_list = cb_list)
names(cb_list) <- .callback_names(cb_list = cb_list)

if ("cb_early_stop" %in% names(cb_list)) {

Expand All @@ -349,7 +349,7 @@ add.cb <- function(cb_list, cb) {

}

categorize.callbacks <- function(cb_list) {
.categorize_callbacks <- function(cb_list) {

# Check for pre-iteration or post-iteration
return(
Expand Down
46 changes: 29 additions & 17 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ Booster <- R6::R6Class(

if (!is.null(train_set)) {

if (!lgb.is.Dataset(train_set)) {
if (!.is_Dataset(train_set)) {
stop("lgb.Booster: Can only use lgb.Dataset as training data")
}
train_set_handle <- train_set$.__enclos_env__$private$get_handle()
params <- utils::modifyList(params, train_set$get_params())
params_str <- lgb.params2str(params = params)
params_str <- .params2str(params = params)
# Store booster handle
handle <- .Call(
LGBM_BoosterCreate_R
Expand Down Expand Up @@ -130,7 +130,7 @@ Booster <- R6::R6Class(
# Add validation data
add_valid = function(data, name) {

if (!lgb.is.Dataset(data)) {
if (!.is_Dataset(data)) {
stop("lgb.Booster.add_valid: Can only use lgb.Dataset as validation data")
}

Expand Down Expand Up @@ -167,7 +167,7 @@ Booster <- R6::R6Class(
params <- utils::modifyList(self$params, params)
}

params_str <- lgb.params2str(params = params)
params_str <- .params2str(params = params)

self$restore_handle()

Expand All @@ -193,7 +193,7 @@ Booster <- R6::R6Class(

if (!is.null(train_set)) {

if (!lgb.is.Dataset(train_set)) {
if (!.is_Dataset(train_set)) {
stop("lgb.Booster.update: Only can use lgb.Dataset as training data")
}

Expand Down Expand Up @@ -340,7 +340,7 @@ Booster <- R6::R6Class(
# Evaluate data on metrics
eval = function(data, name, feval = NULL) {

if (!lgb.is.Dataset(data)) {
if (!.is_Dataset(data)) {
stop("lgb.Booster.eval: Can only use lgb.Dataset to eval")
}

Expand Down Expand Up @@ -508,17 +508,17 @@ Booster <- R6::R6Class(
# NOTE: doing this here instead of in Predictor$predict() to keep
# Predictor$predict() as fast as possible
if (length(params) > 0L) {
params <- lgb.check.wrapper_param(
params <- .check_wrapper_param(
main_param_name = "predict_raw_score"
, params = params
, alternative_kwarg_value = rawscore
)
params <- lgb.check.wrapper_param(
params <- .check_wrapper_param(
main_param_name = "predict_leaf_index"
, params = params
, alternative_kwarg_value = predleaf
)
params <- lgb.check.wrapper_param(
params <- .check_wrapper_param(
main_param_name = "predict_contrib"
, params = params
, alternative_kwarg_value = predcontrib
Expand Down Expand Up @@ -586,7 +586,7 @@ Booster <- R6::R6Class(
, predcontrib
, start_iteration
, num_iteration
, lgb.params2str(params = params)
, .params2str(params = params)
)

private$fast_predict_config <- list(
Expand Down Expand Up @@ -622,7 +622,7 @@ Booster <- R6::R6Class(
},

check_null_handle = function() {
return(lgb.is.null.handle(private$handle))
return(.is_null_handle(private$handle))
},

restore_handle = function() {
Expand Down Expand Up @@ -917,6 +917,8 @@ NULL
#' the factor levels not being present in the output.
#' @examples
#' \donttest{
#' \dontshow{setLGBMthreads(2L)}
#' \dontshow{data.table::setDTthreads(1L)}
#' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train
#' dtrain <- lgb.Dataset(train$data, label = train$label)
Expand Down Expand Up @@ -959,7 +961,7 @@ predict.lgb.Booster <- function(object,
params = list(),
...) {

if (!lgb.is.Booster(x = object)) {
if (!.is_Booster(x = object)) {
stop("predict.lgb.Booster: object should be an ", sQuote("lgb.Booster"))
}

Expand Down Expand Up @@ -1082,6 +1084,8 @@ predict.lgb.Booster <- function(object,
#' \link{predict.lgb.Booster}.
#' @examples
#' \donttest{
#' \dontshow{setLGBMthreads(2L)}
#' \dontshow{data.table::setDTthreads(1L)}
#' library(lightgbm)
#' data(mtcars)
#' X <- as.matrix(mtcars[, -1L])
Expand Down Expand Up @@ -1114,7 +1118,7 @@ lgb.configure_fast_predict <- function(model,
num_iteration = NULL,
type = "response",
params = list()) {
if (!lgb.is.Booster(x = model)) {
if (!.is_Booster(x = model)) {
stop("lgb.configure_fast_predict: model should be an ", sQuote("lgb.Booster"))
}
if (type == "class") {
Expand Down Expand Up @@ -1160,7 +1164,7 @@ lgb.configure_fast_predict <- function(model,
print.lgb.Booster <- function(x, ...) {
# nolint start
handle <- x$.__enclos_env__$private$handle
handle_is_null <- lgb.is.null.handle(handle)
handle_is_null <- .is_null_handle(handle)

if (!handle_is_null) {
ntrees <- x$current_iter()
Expand Down Expand Up @@ -1224,6 +1228,8 @@ summary.lgb.Booster <- function(object, ...) {
#'
#' @examples
#' \donttest{
#' \dontshow{setLGBMthreads(2L)}
#' \dontshow{data.table::setDTthreads(1L)}
#' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train
#' dtrain <- lgb.Dataset(train$data, label = train$label)
Expand Down Expand Up @@ -1289,6 +1295,8 @@ lgb.load <- function(filename = NULL, model_str = NULL) {
#'
#' @examples
#' \donttest{
#' \dontshow{setLGBMthreads(2L)}
#' \dontshow{data.table::setDTthreads(1L)}
#' library(lightgbm)
#' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train
Expand Down Expand Up @@ -1316,7 +1324,7 @@ lgb.load <- function(filename = NULL, model_str = NULL) {
#' @export
lgb.save <- function(booster, filename, num_iteration = NULL) {

if (!lgb.is.Booster(x = booster)) {
if (!.is_Booster(x = booster)) {
stop("lgb.save: booster should be an ", sQuote("lgb.Booster"))
}

Expand Down Expand Up @@ -1346,6 +1354,8 @@ lgb.save <- function(booster, filename, num_iteration = NULL) {
#' @examples
#' \donttest{
#' library(lightgbm)
#' \dontshow{setLGBMthreads(2L)}
#' \dontshow{data.table::setDTthreads(1L)}
#' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train
#' dtrain <- lgb.Dataset(train$data, label = train$label)
Expand All @@ -1372,7 +1382,7 @@ lgb.save <- function(booster, filename, num_iteration = NULL) {
#' @export
lgb.dump <- function(booster, num_iteration = NULL) {

if (!lgb.is.Booster(x = booster)) {
if (!.is_Booster(x = booster)) {
stop("lgb.dump: booster should be an ", sQuote("lgb.Booster"))
}

Expand All @@ -1396,6 +1406,8 @@ lgb.dump <- function(booster, num_iteration = NULL) {
#'
#' @examples
#' \donttest{
#' \dontshow{setLGBMthreads(2L)}
#' \dontshow{data.table::setDTthreads(1L)}
#' # train a regression model
#' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train
Expand Down Expand Up @@ -1430,7 +1442,7 @@ lgb.dump <- function(booster, num_iteration = NULL) {
#' @export
lgb.get.eval.result <- function(booster, data_name, eval_name, iters = NULL, is_err = FALSE) {

if (!lgb.is.Booster(x = booster)) {
if (!.is_Booster(x = booster)) {
stop("lgb.get.eval.result: Can only use ", sQuote("lgb.Booster"), " to get eval result")
}

Expand Down
2 changes: 1 addition & 1 deletion R-package/R/lgb.DataProcessor.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DataProcessor <- R6::R6Class(
)
}
data_num_class <- length(self$factor_levels)
params <- lgb.check.wrapper_param(
params <- .check_wrapper_param(
main_param_name = "num_class"
, params = params
, alternative_kwarg_value = data_num_class
Expand Down
Loading

0 comments on commit 8eaf3ad

Please sign in to comment.