diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 4efe658b7f45..195fd5f1c8f1 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -39,7 +39,7 @@ jobs: This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. - # what shoulld the locking status be? + # what should the locking status be? issue-lock-reason: 'resolved' pr-lock-reason: 'resolved' process-only: 'issues, prs' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c8732a01416..8ab55d9dd3b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,3 +35,9 @@ repos: - id: ruff-format args: ["--config", "python-package/pyproject.toml"] types_or: [python, jupyter] + - repo: https://github.com/crate-ci/typos + rev: v1.23.2 + hooks: + - id: typos + args: ["--force-exclude"] + exclude: (\.gitignore$)|(^\.editorconfig$) diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 000000000000..6dc2c2c97529 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,21 @@ +default.extend-ignore-re = [ + "/Ot", + "mis-alignment", + "mis-spelled", + "posix-seh-rt", +] + +[default.extend-words] +MAPE = "MAPE" +datas = "datas" +interprete = "interprete" +mape = "mape" +splitted = "splitted" + +[default.extend-identifiers] +ERRORs = "ERRORs" +GAM = "GAM" +ND24s = "ND24s" +WARNINGs = "WARNINGs" +fullset = "fullset" +thess = "thess" diff --git a/CMakeLists.txt b/CMakeLists.txt index 982535b7258c..5f3fe5c59e5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ option(USE_SWIG "Enable SWIG to generate Java API" OFF) option(USE_TIMETAG "Set to ON to output time costs" OFF) option(USE_CUDA "Enable CUDA-accelerated training " OFF) option(USE_DEBUG "Set to ON for Debug mode" OFF) -option(USE_SANITIZER "Use santizer flags" OFF) +option(USE_SANITIZER "Use sanitizer flags" OFF) option(USE_HOMEBREW_FALLBACK "(macOS-only) also look in 'brew --prefix' for libraries (e.g. OpenMP)" ON) set( ENABLED_SANITIZERS diff --git a/R-package/R/lgb.Booster.R b/R-package/R/lgb.Booster.R index a13516ff6569..85a91b1ce058 100644 --- a/R-package/R/lgb.Booster.R +++ b/R-package/R/lgb.Booster.R @@ -1114,7 +1114,7 @@ predict.lgb.Booster <- function(object, #' #' Requesting a different prediction type or passing parameters to \link{predict.lgb.Booster} #' will cause it to ignore the fast-predict configuration and take the slow route instead -#' (but be aware that an existing configuration might not always be overriden by supplying +#' (but be aware that an existing configuration might not always be overridden by supplying #' different parameters or prediction type, so make sure to check that the output is what #' was expected when a prediction is to be made on a single row for something different than #' what is configured). @@ -1128,7 +1128,7 @@ predict.lgb.Booster <- function(object, #' and as such, this function will produce an error if passing \code{csr=TRUE} and #' \code{type = "contrib"} together. #' @inheritParams lgb_predict_shared_params -#' @param model LighGBM model object (class \code{lgb.Booster}). +#' @param model LightGBM model object (class \code{lgb.Booster}). #' #' \bold{The object will be modified in-place}. #' @param csr Whether the prediction function is going to be called on sparse CSR inputs. diff --git a/R-package/R/lgb.importance.R b/R-package/R/lgb.importance.R index 7c76131f4f53..d60507cf00d4 100644 --- a/R-package/R/lgb.importance.R +++ b/R-package/R/lgb.importance.R @@ -9,7 +9,7 @@ #' \item{\code{Feature}: Feature names in the model.} #' \item{\code{Gain}: The total gain of this feature's splits.} #' \item{\code{Cover}: The number of observation related to this feature.} -#' \item{\code{Frequency}: The number of times a feature splited in trees.} +#' \item{\code{Frequency}: The number of times a feature split in trees.} #' } #' #' @examples diff --git a/R-package/R/lgb.model.dt.tree.R b/R-package/R/lgb.model.dt.tree.R index db4ef955f866..ac1b2f9aaf14 100644 --- a/R-package/R/lgb.model.dt.tree.R +++ b/R-package/R/lgb.model.dt.tree.R @@ -10,7 +10,7 @@ #' \emph{New in version 4.4.0} #' #' @return -#' A \code{data.table} with detailed information about model trees' nodes and leafs. +#' A \code{data.table} with detailed information about model trees' nodes and leaves. #' #' The columns of the \code{data.table} are: #' diff --git a/R-package/R/lightgbm.R b/R-package/R/lightgbm.R index efa593ffe12f..6cb4eebd8baf 100644 --- a/R-package/R/lightgbm.R +++ b/R-package/R/lightgbm.R @@ -139,7 +139,7 @@ NULL #' system, but be aware that getting the number of cores detected correctly requires package #' \code{RhpcBLASctl} to be installed. #' -#' This parameter gets overriden by \code{num_threads} and its aliases under \code{params} +#' This parameter gets overridden by \code{num_threads} and its aliases under \code{params} #' if passed there. #' #' \emph{New in version 4.0.0} diff --git a/R-package/demo/cross_validation.R b/R-package/demo/cross_validation.R index 0324f83f2da9..9f74ef7f4b2a 100644 --- a/R-package/demo/cross_validation.R +++ b/R-package/demo/cross_validation.R @@ -51,7 +51,7 @@ logregobj <- function(preds, dtrain) { # User-defined evaluation function returns a pair (metric_name, result, higher_better) # NOTE: when you do customized loss function, the default prediction value is margin -# This may make built-in evalution metric calculate wrong results +# This may make built-in evaluation metric calculate wrong results # For example, we are doing logistic loss, the prediction is score before logistic transformation # Keep this in mind when you use the customization, and maybe you need write customized evaluation function evalerror <- function(preds, dtrain) { diff --git a/R-package/demo/early_stopping.R b/R-package/demo/early_stopping.R index 6ca214c5ac7b..4435dd1b09b6 100644 --- a/R-package/demo/early_stopping.R +++ b/R-package/demo/early_stopping.R @@ -29,7 +29,7 @@ logregobj <- function(preds, dtrain) { # User-defined evaluation function returns a pair (metric_name, result, higher_better) # NOTE: when you do customized loss function, the default prediction value is margin -# This may make built-in evalution metric calculate wrong results +# This may make built-in evaluation metric calculate wrong results # For example, we are doing logistic loss, the prediction is score before logistic transformation # The built-in evaluation error assumes input is after logistic transformation # Keep this in mind when you use the customization, and maybe you need write customized evaluation function diff --git a/R-package/man/lgb.configure_fast_predict.Rd b/R-package/man/lgb.configure_fast_predict.Rd index e02600451df5..9cd4339bdced 100644 --- a/R-package/man/lgb.configure_fast_predict.Rd +++ b/R-package/man/lgb.configure_fast_predict.Rd @@ -14,7 +14,7 @@ lgb.configure_fast_predict( ) } \arguments{ -\item{model}{LighGBM model object (class \code{lgb.Booster}). +\item{model}{LightGBM model object (class \code{lgb.Booster}). \bold{The object will be modified in-place}.} @@ -98,7 +98,7 @@ Calling this function multiple times with different parameters might not overrid Requesting a different prediction type or passing parameters to \link{predict.lgb.Booster} will cause it to ignore the fast-predict configuration and take the slow route instead - (but be aware that an existing configuration might not always be overriden by supplying + (but be aware that an existing configuration might not always be overridden by supplying different parameters or prediction type, so make sure to check that the output is what was expected when a prediction is to be made on a single row for something different than what is configured). diff --git a/R-package/man/lgb.importance.Rd b/R-package/man/lgb.importance.Rd index 79cb82f5d8ef..5099643112be 100644 --- a/R-package/man/lgb.importance.Rd +++ b/R-package/man/lgb.importance.Rd @@ -17,7 +17,7 @@ For a tree model, a \code{data.table} with the following columns: \item{\code{Feature}: Feature names in the model.} \item{\code{Gain}: The total gain of this feature's splits.} \item{\code{Cover}: The number of observation related to this feature.} - \item{\code{Frequency}: The number of times a feature splited in trees.} + \item{\code{Frequency}: The number of times a feature split in trees.} } } \description{ diff --git a/R-package/man/lgb.model.dt.tree.Rd b/R-package/man/lgb.model.dt.tree.Rd index ecfee17332f5..df36b6a94f42 100644 --- a/R-package/man/lgb.model.dt.tree.Rd +++ b/R-package/man/lgb.model.dt.tree.Rd @@ -18,7 +18,7 @@ lgb.model.dt.tree(model, num_iteration = NULL, start_iteration = 1L) \emph{New in version 4.4.0}} } \value{ -A \code{data.table} with detailed information about model trees' nodes and leafs. +A \code{data.table} with detailed information about model trees' nodes and leaves. The columns of the \code{data.table} are: diff --git a/R-package/man/lightgbm.Rd b/R-package/man/lightgbm.Rd index 90cb3166bf5c..376a6d03a6b1 100644 --- a/R-package/man/lightgbm.Rd +++ b/R-package/man/lightgbm.Rd @@ -93,7 +93,7 @@ set to the iteration number of the best iteration.} system, but be aware that getting the number of cores detected correctly requires package \code{RhpcBLASctl} to be installed. - This parameter gets overriden by \code{num_threads} and its aliases under \code{params} + This parameter gets overridden by \code{num_threads} and its aliases under \code{params} if passed there. \emph{New in version 4.0.0}} diff --git a/R-package/tests/testthat/test_basic.R b/R-package/tests/testthat/test_basic.R index ed477a42c00b..f5339cd969b2 100644 --- a/R-package/tests/testthat/test_basic.R +++ b/R-package/tests/testthat/test_basic.R @@ -9,7 +9,7 @@ set.seed(708L) # to an accumulator then returns the current value. # This is used to mock the situation where an evaluation # metric increases every iteration -ACCUMULATOR_NAME <- "INCREASING_METRIC_ACUMULATOR" +ACCUMULATOR_NAME <- "INCREASING_METRIC_ACCUMULATOR" assign(x = ACCUMULATOR_NAME, value = 0.0, envir = .GlobalEnv) .increasing_metric <- function(preds, dtrain) { @@ -1777,7 +1777,7 @@ test_that("lgb.train() works with early stopping for regression with a metric th , early_stopping_rounds + 1L ) - # Booster should understand thatt all three of these metrics should be minimized + # Booster should understand that all three of these metrics should be minimized eval_info <- bst$.__enclos_env__$private$get_eval_info() expect_identical(eval_info, c("mape", "rmse", "l1")) expect_identical( diff --git a/R-package/tests/testthat/test_custom_objective.R b/R-package/tests/testthat/test_custom_objective.R index 2c10b9d571dc..a1baf0067c4a 100644 --- a/R-package/tests/testthat/test_custom_objective.R +++ b/R-package/tests/testthat/test_custom_objective.R @@ -14,7 +14,7 @@ logregobj <- function(preds, dtrain) { # User-defined evaluation function returns a pair (metric_name, result, higher_better) # NOTE: when you do customized loss function, the default prediction value is margin -# This may make built-in evalution metric calculate wrong results +# This may make built-in evaluation metric calculate wrong results # Keep this in mind when you use the customization, and maybe you need write customized evaluation function evalerror <- function(preds, dtrain) { labels <- get_field(dtrain, "label") diff --git a/R-package/tests/testthat/test_lgb.interprete.R b/R-package/tests/testthat/test_lgb.interprete.R index 322a80a55bc5..cfcd1c942f31 100644 --- a/R-package/tests/testthat/test_lgb.interprete.R +++ b/R-package/tests/testthat/test_lgb.interprete.R @@ -5,7 +5,7 @@ log(x / (1.0 - x)) } -test_that("lgb.intereprete works as expected for binary classification", { +test_that("lgb.interprete works as expected for binary classification", { data(agaricus.train, package = "lightgbm") train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) diff --git a/R-package/tests/testthat/test_lgb.plot.interpretation.R b/R-package/tests/testthat/test_lgb.plot.interpretation.R index 6cba9927942a..e8a021fc7237 100644 --- a/R-package/tests/testthat/test_lgb.plot.interpretation.R +++ b/R-package/tests/testthat/test_lgb.plot.interpretation.R @@ -5,7 +5,7 @@ log(x / (1.0 - x)) } -test_that("lgb.plot.interepretation works as expected for binary classification", { +test_that("lgb.plot.interpretation works as expected for binary classification", { data(agaricus.train, package = "lightgbm") train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) @@ -57,7 +57,7 @@ test_that("lgb.plot.interepretation works as expected for binary classification" expect_null(plot_res) }) -test_that("lgb.plot.interepretation works as expected for multiclass classification", { +test_that("lgb.plot.interpretation works as expected for multiclass classification", { data(iris) # We must convert factors to numeric diff --git a/cmake/Sanitizer.cmake b/cmake/Sanitizer.cmake index a3768effac0d..f99048476d8b 100644 --- a/cmake/Sanitizer.cmake +++ b/cmake/Sanitizer.cmake @@ -18,7 +18,7 @@ macro(enable_sanitizer sanitizer) set(SAN_COMPILE_FLAGS "${SAN_COMPILE_FLAGS} -fsanitize=undefined -fno-sanitize-recover=undefined") else() - message(FATAL_ERROR "Santizer ${sanitizer} not supported.") + message(FATAL_ERROR "Sanitizer ${sanitizer} not supported.") endif() endmacro() diff --git a/docker/README.md b/docker/README.md index 7e9e3276dd33..8f57dc4699ec 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,9 +8,9 @@ These builds of LightGBM all train on the CPU. For GPU-enabled builds, see [the Follow the general installation instructions [on the Docker site](https://docs.docker.com/install/): -* [macOS](https://docs.docker.com/docker-for-mac/install/) -* [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/) -* [Windows](https://docs.docker.com/docker-for-windows/install/) +- [macOS](https://docs.docker.com/docker-for-mac/install/) +- [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/) +- [Windows](https://docs.docker.com/docker-for-windows/install/) ## Using CLI Version of LightGBM via Docker @@ -55,7 +55,7 @@ After this runs, a LightGBM model can be found at `LightGBM-CLI-model.txt`. For more details on how to configure and use the LightGBM CLI, see https://lightgbm.readthedocs.io/en/latest/Quick-Start.html. -## Running the Python-package Сontainer +## Running the Python-package Container Build an image with the LightGBM Python package installed. @@ -114,7 +114,7 @@ docker run \ python ``` -## Running the R-package Сontainer +## Running the R-package Container Build an image with the LightGBM R package installed. diff --git a/docs/_static/js/script.js b/docs/_static/js/script.js index 107a6a4969a3..a16908c298f6 100644 --- a/docs/_static/js/script.js +++ b/docs/_static/js/script.js @@ -24,7 +24,7 @@ $(function() { /* Collapse specified sections in the installation guide */ if(window.location.pathname.toLocaleLowerCase().indexOf('installation-guide') != -1) { $('').appendTo('body'); - var collapsable = [ + var collapsible = [ '#build-threadless-version-not-recommended', '#build-mpi-version', '#build-gpu-version', @@ -32,7 +32,7 @@ $(function() { '#build-java-wrapper', '#build-c-unit-tests' ]; - $.each(collapsable, function(_, val) { + $.each(collapsible, function(_, val) { var header = val + ' > :header:first'; var content = val + ' :not(:header:first)'; $(header).addClass('closed'); diff --git a/examples/lambdarank/train.conf b/examples/lambdarank/train.conf index 2aa2113b40d4..f007dcd6fe66 100644 --- a/examples/lambdarank/train.conf +++ b/examples/lambdarank/train.conf @@ -64,7 +64,7 @@ num_leaves = 31 # alias: tree tree_learner = serial -# number of threads for multi-threading. One thread will use one CPU, defalut is setted to #cpu. +# number of threads for multi-threading. One thread will use one CPU, default is set to #cpu. # num_threads = 8 # feature sub-sample, will random select 80% feature to train on each iteration diff --git a/examples/regression/train.conf b/examples/regression/train.conf index cd910af61dcf..992bc6c9ab53 100644 --- a/examples/regression/train.conf +++ b/examples/regression/train.conf @@ -20,7 +20,7 @@ objective = regression # binary_error metric = l2 -# frequence for metric output +# frequency for metric output metric_freq = 1 # true if need output metric for training data, alias: tranining_metric, train_metric @@ -36,12 +36,12 @@ max_bin = 255 # forcedbins_filename = forced_bins.json # training data -# if exsting weight file, should name to "regression.train.weight" +# if existing weight file, should name to "regression.train.weight" # alias: train_data, train data = regression.train # validation data, support multi validation data, separated by ',' -# if exsting weight file, should name to "regression.test.weight" +# if existing weight file, should name to "regression.test.weight" # alias: valid, test, test_data, valid_data = regression.test @@ -62,7 +62,7 @@ num_leaves = 31 # alias: tree tree_learner = serial -# number of threads for multi-threading. One thread will use one CPU, default is setted to #cpu. +# number of threads for multi-threading. One thread will use one CPU, default is set to #cpu. # num_threads = 8 # feature sub-sample, will random select 80% feature to train on each iteration @@ -72,7 +72,7 @@ feature_fraction = 0.9 # Support bagging (data sub-sample), will perform bagging every 5 iterations bagging_freq = 5 -# Bagging farction, will random select 80% data on bagging +# Bagging fraction, will random select 80% data on bagging # alias: sub_row bagging_fraction = 0.8 diff --git a/include/LightGBM/cuda/cuda_algorithms.hpp b/include/LightGBM/cuda/cuda_algorithms.hpp index f79fc57e4f42..abda07b1582f 100644 --- a/include/LightGBM/cuda/cuda_algorithms.hpp +++ b/include/LightGBM/cuda/cuda_algorithms.hpp @@ -115,7 +115,7 @@ __device__ __forceinline__ T ShuffleReduceSumWarp(T value, const data_size_t len return value; } -// reduce values from an 1-dimensional block (block size must be no greather than 1024) +// reduce values from an 1-dimensional block (block size must be no greater than 1024) template __device__ __forceinline__ T ShuffleReduceSum(T value, T* shared_mem_buffer, const size_t len) { const uint32_t warpLane = threadIdx.x % warpSize; @@ -145,7 +145,7 @@ __device__ __forceinline__ T ShuffleReduceMaxWarp(T value, const data_size_t len return value; } -// reduce values from an 1-dimensional block (block size must be no greather than 1024) +// reduce values from an 1-dimensional block (block size must be no greater than 1024) template __device__ __forceinline__ T ShuffleReduceMax(T value, T* shared_mem_buffer, const size_t len) { const uint32_t warpLane = threadIdx.x % warpSize; @@ -196,7 +196,7 @@ __device__ __forceinline__ T ShuffleReduceMinWarp(T value, const data_size_t len return value; } -// reduce values from an 1-dimensional block (block size must be no greather than 1024) +// reduce values from an 1-dimensional block (block size must be no greater than 1024) template __device__ __forceinline__ T ShuffleReduceMin(T value, T* shared_mem_buffer, const size_t len) { const uint32_t warpLane = threadIdx.x % warpSize; diff --git a/include/LightGBM/dataset.h b/include/LightGBM/dataset.h index 220a1f9f009c..ef214b7cd89d 100644 --- a/include/LightGBM/dataset.h +++ b/include/LightGBM/dataset.h @@ -376,7 +376,7 @@ class Metadata { std::vector query_boundaries_; /*! \brief Query weights */ std::vector query_weights_; - /*! \brief Number of querys */ + /*! \brief Number of queries */ data_size_t num_queries_; /*! \brief Number of Initial score, used to check correct weight file */ int64_t num_init_score_; diff --git a/include/LightGBM/utils/common.h b/include/LightGBM/utils/common.h index 6c3ebf5d0096..67bc07b0ecd5 100644 --- a/include/LightGBM/utils/common.h +++ b/include/LightGBM/utils/common.h @@ -925,11 +925,11 @@ class AlignmentAllocator { inline ~AlignmentAllocator() throw() {} - inline pointer adress(reference r) { + inline pointer address(reference r) { return &r; } - inline const_pointer adress(const_reference r) const { + inline const_pointer address(const_reference r) const { return &r; } diff --git a/include/LightGBM/utils/random.h b/include/LightGBM/utils/random.h index 6f89f935b310..eb115ea96644 100644 --- a/include/LightGBM/utils/random.h +++ b/include/LightGBM/utils/random.h @@ -22,9 +22,9 @@ class Random { */ Random() { std::random_device rd; - auto genrator = std::mt19937(rd()); + auto generator = std::mt19937(rd()); std::uniform_int_distribution distribution(0, x); - x = distribution(genrator); + x = distribution(generator); } /*! * \brief Constructor, with specific seed diff --git a/python-package/lightgbm/basic.py b/python-package/lightgbm/basic.py index 194d9ca6c5b0..75b84066f8b0 100644 --- a/python-package/lightgbm/basic.py +++ b/python-package/lightgbm/basic.py @@ -3509,7 +3509,7 @@ def add_features_from(self, other: "Dataset") -> "Dataset": _log_warning(err_msg) self.feature_name = self.get_feature_name() _log_warning( - "Reseting categorical features.\n" + "Resetting categorical features.\n" "You can set new categorical features via ``set_categorical_feature`` method" ) self.categorical_feature = "auto" diff --git a/python-package/lightgbm/dask.py b/python-package/lightgbm/dask.py index e15979bc40db..dcdacba7366c 100644 --- a/python-package/lightgbm/dask.py +++ b/python-package/lightgbm/dask.py @@ -967,7 +967,7 @@ def _extract(items: List[Any], i: int) -> Any: out[i].append(part) # by default, dask.array.concatenate() concatenates sparse arrays into a COO matrix - # the code below is used instead to ensure that the sparse type is preserved during concatentation + # the code below is used instead to ensure that the sparse type is preserved during concatenation if isinstance(pred_meta, ss.csr_matrix): concat_fn = partial(ss.vstack, format="csr") elif isinstance(pred_meta, ss.csc_matrix): diff --git a/src/boosting/gbdt_model_text.cpp b/src/boosting/gbdt_model_text.cpp index 27be5afe066e..e8b6dd2332ef 100644 --- a/src/boosting/gbdt_model_text.cpp +++ b/src/boosting/gbdt_model_text.cpp @@ -545,17 +545,17 @@ bool GBDT::LoadModelFromString(const char* buffer, size_t len) { } } else { std::vector tree_sizes = CommonC::StringToArray(key_vals["tree_sizes"].c_str(), ' '); - std::vector tree_boundries(tree_sizes.size() + 1, 0); + std::vector tree_boundaries(tree_sizes.size() + 1, 0); int num_trees = static_cast(tree_sizes.size()); for (int i = 0; i < num_trees; ++i) { - tree_boundries[i + 1] = tree_boundries[i] + tree_sizes[i]; + tree_boundaries[i + 1] = tree_boundaries[i] + tree_sizes[i]; models_.emplace_back(nullptr); } OMP_INIT_EX(); #pragma omp parallel for num_threads(OMP_NUM_THREADS()) schedule(static) for (int i = 0; i < num_trees; ++i) { OMP_LOOP_EX_BEGIN(); - auto cur_p = p + tree_boundries[i]; + auto cur_p = p + tree_boundaries[i]; auto line_len = Common::GetLine(cur_p); std::string cur_line(cur_p, line_len); if (Common::StartsWith(cur_line, "Tree=")) { diff --git a/src/io/metadata.cpp b/src/io/metadata.cpp index f46e6d1c9f14..f6f07c434661 100644 --- a/src/io/metadata.cpp +++ b/src/io/metadata.cpp @@ -225,7 +225,7 @@ void Metadata::CheckOrPartition(data_size_t num_all_data, const std::vector(metadata.num_position_ids()); - // get boundries + // get boundaries query_boundaries_ = metadata.query_boundaries(); if (query_boundaries_ == nullptr) { Log::Fatal("Ranking tasks require query information"); diff --git a/src/treelearner/cuda/cuda_best_split_finder.cpp b/src/treelearner/cuda/cuda_best_split_finder.cpp index 95758542849c..e272ce744b1a 100644 --- a/src/treelearner/cuda/cuda_best_split_finder.cpp +++ b/src/treelearner/cuda/cuda_best_split_finder.cpp @@ -120,7 +120,7 @@ void CUDABestSplitFinder::Init() { void CUDABestSplitFinder::InitCUDAFeatureMetaInfo() { AllocateCUDAMemory(&cuda_is_feature_used_bytree_, static_cast(num_features_), __FILE__, __LINE__); - // intialize split find task information (a split find task is one pass through the histogram of a feature) + // initialize split find task information (a split find task is one pass through the histogram of a feature) num_tasks_ = 0; for (int inner_feature_index = 0; inner_feature_index < num_features_; ++inner_feature_index) { const uint32_t num_bin = feature_num_bins_[inner_feature_index]; diff --git a/src/treelearner/cuda/cuda_data_partition.cu b/src/treelearner/cuda/cuda_data_partition.cu index 3090b7a84176..4ca9d9279443 100644 --- a/src/treelearner/cuda/cuda_data_partition.cu +++ b/src/treelearner/cuda/cuda_data_partition.cu @@ -262,7 +262,7 @@ void CUDADataPartition::LaunchUpdateDataIndexToLeafIndexKernel_Inner4( } } -#define GenDataToLeftBitVectorKernel_PARMS \ +#define GenDataToLeftBitVectorKernel_PARAMS \ const BIN_TYPE* column_data, \ const data_size_t num_data_in_leaf, \ const data_size_t* data_indices_in_leaf, \ @@ -286,7 +286,7 @@ void CUDADataPartition::LaunchUpdateDataIndexToLeafIndexKernel_Inner4( template __global__ void GenDataToLeftBitVectorKernel( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, uint16_t* block_to_left_offset, data_size_t* block_to_left_offset_buffer, data_size_t* block_to_right_offset_buffer) { @@ -335,7 +335,7 @@ __global__ void GenDataToLeftBitVectorKernel( template void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool missing_is_zero, const bool missing_is_na, const bool mfb_is_zero, @@ -363,7 +363,7 @@ void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner( template void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner0( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool missing_is_na, const bool mfb_is_zero, const bool mfb_is_na, @@ -380,7 +380,7 @@ void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner0( template void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner1( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool mfb_is_zero, const bool mfb_is_na, const bool max_bin_to_left, @@ -396,7 +396,7 @@ void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner1( template void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner2( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool mfb_is_na, const bool max_bin_to_left, const bool is_single_feature_in_column) { @@ -413,7 +413,7 @@ void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner2( template void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner3( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool max_bin_to_left, const bool is_single_feature_in_column) { if (!max_bin_to_left) { @@ -429,7 +429,7 @@ void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner3( template void CUDADataPartition::LaunchGenDataToLeftBitVectorKernelInner4( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool is_single_feature_in_column) { if (!is_single_feature_in_column) { GenDataToLeftBitVectorKernel @@ -548,7 +548,7 @@ void CUDADataPartition::LaunchGenDataToLeftBitVectorKernel( #undef UpdateDataIndexToLeafIndexKernel_PARAMS #undef UpdateDataIndexToLeafIndex_ARGS -#undef GenDataToLeftBitVectorKernel_PARMS +#undef GenDataToLeftBitVectorKernel_PARAMS #undef GenBitVector_ARGS template diff --git a/src/treelearner/cuda/cuda_data_partition.hpp b/src/treelearner/cuda/cuda_data_partition.hpp index f6bbab9b8c65..bfcce89af243 100644 --- a/src/treelearner/cuda/cuda_data_partition.hpp +++ b/src/treelearner/cuda/cuda_data_partition.hpp @@ -174,7 +174,7 @@ class CUDADataPartition { const int left_leaf_index, const int right_leaf_index); -#define GenDataToLeftBitVectorKernel_PARMS \ +#define GenDataToLeftBitVectorKernel_PARAMS \ const BIN_TYPE* column_data, \ const data_size_t num_data_in_leaf, \ const data_size_t* data_indices_in_leaf, \ @@ -187,7 +187,7 @@ class CUDADataPartition { template void LaunchGenDataToLeftBitVectorKernelInner( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool missing_is_zero, const bool missing_is_na, const bool mfb_is_zero, @@ -197,7 +197,7 @@ class CUDADataPartition { template void LaunchGenDataToLeftBitVectorKernelInner0( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool missing_is_na, const bool mfb_is_zero, const bool mfb_is_na, @@ -206,7 +206,7 @@ class CUDADataPartition { template void LaunchGenDataToLeftBitVectorKernelInner1( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool mfb_is_zero, const bool mfb_is_na, const bool max_bin_to_left, @@ -214,23 +214,23 @@ class CUDADataPartition { template void LaunchGenDataToLeftBitVectorKernelInner2( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool mfb_is_na, const bool max_bin_to_left, const bool is_single_feature_in_column); template void LaunchGenDataToLeftBitVectorKernelInner3( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool max_bin_to_left, const bool is_single_feature_in_column); template void LaunchGenDataToLeftBitVectorKernelInner4( - GenDataToLeftBitVectorKernel_PARMS, + GenDataToLeftBitVectorKernel_PARAMS, const bool is_single_feature_in_column); -#undef GenDataToLeftBitVectorKernel_PARMS +#undef GenDataToLeftBitVectorKernel_PARAMS #define UpdateDataIndexToLeafIndexKernel_PARAMS \ const BIN_TYPE* column_data, \ @@ -379,7 +379,7 @@ class CUDADataPartition { int* cuda_split_info_buffer_; // dataset information - /*! \brief number of data in training set, for intialization of cuda_leaf_num_data_ and cuda_leaf_data_end_ */ + /*! \brief number of data in training set, for initialization of cuda_leaf_num_data_ and cuda_leaf_data_end_ */ data_size_t* cuda_num_data_; diff --git a/src/treelearner/cuda/cuda_histogram_constructor.cpp b/src/treelearner/cuda/cuda_histogram_constructor.cpp index 659db2aad24c..9f42eadec6f7 100644 --- a/src/treelearner/cuda/cuda_histogram_constructor.cpp +++ b/src/treelearner/cuda/cuda_histogram_constructor.cpp @@ -150,7 +150,7 @@ void CUDAHistogramConstructor::CalcConstructHistogramKernelDim( int* block_dim_y, const data_size_t num_data_in_smaller_leaf) { *block_dim_x = cuda_row_data_->max_num_column_per_partition(); - *block_dim_y = NUM_THRADS_PER_BLOCK / cuda_row_data_->max_num_column_per_partition(); + *block_dim_y = NUM_THREADS_PER_BLOCK / cuda_row_data_->max_num_column_per_partition(); *grid_dim_x = cuda_row_data_->num_feature_partitions(); *grid_dim_y = std::max(min_grid_dim_y_, ((num_data_in_smaller_leaf + NUM_DATA_PER_THREAD - 1) / NUM_DATA_PER_THREAD + (*block_dim_y) - 1) / (*block_dim_y)); diff --git a/src/treelearner/cuda/cuda_histogram_constructor.hpp b/src/treelearner/cuda/cuda_histogram_constructor.hpp index ddc78cb17d90..655029d23ba5 100644 --- a/src/treelearner/cuda/cuda_histogram_constructor.hpp +++ b/src/treelearner/cuda/cuda_histogram_constructor.hpp @@ -19,7 +19,7 @@ #include "cuda_leaf_splits.hpp" #define NUM_DATA_PER_THREAD (400) -#define NUM_THRADS_PER_BLOCK (504) +#define NUM_THREADS_PER_BLOCK (504) #define NUM_FEATURE_PER_THREAD_GROUP (28) #define SUBTRACT_BLOCK_SIZE (1024) #define FIX_HISTOGRAM_SHARED_MEM_SIZE (1024) diff --git a/src/treelearner/cuda/cuda_leaf_splits.cpp b/src/treelearner/cuda/cuda_leaf_splits.cpp index 57b5b777c142..7a6377540e32 100644 --- a/src/treelearner/cuda/cuda_leaf_splits.cpp +++ b/src/treelearner/cuda/cuda_leaf_splits.cpp @@ -16,7 +16,7 @@ num_data_(num_data) {} CUDALeafSplits::~CUDALeafSplits() {} void CUDALeafSplits::Init(const bool use_quantized_grad) { - num_blocks_init_from_gradients_ = (num_data_ + NUM_THRADS_PER_BLOCK_LEAF_SPLITS - 1) / NUM_THRADS_PER_BLOCK_LEAF_SPLITS; + num_blocks_init_from_gradients_ = (num_data_ + NUM_THREADS_PER_BLOCK_LEAF_SPLITS - 1) / NUM_THREADS_PER_BLOCK_LEAF_SPLITS; // allocate more memory for sum reduction in CUDA // only the first element records the final sum @@ -43,7 +43,7 @@ void CUDALeafSplits::InitValues( cuda_hessians_ = cuda_hessians; cuda_sum_of_gradients_buffer_.SetValue(0); cuda_sum_of_hessians_buffer_.SetValue(0); - LaunchInitValuesKernal(lambda_l1, lambda_l2, cuda_bagging_data_indices, cuda_data_indices_in_leaf, num_used_indices, cuda_hist_in_leaf); + LaunchInitValuesKernel(lambda_l1, lambda_l2, cuda_bagging_data_indices, cuda_data_indices_in_leaf, num_used_indices, cuda_hist_in_leaf); CopyFromCUDADeviceToHost(root_sum_hessians, cuda_sum_of_hessians_buffer_.RawData(), 1, __FILE__, __LINE__); SynchronizeCUDADevice(__FILE__, __LINE__); } @@ -57,14 +57,14 @@ void CUDALeafSplits::InitValues( const score_t* grad_scale, const score_t* hess_scale) { cuda_gradients_ = reinterpret_cast(cuda_gradients_and_hessians); cuda_hessians_ = nullptr; - LaunchInitValuesKernal(lambda_l1, lambda_l2, cuda_bagging_data_indices, cuda_data_indices_in_leaf, num_used_indices, cuda_hist_in_leaf, grad_scale, hess_scale); + LaunchInitValuesKernel(lambda_l1, lambda_l2, cuda_bagging_data_indices, cuda_data_indices_in_leaf, num_used_indices, cuda_hist_in_leaf, grad_scale, hess_scale); CopyFromCUDADeviceToHost(root_sum_hessians, cuda_sum_of_hessians_buffer_.RawData(), 1, __FILE__, __LINE__); SynchronizeCUDADevice(__FILE__, __LINE__); } void CUDALeafSplits::Resize(const data_size_t num_data) { num_data_ = num_data; - num_blocks_init_from_gradients_ = (num_data + NUM_THRADS_PER_BLOCK_LEAF_SPLITS - 1) / NUM_THRADS_PER_BLOCK_LEAF_SPLITS; + num_blocks_init_from_gradients_ = (num_data + NUM_THREADS_PER_BLOCK_LEAF_SPLITS - 1) / NUM_THREADS_PER_BLOCK_LEAF_SPLITS; cuda_sum_of_gradients_buffer_.Resize(static_cast(num_blocks_init_from_gradients_)); cuda_sum_of_hessians_buffer_.Resize(static_cast(num_blocks_init_from_gradients_)); cuda_sum_of_gradients_hessians_buffer_.Resize(static_cast(num_blocks_init_from_gradients_)); diff --git a/src/treelearner/cuda/cuda_leaf_splits.cu b/src/treelearner/cuda/cuda_leaf_splits.cu index ae505ecd55dd..0c796be9f20a 100644 --- a/src/treelearner/cuda/cuda_leaf_splits.cu +++ b/src/treelearner/cuda/cuda_leaf_splits.cu @@ -180,23 +180,23 @@ void CUDALeafSplits::LaunchInitValuesEmptyKernel() { InitValuesEmptyKernel<<<1, 1>>>(cuda_struct_.RawData()); } -void CUDALeafSplits::LaunchInitValuesKernal( +void CUDALeafSplits::LaunchInitValuesKernel( const double lambda_l1, const double lambda_l2, const data_size_t* cuda_bagging_data_indices, const data_size_t* cuda_data_indices_in_leaf, const data_size_t num_used_indices, hist_t* cuda_hist_in_leaf) { if (cuda_bagging_data_indices == nullptr) { - CUDAInitValuesKernel1<<>>( + CUDAInitValuesKernel1<<>>( cuda_gradients_, cuda_hessians_, num_used_indices, nullptr, cuda_sum_of_gradients_buffer_.RawData(), cuda_sum_of_hessians_buffer_.RawData()); } else { - CUDAInitValuesKernel1<<>>( + CUDAInitValuesKernel1<<>>( cuda_gradients_, cuda_hessians_, num_used_indices, cuda_bagging_data_indices, cuda_sum_of_gradients_buffer_.RawData(), cuda_sum_of_hessians_buffer_.RawData()); } SynchronizeCUDADevice(__FILE__, __LINE__); - CUDAInitValuesKernel2<<<1, NUM_THRADS_PER_BLOCK_LEAF_SPLITS>>>( + CUDAInitValuesKernel2<<<1, NUM_THREADS_PER_BLOCK_LEAF_SPLITS>>>( lambda_l1, lambda_l2, num_blocks_init_from_gradients_, cuda_sum_of_gradients_buffer_.RawData(), @@ -208,7 +208,7 @@ void CUDALeafSplits::LaunchInitValuesKernal( SynchronizeCUDADevice(__FILE__, __LINE__); } -void CUDALeafSplits::LaunchInitValuesKernal( +void CUDALeafSplits::LaunchInitValuesKernel( const double lambda_l1, const double lambda_l2, const data_size_t* cuda_bagging_data_indices, const data_size_t* cuda_data_indices_in_leaf, @@ -217,17 +217,17 @@ void CUDALeafSplits::LaunchInitValuesKernal( const score_t* grad_scale, const score_t* hess_scale) { if (cuda_bagging_data_indices == nullptr) { - CUDAInitValuesKernel3<<>>( + CUDAInitValuesKernel3<<>>( reinterpret_cast(cuda_gradients_), num_used_indices, nullptr, cuda_sum_of_gradients_buffer_.RawData(), cuda_sum_of_hessians_buffer_.RawData(), cuda_sum_of_gradients_hessians_buffer_.RawData(), grad_scale, hess_scale); } else { - CUDAInitValuesKernel3<<>>( + CUDAInitValuesKernel3<<>>( reinterpret_cast(cuda_gradients_), num_used_indices, cuda_bagging_data_indices, cuda_sum_of_gradients_buffer_.RawData(), cuda_sum_of_hessians_buffer_.RawData(), cuda_sum_of_gradients_hessians_buffer_.RawData(), grad_scale, hess_scale); } SynchronizeCUDADevice(__FILE__, __LINE__); - CUDAInitValuesKernel4<<<1, NUM_THRADS_PER_BLOCK_LEAF_SPLITS>>>( + CUDAInitValuesKernel4<<<1, NUM_THREADS_PER_BLOCK_LEAF_SPLITS>>>( lambda_l1, lambda_l2, num_blocks_init_from_gradients_, cuda_sum_of_gradients_buffer_.RawData(), diff --git a/src/treelearner/cuda/cuda_leaf_splits.hpp b/src/treelearner/cuda/cuda_leaf_splits.hpp index 33a9ea578a1f..3cd57486716c 100644 --- a/src/treelearner/cuda/cuda_leaf_splits.hpp +++ b/src/treelearner/cuda/cuda_leaf_splits.hpp @@ -13,7 +13,7 @@ #include #include -#define NUM_THRADS_PER_BLOCK_LEAF_SPLITS (1024) +#define NUM_THREADS_PER_BLOCK_LEAF_SPLITS (1024) #define NUM_DATA_THREAD_ADD_LEAF_SPLITS (6) namespace LightGBM { @@ -142,14 +142,14 @@ class CUDALeafSplits { private: void LaunchInitValuesEmptyKernel(); - void LaunchInitValuesKernal( + void LaunchInitValuesKernel( const double lambda_l1, const double lambda_l2, const data_size_t* cuda_bagging_data_indices, const data_size_t* cuda_data_indices_in_leaf, const data_size_t num_used_indices, hist_t* cuda_hist_in_leaf); - void LaunchInitValuesKernal( + void LaunchInitValuesKernel( const double lambda_l1, const double lambda_l2, const data_size_t* cuda_bagging_data_indices, const data_size_t* cuda_data_indices_in_leaf, diff --git a/src/treelearner/data_parallel_tree_learner.cpp b/src/treelearner/data_parallel_tree_learner.cpp index 64c342e5b01d..670788118455 100644 --- a/src/treelearner/data_parallel_tree_learner.cpp +++ b/src/treelearner/data_parallel_tree_learner.cpp @@ -260,12 +260,12 @@ void DataParallelTreeLearner::FindBestSplits(const Tree* tree) { if (smaller_leaf_num_bits <= 16) { std::memcpy(input_buffer_.data() + buffer_write_start_pos_int16_[feature_index], this->smaller_leaf_histogram_array_[feature_index].RawDataInt16(), - this->smaller_leaf_histogram_array_[feature_index].SizeOfInt16Histgram()); + this->smaller_leaf_histogram_array_[feature_index].SizeOfInt16Histogram()); } else { if (local_smaller_leaf_num_bits == 32) { std::memcpy(input_buffer_.data() + buffer_write_start_pos_[feature_index], this->smaller_leaf_histogram_array_[feature_index].RawDataInt32(), - this->smaller_leaf_histogram_array_[feature_index].SizeOfInt32Histgram()); + this->smaller_leaf_histogram_array_[feature_index].SizeOfInt32Histogram()); } else { this->smaller_leaf_histogram_array_[feature_index].CopyFromInt16ToInt32( input_buffer_.data() + buffer_write_start_pos_[feature_index]); @@ -274,7 +274,7 @@ void DataParallelTreeLearner::FindBestSplits(const Tree* tree) { } else { std::memcpy(input_buffer_.data() + buffer_write_start_pos_[feature_index], this->smaller_leaf_histogram_array_[feature_index].RawData(), - this->smaller_leaf_histogram_array_[feature_index].SizeOfHistgram()); + this->smaller_leaf_histogram_array_[feature_index].SizeOfHistogram()); } } global_timer.Stop("DataParallelTreeLearner::ReduceHistogram::Copy"); diff --git a/src/treelearner/feature_histogram.hpp b/src/treelearner/feature_histogram.hpp index 70dd0fb5436f..2d4abbd27af1 100644 --- a/src/treelearner/feature_histogram.hpp +++ b/src/treelearner/feature_histogram.hpp @@ -668,15 +668,15 @@ class FeatureHistogram { /*! * \brief Binary size of this histogram */ - int SizeOfHistgram() const { + int SizeOfHistogram() const { return (meta_->num_bin - meta_->offset) * kHistEntrySize; } - int SizeOfInt32Histgram() const { + int SizeOfInt32Histogram() const { return (meta_->num_bin - meta_->offset) * kInt32HistEntrySize; } - int SizeOfInt16Histgram() const { + int SizeOfInt16Histogram() const { return (meta_->num_bin - meta_->offset) * kInt16HistEntrySize; } diff --git a/src/treelearner/gpu_tree_learner.cpp b/src/treelearner/gpu_tree_learner.cpp index 7c6c811c3b45..1bf21d65ccc6 100644 --- a/src/treelearner/gpu_tree_learner.cpp +++ b/src/treelearner/gpu_tree_learner.cpp @@ -777,7 +777,7 @@ void GPUTreeLearner::ResetIsConstantHessian(bool is_constant_hessian) { void GPUTreeLearner::BeforeTrain() { #if GPU_DEBUG >= 2 - printf("Copying intial full gradients and hessians to device\n"); + printf("Copying initial full gradients and hessians to device\n"); #endif // Copy initial full hessians and gradients to GPU. // We start copying as early as possible, instead of at ConstructHistogram(). diff --git a/src/treelearner/kernels/histogram_16_64_256.cu b/src/treelearner/kernels/histogram_16_64_256.cu index d778d650f722..59662fb19d55 100644 --- a/src/treelearner/kernels/histogram_16_64_256.cu +++ b/src/treelearner/kernels/histogram_16_64_256.cu @@ -508,7 +508,7 @@ __global__ void KERNEL_NAME(const uchar* feature_data_base, // there are 2^POWER_FEATURE_WORKGROUPS workgroups processing each feature4 for (unsigned int i = subglobal_tid; i < num_data; i += subglobal_size) { // prefetch the next iteration variables - // we don't need bondary check because we have made the buffer large + // we don't need boundary check because we have made the buffer large int i_next = i + subglobal_size; #ifdef IGNORE_INDICES // we need to check to bounds here @@ -752,7 +752,7 @@ __global__ void KERNEL_NAME(const uchar* feature_data_base, // assume this starts at 32 * 4 = 128-byte boundary // What does it mean? boundary?? // total size: 2 * 256 * size_of(float) = 2 KB // organization: each feature/grad/hessian is at a different bank, - // as indepedent of the feature value as possible + // as independent of the feature value as possible acc_type *gh_hist = reinterpret_cast(shared_array); // counter histogram diff --git a/src/treelearner/ocl/histogram16.cl b/src/treelearner/ocl/histogram16.cl index 21624ec9ee10..be590c20666b 100644 --- a/src/treelearner/ocl/histogram16.cl +++ b/src/treelearner/ocl/histogram16.cl @@ -8,7 +8,7 @@ #ifndef __OPENCL_VERSION__ // If we are including this file in C++, // the entire source file following (except the last #endif) will become -// a raw string literal. The extra ")" is just for mathcing parentheses +// a raw string literal. The extra ")" is just for matching parentheses // to make the editor happy. The extra ")" and extra endif will be skipped. // DO NOT add anything between here and the next #ifdef, otherwise you need // to modify the skip count at the end of this file. @@ -475,7 +475,7 @@ R""() // prefetch the next iteration variables - // we don't need bondary check because if it is out of boundary, ind_next = 0 + // we don't need boundary check because if it is out of boundary, ind_next = 0 #ifndef IGNORE_INDICES feature4_next = feature_data[ind_next]; #endif diff --git a/src/treelearner/ocl/histogram256.cl b/src/treelearner/ocl/histogram256.cl index 3351f9efa7c3..b5c049e1272d 100644 --- a/src/treelearner/ocl/histogram256.cl +++ b/src/treelearner/ocl/histogram256.cl @@ -387,7 +387,7 @@ __kernel void histogram256(__global const uchar4* feature_data_base, const uint subglobal_tid = gtid - group_feature * subglobal_size; // extract feature mask, when a byte is set to 0, that feature is disabled #if ENABLE_ALL_FEATURES == 1 - // hopefully the compiler will propogate the constants and eliminate all branches + // hopefully the compiler will propagate the constants and eliminate all branches uchar4 feature_mask = (uchar4)(0xff, 0xff, 0xff, 0xff); #else uchar4 feature_mask = feature_masks[group_feature]; diff --git a/src/treelearner/ocl/histogram64.cl b/src/treelearner/ocl/histogram64.cl index 48fa8c506d8b..4ec4d6371df5 100644 --- a/src/treelearner/ocl/histogram64.cl +++ b/src/treelearner/ocl/histogram64.cl @@ -454,7 +454,7 @@ R""() // prefetch the next iteration variables - // we don't need bondary check because if it is out of boundary, ind_next = 0 + // we don't need boundary check because if it is out of boundary, ind_next = 0 #ifndef IGNORE_INDICES feature4_next = feature_data[ind_next]; #endif diff --git a/src/treelearner/parallel_tree_learner.h b/src/treelearner/parallel_tree_learner.h index b942dceab28b..aff8ac0fd4c5 100644 --- a/src/treelearner/parallel_tree_learner.h +++ b/src/treelearner/parallel_tree_learner.h @@ -148,12 +148,12 @@ class VotingParallelTreeLearner: public TREELEARNER_T { * \brief Perform global voting * \param leaf_idx index of leaf * \param splits All splits from local voting - * \param out Result of gobal voting, only store feature indices + * \param out Result of global voting, only store feature indices */ void GlobalVoting(int leaf_idx, const std::vector& splits, std::vector* out); /*! - * \brief Copy local histgram to buffer + * \brief Copy local histogram to buffer * \param smaller_top_features Selected features for smaller leaf * \param larger_top_features Selected features for larger leaf */ @@ -183,9 +183,9 @@ class VotingParallelTreeLearner: public TREELEARNER_T { std::vector block_start_; /*! \brief Block size for reduce scatter */ std::vector block_len_; - /*! \brief Read positions for feature histgrams at smaller leaf */ + /*! \brief Read positions for feature histograms at smaller leaf */ std::vector smaller_buffer_read_start_pos_; - /*! \brief Read positions for feature histgrams at larger leaf */ + /*! \brief Read positions for feature histograms at larger leaf */ std::vector larger_buffer_read_start_pos_; /*! \brief Size for reduce scatter */ comm_size_t reduce_scatter_size_; diff --git a/src/treelearner/serial_tree_learner.cpp b/src/treelearner/serial_tree_learner.cpp index f3a88bd18679..77d853608b47 100644 --- a/src/treelearner/serial_tree_learner.cpp +++ b/src/treelearner/serial_tree_learner.cpp @@ -729,24 +729,24 @@ int32_t SerialTreeLearner::ForceSplits(Tree* tree, int* left_leaf, std::set SerialTreeLearner::FindAllForceFeatures(Json force_split_leaf_setting) { std::set force_features; - std::queue force_split_leafs; + std::queue force_split_leaves; - force_split_leafs.push(force_split_leaf_setting); + force_split_leaves.push(force_split_leaf_setting); - while (!force_split_leafs.empty()) { - Json split_leaf = force_split_leafs.front(); - force_split_leafs.pop(); + while (!force_split_leaves.empty()) { + Json split_leaf = force_split_leaves.front(); + force_split_leaves.pop(); const int feature_index = split_leaf["feature"].int_value(); const int feature_inner_index = train_data_->InnerFeatureIndex(feature_index); force_features.insert(feature_inner_index); if (split_leaf.object_items().count("left") > 0) { - force_split_leafs.push(split_leaf["left"]); + force_split_leaves.push(split_leaf["left"]); } if (split_leaf.object_items().count("right") > 0) { - force_split_leafs.push(split_leaf["right"]); + force_split_leaves.push(split_leaf["right"]); } } diff --git a/src/treelearner/voting_parallel_tree_learner.cpp b/src/treelearner/voting_parallel_tree_learner.cpp index b88db5a7ba28..37f2d4cf2641 100644 --- a/src/treelearner/voting_parallel_tree_learner.cpp +++ b/src/treelearner/voting_parallel_tree_learner.cpp @@ -207,9 +207,9 @@ void VotingParallelTreeLearner::CopyLocalHistogram(const std::vec smaller_buffer_read_start_pos_[inner_feature_index] = static_cast(cur_size); } // copy - std::memcpy(input_buffer_.data() + reduce_scatter_size_, this->smaller_leaf_histogram_array_[inner_feature_index].RawData(), this->smaller_leaf_histogram_array_[inner_feature_index].SizeOfHistgram()); - cur_size += this->smaller_leaf_histogram_array_[inner_feature_index].SizeOfHistgram(); - reduce_scatter_size_ += this->smaller_leaf_histogram_array_[inner_feature_index].SizeOfHistgram(); + std::memcpy(input_buffer_.data() + reduce_scatter_size_, this->smaller_leaf_histogram_array_[inner_feature_index].RawData(), this->smaller_leaf_histogram_array_[inner_feature_index].SizeOfHistogram()); + cur_size += this->smaller_leaf_histogram_array_[inner_feature_index].SizeOfHistogram(); + reduce_scatter_size_ += this->smaller_leaf_histogram_array_[inner_feature_index].SizeOfHistogram(); ++smaller_idx; } if (cur_used_features >= cur_total_feature) { @@ -225,9 +225,9 @@ void VotingParallelTreeLearner::CopyLocalHistogram(const std::vec larger_buffer_read_start_pos_[inner_feature_index] = static_cast(cur_size); } // copy - std::memcpy(input_buffer_.data() + reduce_scatter_size_, this->larger_leaf_histogram_array_[inner_feature_index].RawData(), this->larger_leaf_histogram_array_[inner_feature_index].SizeOfHistgram()); - cur_size += this->larger_leaf_histogram_array_[inner_feature_index].SizeOfHistgram(); - reduce_scatter_size_ += this->larger_leaf_histogram_array_[inner_feature_index].SizeOfHistgram(); + std::memcpy(input_buffer_.data() + reduce_scatter_size_, this->larger_leaf_histogram_array_[inner_feature_index].RawData(), this->larger_leaf_histogram_array_[inner_feature_index].SizeOfHistogram()); + cur_size += this->larger_leaf_histogram_array_[inner_feature_index].SizeOfHistogram(); + reduce_scatter_size_ += this->larger_leaf_histogram_array_[inner_feature_index].SizeOfHistogram(); ++larger_idx; } } diff --git a/tests/cpp_tests/test_chunked_array.cpp b/tests/cpp_tests/test_chunked_array.cpp index 9bfd857299ab..bc58918082a8 100644 --- a/tests/cpp_tests/test_chunked_array.cpp +++ b/tests/cpp_tests/test_chunked_array.cpp @@ -217,8 +217,8 @@ TEST_F(ChunkedArrayTest, testDataLayoutWithAdvancedInsertionAPI) { // Number of trials for each new ChunkedArray configuration. Pass 100 times over the search space: const size_t N_TRIALS = MAX_CHUNKS_SEARCH * MAX_IN_CHUNK_SEARCH_IDX * 100; const int INVALID = -1; // A negative value signaling the requested value lives in an invalid address. - const int UNITIALIZED = -99; // A negative value to signal this was never updated. - std::vector ref_values(MAX_CHUNKS_SEARCH * CHUNK_SIZE, UNITIALIZED); // Memorize latest inserted values. + const int UNINITIALIZED = -99; // A negative value to signal this was never updated. + std::vector ref_values(MAX_CHUNKS_SEARCH * CHUNK_SIZE, UNINITIALIZED); // Memorize latest inserted values. // Each outer loop iteration changes the test by adding +1 chunk. We start with 1 chunk only: for (size_t chunks = 1; chunks < MAX_CHUNKS_SEARCH; ++chunks) { @@ -249,10 +249,10 @@ TEST_F(ChunkedArrayTest, testDataLayoutWithAdvancedInsertionAPI) { } // Final check: ensure even with overrides, all valid insertions store the latest value at that address: - std::vector coalesced_out(MAX_CHUNKS_SEARCH * CHUNK_SIZE, UNITIALIZED); + std::vector coalesced_out(MAX_CHUNKS_SEARCH * CHUNK_SIZE, UNINITIALIZED); ca_.coalesce_to(coalesced_out.data(), true); // Export all valid addresses. for (size_t i = 0; i < ref_values.size(); ++i) { - if (ref_values[i] != UNITIALIZED) { + if (ref_values[i] != UNINITIALIZED) { // Test in 2 ways that the values are correctly laid out in memory: EXPECT_EQ(ca_.getitem(i / CHUNK_SIZE, i % CHUNK_SIZE, INVALID), ref_values[i]); EXPECT_EQ(coalesced_out[i], ref_values[i]); diff --git a/tests/cpp_tests/test_stream.cpp b/tests/cpp_tests/test_stream.cpp index bc5f73b0a3ee..a656af1e2fe9 100644 --- a/tests/cpp_tests/test_stream.cpp +++ b/tests/cpp_tests/test_stream.cpp @@ -17,7 +17,7 @@ using LightGBM::TestUtils; void test_stream_dense( int8_t creation_type, - DatasetHandle ref_datset_handle, + DatasetHandle ref_dataset_handle, int32_t nrows, int32_t ncols, int32_t nclasses, @@ -86,7 +86,7 @@ void test_stream_dense( case 1: Log::Info("Creating Dataset using LGBM_DatasetCreateByReference, %d rows dense data with a batch size of %d", nrows, batch_count); - result = LGBM_DatasetCreateByReference(ref_datset_handle, nrows, &dataset_handle); + result = LGBM_DatasetCreateByReference(ref_dataset_handle, nrows, &dataset_handle); EXPECT_EQ(0, result) << "LGBM_DatasetCreateByReference result code: " << result; break; } @@ -131,7 +131,7 @@ void test_stream_dense( void test_stream_sparse( int8_t creation_type, - DatasetHandle ref_datset_handle, + DatasetHandle ref_dataset_handle, int32_t nrows, int32_t ncols, int32_t nclasses, @@ -203,7 +203,7 @@ void test_stream_sparse( case 1: Log::Info("Creating Dataset using LGBM_DatasetCreateByReference, %d rows sparse data with a batch size of %d", nrows, batch_count); - result = LGBM_DatasetCreateByReference(ref_datset_handle, nrows, &dataset_handle); + result = LGBM_DatasetCreateByReference(ref_dataset_handle, nrows, &dataset_handle); EXPECT_EQ(0, result) << "LGBM_DatasetCreateByReference result code: " << result; break; } @@ -249,13 +249,13 @@ void test_stream_sparse( TEST(Stream, PushDenseRowsWithMetadata) { // Load some test data - DatasetHandle ref_datset_handle; + DatasetHandle ref_dataset_handle; const char* params = "max_bin=15"; // Use the smaller ".test" data because we don't care about the actual data and it's smaller - int result = TestUtils::LoadDatasetFromExamples("binary_classification/binary.test", params, &ref_datset_handle); + int result = TestUtils::LoadDatasetFromExamples("binary_classification/binary.test", params, &ref_dataset_handle); EXPECT_EQ(0, result) << "LoadDatasetFromExamples result code: " << result; - Dataset* ref_dataset = static_cast(ref_datset_handle); + Dataset* ref_dataset = static_cast(ref_dataset_handle); auto noriginalrows = ref_dataset->num_data(); Log::Info("Row count: %d", noriginalrows); Log::Info("Feature group count: %d", ref_dataset->num_features()); @@ -266,9 +266,9 @@ TEST(Stream, PushDenseRowsWithMetadata) { unused_init_scores.resize(noriginalrows * nclasses); std::vector unused_groups; unused_groups.assign(noriginalrows, 1); - result = LGBM_DatasetSetField(ref_datset_handle, "init_score", unused_init_scores.data(), noriginalrows * nclasses, 1); + result = LGBM_DatasetSetField(ref_dataset_handle, "init_score", unused_init_scores.data(), noriginalrows * nclasses, 1); EXPECT_EQ(0, result) << "LGBM_DatasetSetField init_score result code: " << result; - result = LGBM_DatasetSetField(ref_datset_handle, "group", unused_groups.data(), noriginalrows, 2); + result = LGBM_DatasetSetField(ref_dataset_handle, "group", unused_groups.data(), noriginalrows, 2); EXPECT_EQ(0, result) << "LGBM_DatasetSetField group result code: " << result; // Now use the reference dataset schema to make some testable Datasets with N rows each @@ -290,23 +290,23 @@ TEST(Stream, PushDenseRowsWithMetadata) { for (size_t j = 0; j < batch_counts.size(); ++j) { auto type = creation_types[i]; auto batch_count = batch_counts[j]; - test_stream_dense(type, ref_datset_handle, nrows, ncols, nclasses, batch_count, &features, &labels, &weights, &init_scores, &groups); + test_stream_dense(type, ref_dataset_handle, nrows, ncols, nclasses, batch_count, &features, &labels, &weights, &init_scores, &groups); } } - result = LGBM_DatasetFree(ref_datset_handle); + result = LGBM_DatasetFree(ref_dataset_handle); EXPECT_EQ(0, result) << "LGBM_DatasetFree result code: " << result; } TEST(Stream, PushSparseRowsWithMetadata) { // Load some test data - DatasetHandle ref_datset_handle; + DatasetHandle ref_dataset_handle; const char* params = "max_bin=15"; // Use the smaller ".test" data because we don't care about the actual data and it's smaller - int result = TestUtils::LoadDatasetFromExamples("binary_classification/binary.test", params, &ref_datset_handle); + int result = TestUtils::LoadDatasetFromExamples("binary_classification/binary.test", params, &ref_dataset_handle); EXPECT_EQ(0, result) << "LoadDatasetFromExamples result code: " << result; - Dataset* ref_dataset = static_cast(ref_datset_handle); + Dataset* ref_dataset = static_cast(ref_dataset_handle); auto noriginalrows = ref_dataset->num_data(); Log::Info("Row count: %d", noriginalrows); Log::Info("Feature group count: %d", ref_dataset->num_features()); @@ -317,9 +317,9 @@ TEST(Stream, PushSparseRowsWithMetadata) { unused_init_scores.resize(noriginalrows * nclasses); std::vector unused_groups; unused_groups.assign(noriginalrows, 1); - result = LGBM_DatasetSetField(ref_datset_handle, "init_score", unused_init_scores.data(), noriginalrows * nclasses, 1); + result = LGBM_DatasetSetField(ref_dataset_handle, "init_score", unused_init_scores.data(), noriginalrows * nclasses, 1); EXPECT_EQ(0, result) << "LGBM_DatasetSetField init_score result code: " << result; - result = LGBM_DatasetSetField(ref_datset_handle, "group", unused_groups.data(), noriginalrows, 2); + result = LGBM_DatasetSetField(ref_dataset_handle, "group", unused_groups.data(), noriginalrows, 2); EXPECT_EQ(0, result) << "LGBM_DatasetSetField group result code: " << result; // Now use the reference dataset schema to make some testable Datasets with N rows each @@ -344,10 +344,10 @@ TEST(Stream, PushSparseRowsWithMetadata) { for (size_t j = 0; j < batch_counts.size(); ++j) { auto type = creation_types[i]; auto batch_count = batch_counts[j]; - test_stream_sparse(type, ref_datset_handle, nrows, ncols, nclasses, batch_count, &indptr, &indices, &vals, &labels, &weights, &init_scores, &groups); + test_stream_sparse(type, ref_dataset_handle, nrows, ncols, nclasses, batch_count, &indptr, &indices, &vals, &labels, &weights, &init_scores, &groups); } } - result = LGBM_DatasetFree(ref_datset_handle); + result = LGBM_DatasetFree(ref_dataset_handle); EXPECT_EQ(0, result) << "LGBM_DatasetFree result code: " << result; } diff --git a/tests/python_package_test/test_dask.py b/tests/python_package_test/test_dask.py index 37d6db2541f5..1bce9e6bf456 100644 --- a/tests/python_package_test/test_dask.py +++ b/tests/python_package_test/test_dask.py @@ -472,7 +472,7 @@ def test_classifier_custom_objective(output, task, cluster): assert_eq(p1_proba, p1_proba_local) -def test_machines_to_worker_map_unparseable_host_names(): +def test_machines_to_worker_map_unparsable_host_names(): workers = {"0.0.0.1:80": {}, "0.0.0.2:80": {}} machines = "0.0.0.1:80,0.0.0.2:80" with pytest.raises(ValueError, match="Could not parse host name from worker address '0.0.0.1:80'"): diff --git a/tests/python_package_test/test_engine.py b/tests/python_package_test/test_engine.py index 9ff56206ca70..e4f5810f760d 100644 --- a/tests/python_package_test/test_engine.py +++ b/tests/python_package_test/test_engine.py @@ -658,7 +658,7 @@ def test_ranking_prediction_early_stopping(): # Simulates position bias for a given ranking dataset. -# The ouput dataset is identical to the input one with the exception for the relevance labels. +# The output dataset is identical to the input one with the exception for the relevance labels. # The new labels are generated according to an instance of a cascade user model: # for each query, the user is simulated to be traversing the list of documents ranked by a baseline ranker # (in our example it is simply the ordering by some feature correlated with relevance, e.g., 34)