-
Notifications
You must be signed in to change notification settings - Fork 213
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
avolkov-intel
merged 71 commits into
oneapi-src:master
from
avolkov-intel:dev/logreg-algo
Nov 8, 2023
Merged
Changes from 70 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
730c623
Initial commit
avolkov-intel 103b005
Add tests
avolkov-intel fc75c58
Add cg_solver primitive to solve equation Ax = b
avolkov-intel 520b811
Merge branch 'master' into dev/cg-solver
avolkov-intel d4b97c9
Move newton_cg primitve to optimizators primitive
avolkov-intel a68c6f0
Define newton_cg optimization function
avolkov-intel 7d56a99
Add backtracking algorithm for optimal alpha, implement newton_cg solver
avolkov-intel 1f36dd6
Fix errors, add tests for newton-cg
avolkov-intel 5fb7117
Remove redundant wait_and_throw, add links to sources
avolkov-intel 93e428d
Ensure code stability and fix minor issues
avolkov-intel 9eb51f5
Add sycl::fill, sycl::fabs and add specifiers for virtual functions
avolkov-intel 5c3fa2e
Remove redundant package dependency, update default values for Float …
avolkov-intel 7d2bdaf
Change update_x return type to event_vector, rename test function and…
avolkov-intel 890e1da
Initial commit
avolkov-intel ff71dfb
Split logloss and derivative functions, decrease the number of parame…
avolkov-intel 8f945a1
Delete redundant compute functions, deselect tests
avolkov-intel 4d71e82
Add LogLossFunction class and cover it with tests
avolkov-intel 551131d
Merge master
avolkov-intel 1e53e75
Fix bugs, rename kernels and remove redundant, update perforamnce tests
avolkov-intel 9fdbe1d
Merge branch 'master' into dev/logloss-functor
avolkov-intel 16a2312
Add wait and throw after gemv events
avolkov-intel 10bee38
Merge branch 'master' into dev/logloss-functor
avolkov-intel 3c026da
Minor
avolkov-intel a66aab2
Fix error and add batch test
avolkov-intel 6534dac
Add const qualifier for table with data
avolkov-intel e559daf
Merge remote-tracking branch 'origin/master' into dev/logloss-functor
avolkov-intel 10df0e8
Minor
avolkov-intel a11026c
Add LogReg test to newton_cg optimizer
avolkov-intel 5c4f579
Add LogReg algorithm interface
avolkov-intel 158c6fa
Add BUILD files, vanila implementation and tmp test
avolkov-intel 5510f5e
Add test
avolkov-intel 72ec43c
Minor
avolkov-intel d4764dd
Update train kernel
avolkov-intel 59fb63b
Add GPU infer kernels to LogReg algo
avolkov-intel 1e40174
Add logistic regression dpc example
avolkov-intel 1927003
Fix GPU test failures: PCA (#2531)
inteldimitrius 744f259
Support building reference backend with clang (#2529)
keeranroth 9188113
oneDAL development env docker image (#2513)
napetrov b3e0deb
chore(deps): update actions/checkout digest to 8ade135 (#2521)
renovate[bot] 927c008
Update version to 2024.0.1 (#2533)
Alexsandruss e5222fd
Online interfaces for LOM (#2483)
Alexandr-Solovev 44c3fd3
chore(deps): update dependency urllib3 to v2.0.6 [security] (#2536)
renovate[bot] 9c778cf
Minor
avolkov-intel 2651049
Merge master
avolkov-intel f2a4c25
Change task name to binary classification and update an example
avolkov-intel d8cc4cc
Add template optimizer parameter to descriptor, add optimizer factory…
avolkov-intel 5efce33
Change unimplemented error name thrown in cpu kernel
avolkov-intel 2606a2a
Move data to gpu before training
avolkov-intel 3cdc96b
Minor
avolkov-intel 57b8125
Change dependency graph to address error, fix tests
avolkov-intel 26367de
Add optimizer descriptor as a template parameter
avolkov-intel 19c0764
Update interface, improve primitive stability
avolkov-intel 32cbc1a
Move the optimizer dispatching logic to minimize function
avolkov-intel ec46575
Minor
avolkov-intel 4f9b51e
Remove debug output, change optimizer_impl minimize interface
avolkov-intel f0e3650
Remove redundant header and fix example
avolkov-intel dd4a40f
Remove redundatn imports
avolkov-intel cdcb434
Update makefile, remove dependency from rng_primitive
avolkov-intel 87da255
Clang format
avolkov-intel 5f22967
Update makefile
avolkov-intel d1cdf8d
Add iterations number parameter
avolkov-intel af113b3
Update devices list for logreg example
avolkov-intel f5872c5
Merge branch 'master' into dev/logreg-algo
avolkov-intel fc55338
Change fp type to float
avolkov-intel 243d518
Address comments
avolkov-intel f29d54d
Adress changes, change iterations_number to iterations_count
avolkov-intel be6c81d
Substitute l1, l2 coefs to C - inverse regularization in the interface
avolkov-intel 7735a5d
Remove class_count from descriptor constructor
avolkov-intel 99e7975
Fix typo in result option naming
avolkov-intel 123e398
Add skipif statement to ignore cpu testing
avolkov-intel 8f60536
Remove redundant includes
avolkov-intel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
31 changes: 31 additions & 0 deletions
31
cpp/oneapi/dal/algo/logistic_regression/backend/cpu/infer_kernel.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
40 changes: 40 additions & 0 deletions
40
cpp/oneapi/dal/algo/logistic_regression/backend/cpu/infer_kernel_dense_batch.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
32 changes: 32 additions & 0 deletions
32
cpp/oneapi/dal/algo/logistic_regression/backend/cpu/train_kernel.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
38 changes: 38 additions & 0 deletions
38
cpp/oneapi/dal/algo/logistic_regression/backend/cpu/train_kernel_dense_batch.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
31 changes: 31 additions & 0 deletions
31
cpp/oneapi/dal/algo/logistic_regression/backend/gpu/infer_kernel.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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