Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Logistic Regression algorithm #2530

Merged
merged 71 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
730c623
Initial commit
avolkov-intel Jun 29, 2023
103b005
Add tests
avolkov-intel Jul 3, 2023
fc75c58
Add cg_solver primitive to solve equation Ax = b
avolkov-intel Jul 7, 2023
520b811
Merge branch 'master' into dev/cg-solver
avolkov-intel Jul 7, 2023
d4b97c9
Move newton_cg primitve to optimizators primitive
avolkov-intel Jul 13, 2023
a68c6f0
Define newton_cg optimization function
avolkov-intel Jul 14, 2023
7d56a99
Add backtracking algorithm for optimal alpha, implement newton_cg solver
avolkov-intel Jul 18, 2023
1f36dd6
Fix errors, add tests for newton-cg
avolkov-intel Jul 21, 2023
5fb7117
Remove redundant wait_and_throw, add links to sources
avolkov-intel Jul 21, 2023
93e428d
Ensure code stability and fix minor issues
avolkov-intel Jul 25, 2023
9eb51f5
Add sycl::fill, sycl::fabs and add specifiers for virtual functions
avolkov-intel Jul 25, 2023
5c3fa2e
Remove redundant package dependency, update default values for Float …
avolkov-intel Jul 26, 2023
7d2bdaf
Change update_x return type to event_vector, rename test function and…
avolkov-intel Jul 26, 2023
890e1da
Initial commit
avolkov-intel Jul 26, 2023
ff71dfb
Split logloss and derivative functions, decrease the number of parame…
avolkov-intel Aug 1, 2023
8f945a1
Delete redundant compute functions, deselect tests
avolkov-intel Aug 2, 2023
4d71e82
Add LogLossFunction class and cover it with tests
avolkov-intel Aug 3, 2023
551131d
Merge master
avolkov-intel Aug 3, 2023
1e53e75
Fix bugs, rename kernels and remove redundant, update perforamnce tests
avolkov-intel Aug 4, 2023
9fdbe1d
Merge branch 'master' into dev/logloss-functor
avolkov-intel Aug 22, 2023
16a2312
Add wait and throw after gemv events
avolkov-intel Sep 14, 2023
10bee38
Merge branch 'master' into dev/logloss-functor
avolkov-intel Sep 14, 2023
3c026da
Minor
avolkov-intel Sep 19, 2023
a66aab2
Fix error and add batch test
avolkov-intel Sep 21, 2023
6534dac
Add const qualifier for table with data
avolkov-intel Sep 27, 2023
e559daf
Merge remote-tracking branch 'origin/master' into dev/logloss-functor
avolkov-intel Sep 27, 2023
10df0e8
Minor
avolkov-intel Oct 4, 2023
a11026c
Add LogReg test to newton_cg optimizer
avolkov-intel Sep 19, 2023
5c4f579
Add LogReg algorithm interface
avolkov-intel Sep 22, 2023
158c6fa
Add BUILD files, vanila implementation and tmp test
avolkov-intel Sep 25, 2023
5510f5e
Add test
avolkov-intel Sep 27, 2023
72ec43c
Minor
avolkov-intel Sep 27, 2023
d4764dd
Update train kernel
avolkov-intel Sep 29, 2023
59fb63b
Add GPU infer kernels to LogReg algo
avolkov-intel Sep 29, 2023
1e40174
Add logistic regression dpc example
avolkov-intel Sep 29, 2023
1927003
Fix GPU test failures: PCA (#2531)
inteldimitrius Sep 27, 2023
744f259
Support building reference backend with clang (#2529)
keeranroth Sep 28, 2023
9188113
oneDAL development env docker image (#2513)
napetrov Sep 28, 2023
b3e0deb
chore(deps): update actions/checkout digest to 8ade135 (#2521)
renovate[bot] Sep 28, 2023
927c008
Update version to 2024.0.1 (#2533)
Alexsandruss Sep 29, 2023
e5222fd
Online interfaces for LOM (#2483)
Alexandr-Solovev Oct 2, 2023
44c3fd3
chore(deps): update dependency urllib3 to v2.0.6 [security] (#2536)
renovate[bot] Oct 3, 2023
9c778cf
Minor
avolkov-intel Oct 6, 2023
2651049
Merge master
avolkov-intel Oct 6, 2023
f2a4c25
Change task name to binary classification and update an example
avolkov-intel Oct 9, 2023
d8cc4cc
Add template optimizer parameter to descriptor, add optimizer factory…
avolkov-intel Oct 10, 2023
5efce33
Change unimplemented error name thrown in cpu kernel
avolkov-intel Oct 10, 2023
2606a2a
Move data to gpu before training
avolkov-intel Oct 10, 2023
3cdc96b
Minor
avolkov-intel Oct 11, 2023
57b8125
Change dependency graph to address error, fix tests
avolkov-intel Oct 11, 2023
26367de
Add optimizer descriptor as a template parameter
avolkov-intel Oct 16, 2023
19c0764
Update interface, improve primitive stability
avolkov-intel Oct 17, 2023
32cbc1a
Move the optimizer dispatching logic to minimize function
avolkov-intel Oct 17, 2023
ec46575
Minor
avolkov-intel Oct 17, 2023
4f9b51e
Remove debug output, change optimizer_impl minimize interface
avolkov-intel Oct 18, 2023
f0e3650
Remove redundant header and fix example
avolkov-intel Oct 18, 2023
dd4a40f
Remove redundatn imports
avolkov-intel Oct 18, 2023
cdcb434
Update makefile, remove dependency from rng_primitive
avolkov-intel Oct 19, 2023
87da255
Clang format
avolkov-intel Oct 19, 2023
5f22967
Update makefile
avolkov-intel Oct 23, 2023
d1cdf8d
Add iterations number parameter
avolkov-intel Oct 23, 2023
af113b3
Update devices list for logreg example
avolkov-intel Oct 25, 2023
f5872c5
Merge branch 'master' into dev/logreg-algo
avolkov-intel Oct 30, 2023
fc55338
Change fp type to float
avolkov-intel Oct 30, 2023
243d518
Address comments
avolkov-intel Nov 2, 2023
f29d54d
Adress changes, change iterations_number to iterations_count
avolkov-intel Nov 6, 2023
be6c81d
Substitute l1, l2 coefs to C - inverse regularization in the interface
avolkov-intel Nov 6, 2023
7735a5d
Remove class_count from descriptor constructor
avolkov-intel Nov 7, 2023
99e7975
Fix typo in result option naming
avolkov-intel Nov 7, 2023
123e398
Add skipif statement to ignore cpu testing
avolkov-intel Nov 7, 2023
8f60536
Remove redundant includes
avolkov-intel Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/oneapi/dal/algo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ALGOS = [
"kmeans_init",
"knn",
"linear_kernel",
"logistic_regression",
"logloss_objective",
"louvain",
"minkowski_distance",
Expand Down
20 changes: 20 additions & 0 deletions cpp/oneapi/dal/algo/logistic_regression.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright 2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#pragma once

#include "oneapi/dal/algo/logistic_regression/infer.hpp"
#include "oneapi/dal/algo/logistic_regression/train.hpp"
61 changes: 61 additions & 0 deletions cpp/oneapi/dal/algo/logistic_regression/BUILD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this is probably the only BUILD file needed within logistic_regression if there are no tests outside of logistic_regression/tests

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package(default_visibility = ["//visibility:public"])
load("@onedal//dev/bazel:dal.bzl",
"dal_module",
"dal_test_suite",
)

dal_module(
name = "core",
auto = True,
dal_deps = [
"@onedal//cpp/oneapi/dal:core",
"@onedal//cpp/oneapi/dal/algo/logistic_regression/backend:model_impl",
"@onedal//cpp/oneapi/dal/algo/logistic_regression/detail:optimizers",
],
)

dal_module(
name = "parameters",
dal_deps = [
"@onedal//cpp/oneapi/dal/algo/logistic_regression/parameters",
],
)

dal_module(
name = "logistic_regression",
dal_deps = [
":core",
":parameters",
"@onedal//cpp/oneapi/dal/algo/logistic_regression/detail",
"@onedal//cpp/oneapi/dal/algo/logistic_regression/backend",

]
)

dal_test_suite(
name = "interface_tests",
framework = "catch2",
compile_as = [ "dpc++" ],
hdrs = glob([
"test/*.hpp",
], exclude=[
"test/mpi_*.hpp",
"test/ccl_*.hpp"
]),
srcs = glob([
"test/*.cpp",
], exclude=[
"test/mpi_*.cpp",
"test/ccl_*.cpp"
]),
dal_deps = [
":logistic_regression",
],
)

dal_test_suite(
name = "tests",
tests = [
":interface_tests",
],
)
23 changes: 23 additions & 0 deletions cpp/oneapi/dal/algo/logistic_regression/backend/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package(default_visibility = ["//visibility:public"])
load("@onedal//dev/bazel:dal.bzl",
"dal_module",
"dal_test_suite",
)

dal_module(
name = "backend",
dal_deps = [
"@onedal//cpp/oneapi/dal/algo/logistic_regression/backend/cpu",
"@onedal//cpp/oneapi/dal/algo/logistic_regression/backend/gpu",
],
)

dal_module(
name = "model_impl",
hdrs = glob(["model_impl.hpp"]),
)

dal_module(
name = "optimizer_impl",
hdrs = glob(["optimizer_impl.hpp"]),
)
14 changes: 14 additions & 0 deletions cpp/oneapi/dal/algo/logistic_regression/backend/cpu/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package(default_visibility = ["//visibility:public"])
load("@onedal//dev/bazel:dal.bzl",
"dal_module",
"dal_test_suite",
)

dal_module(
name = "cpu",
auto = True,
dal_deps = [
"@onedal//cpp/oneapi/dal/algo/logistic_regression:core",
"@onedal//cpp/oneapi/dal/backend/primitives:common",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright 2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#pragma once

#include "oneapi/dal/algo/logistic_regression/infer_types.hpp"
#include "oneapi/dal/backend/dispatcher.hpp"

namespace oneapi::dal::logistic_regression::backend {

template <typename Float, typename Method, typename Task>
struct infer_kernel_cpu {
infer_result<Task> operator()(const dal::backend::context_cpu& ctx,
const detail::descriptor_base<Task>& params,
const infer_input<Task>& input) const;
};

} // namespace oneapi::dal::logistic_regression::backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright 2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#include "oneapi/dal/backend/interop/common.hpp"

#include "oneapi/dal/algo/logistic_regression/common.hpp"
#include "oneapi/dal/algo/logistic_regression/infer_types.hpp"
#include "oneapi/dal/algo/logistic_regression/backend/cpu/infer_kernel.hpp"

namespace oneapi::dal::logistic_regression::backend {

using dal::backend::context_cpu;

template <typename Float, typename Task>
struct infer_kernel_cpu<Float, method::dense_batch, Task> {
infer_result<Task> operator()(const context_cpu& ctx,
const detail::descriptor_base<Task>& desc,
const infer_input<Task>& input) const {
throw unimplemented(
dal::detail::error_messages::log_reg_dense_batch_method_is_not_implemented_for_cpu());
}
};

template struct infer_kernel_cpu<float, method::dense_batch, task::classification>;
template struct infer_kernel_cpu<double, method::dense_batch, task::classification>;

} // namespace oneapi::dal::logistic_regression::backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright 2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#pragma once

#include "oneapi/dal/algo/logistic_regression/train_types.hpp"
#include "oneapi/dal/backend/dispatcher.hpp"

namespace oneapi::dal::logistic_regression::backend {

template <typename Float, typename Method, typename Task>
struct train_kernel_cpu {
train_result<Task> operator()(const dal::backend::context_cpu& ctx,
const detail::descriptor_base<Task>& desc,
const detail::train_parameters<Task>& params,
const train_input<Task>& input) const;
};

} // namespace oneapi::dal::logistic_regression::backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright 2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#include "oneapi/dal/algo/logistic_regression/backend/cpu/train_kernel.hpp"
#include "oneapi/dal/exceptions.hpp"

namespace oneapi::dal::logistic_regression::backend {

using dal::backend::context_cpu;

template <typename Float, typename Task>
struct train_kernel_cpu<Float, method::dense_batch, Task> {
train_result<Task> operator()(const context_cpu& ctx,
const detail::descriptor_base<Task>& desc,
const detail::train_parameters<Task>& params,
const train_input<Task>& input) const {
throw unimplemented(
dal::detail::error_messages::log_reg_dense_batch_method_is_not_implemented_for_cpu());
}
};

template struct train_kernel_cpu<float, method::dense_batch, task::classification>;
template struct train_kernel_cpu<double, method::dense_batch, task::classification>;

} // namespace oneapi::dal::logistic_regression::backend
18 changes: 18 additions & 0 deletions cpp/oneapi/dal/algo/logistic_regression/backend/gpu/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package(default_visibility = ["//visibility:public"])
load("@onedal//dev/bazel:dal.bzl",
"dal_module",
"dal_test_suite",
)

dal_module(
name = "gpu",
auto = True,
dal_deps = [
"@onedal//cpp/oneapi/dal/backend/primitives:blas",
"@onedal//cpp/oneapi/dal/backend/primitives:common",
"@onedal//cpp/oneapi/dal/backend/primitives:lapack",
"@onedal//cpp/oneapi/dal/backend/primitives:objective_function",
"@onedal//cpp/oneapi/dal/backend/primitives:optimizers",
"@onedal//cpp/oneapi/dal/algo/logistic_regression:core",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright 2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#pragma once

#include "oneapi/dal/algo/logistic_regression/infer_types.hpp"
#include "oneapi/dal/backend/dispatcher.hpp"

namespace oneapi::dal::logistic_regression::backend {

template <typename Float, typename Method, typename Task>
struct infer_kernel_gpu {
infer_result<Task> operator()(const dal::backend::context_gpu& ctx,
const detail::descriptor_base<Task>& params,
const infer_input<Task>& input) const;
};

} // namespace oneapi::dal::logistic_regression::backend
Loading