-
Notifications
You must be signed in to change notification settings - Fork 217
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
initial commit for adding boost lib #2985
Draft
Alexandr-Solovev
wants to merge
3
commits into
uxlfoundation:main
Choose a base branch
from
Alexandr-Solovev:dev/asolovev_add_boost_library
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -128,6 +128,46 @@ class syevd_test : public te::float_algo_fixture<Float> { | |
} | ||
} | ||
|
||
void check_eigvals_with_eigen(const la::matrix<Float>& s, | ||
const la::matrix<Float>& eigvecs, | ||
const la::matrix<Float>& eigvals) const { | ||
INFO("convert results to float64"); | ||
const auto s_f64 = la::astype<double>(s); | ||
const auto eigvals_f64 = la::astype<double>(eigvals); | ||
const auto eigvecs_f64 = la::astype<double>(eigvecs); | ||
std::int64_t row_count = s.get_row_count(); | ||
std::int64_t column_count = s.get_column_count(); | ||
const Float* data = s.get_data(); | ||
|
||
Eigen::Matrix<Float, Eigen::Dynamic, Eigen::Dynamic> eigen_matrix(row_count, column_count); | ||
for (int i = 0; i < eigen_matrix.rows(); ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An Eigen matrix can also be created from a non-owned pointer for float/double data. I think something along the lines of |
||
for (int j = 0; j < eigen_matrix.cols(); ++j) { | ||
eigen_matrix(i, j) = data[i * column_count + j]; | ||
} | ||
} | ||
|
||
Eigen::SelfAdjointEigenSolver<Eigen::Matrix<Float, Eigen::Dynamic, Eigen::Dynamic>> es( | ||
eigen_matrix); | ||
|
||
auto eigenvalues = es.eigenvalues().real(); | ||
INFO("oneDAL eigvals vs Eigen eigvals"); | ||
la::enumerate_linear(eigvals_f64, [&](std::int64_t i, Float x) { | ||
REQUIRE(abs(eigvals_f64.get(i) - eigenvalues(i)) < 0.1); | ||
}); | ||
|
||
INFO("oneDAL eigvectors vs Eigen eigvectors"); | ||
auto eigenvectors = es.eigenvectors().real(); | ||
|
||
const double* eigenvec_ptr = eigvecs_f64.get_data(); | ||
//TODO: investigate Eigen classes and align checking between oneDAL and Eigen classes. | ||
for (int j = 0; j < eigvecs.get_column_count(); ++j) { | ||
auto column_eigen = eigenvectors.col(j); | ||
for (int i = 0; i < eigvecs.get_row_count(); ++i) { | ||
REQUIRE((abs(eigenvec_ptr[j * row_count + i]) - abs(column_eigen(i))) < 0.1); | ||
} | ||
} | ||
} | ||
|
||
void check_eigvals_are_ascending(const la::matrix<Float>& eigvals) const { | ||
INFO("check eigenvalues order is ascending"); | ||
la::enumerate_linear(eigvals, [&](std::int64_t i, Float x) { | ||
|
@@ -158,6 +198,7 @@ TEMPLATE_LIST_TEST_M(syevd_test, "test syevd with pos def matrix", "[sym_eigvals | |
|
||
this->check_eigvals_definition(s, eigenvectors, eigenvalues); | ||
this->check_eigvals_are_ascending(eigenvalues); | ||
this->check_eigvals_with_eigen(s, eigenvectors, eigenvalues); | ||
} | ||
|
||
TEMPLATE_LIST_TEST_M(syevd_test, "test syevd with pos def matrix 2", "[sym_eigvals]", eigen_types) { | ||
|
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
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"]) | ||
|
||
cc_library( | ||
name = "boost", | ||
srcs = glob([ | ||
"libs/libboost*.a", | ||
]), | ||
hdrs = glob([ | ||
"boost/**/*.h", | ||
"boost/**/*.hpp", | ||
"boost/**/*.ipp", | ||
]), | ||
includes = [ | ||
".", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
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,8 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_library( | ||
name = "eigen", | ||
hdrs = glob(["Eigen/**"]), | ||
includes = [""], | ||
visibility = ["//visibility:public"], | ||
) |
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.
As an alternative, perhaps the input values could be hard-coded along with the solutions instead of checking them against a different library.
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.
Yes, but with this solution there is no opportunity to use random generated data(I mean extend tests with for example row_count = GENERATE(3, 28, 125, 256);) and also it will be complicated to check results for big datasets
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.
How about putting them in the existing folders with .csv files that have data and expected results?
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.
It's possible, but let's say for pca it's necessary to contain gold eigenvectors, eigenvalues, and it will increase the total size of the repo, especially with big datasets. I see no reasons to avoid this pr tbh