Skip to content

Add cosine distance algorithm#3248

Merged
ahuber21 merged 230 commits intouxlfoundation:mainfrom
richardnorth3:dev/cosine-dist-algo
Jul 31, 2025
Merged

Add cosine distance algorithm#3248
ahuber21 merged 230 commits intouxlfoundation:mainfrom
richardnorth3:dev/cosine-dist-algo

Conversation

@richardnorth3
Copy link
Copy Markdown
Contributor

@richardnorth3 richardnorth3 commented Jun 4, 2025

This PR implements the cosine distance algorithm for both the DAAL and oneDAL frameworks, computing pairwise cosine distances between feature vectors. The DAAL implementation includes block-based, batch processing containers, and complete user documentation. The oneDAL implementation adds GPU offload with SYCL/DPC++ support through compute kernels for both CPU and GPU backends, comprehensive test cases for both CPU and GPU, bazel build integration, and updated documentation with mathematical specifications and API references.

PR completeness and readability

  • I have reviewed my changes thoroughly before submitting this pull request.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes or created a separate PR with update and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have added a respective label(s) to PR if I have a permission for that.
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.
  • I have extended testing suite if new functionality was introduced in this PR.

richardnorth3 and others added 30 commits March 19, 2025 09:50
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
renovate bot and others added 17 commits July 8, 2025 09:23
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…foundation#3276)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alexander Andreev <[email protected]>
* Adds correlation distance algorithm, examples, docs, and unit tests

Signed-off-by: North Iii <[email protected]>
Co-authored-by: Victoriya Fedotova <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
Signed-off-by: richard.north.iii <[email protected]>
…3278)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* set init pointer to null

* disambiguate references to global object and instantiated object
* Added SVE intrinsics for postGemm function

* Removed SVE implementation of float exponential due to accuracy issues

* Format code using clang-format

---------

Co-authored-by: shubham.chaudhari <[email protected]>
@richardnorth3
Copy link
Copy Markdown
Contributor Author

/intelci: run

@richardnorth3
Copy link
Copy Markdown
Contributor Author

/intelci: run

Copy link
Copy Markdown
Contributor

@Vika-F Vika-F left a comment

Choose a reason for hiding this comment

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

LGTM

@richardnorth3
Copy link
Copy Markdown
Contributor Author

@ahuber21 could you approve your requested changes so this PR can be merged in?

@Vika-F Vika-F self-requested a review July 14, 2025 09:58
}
else if (na == 2)
{
NumericTable * yTable = const_cast<NumericTable *>(a[1]); /* y Input data */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
NumericTable * yTable = const_cast<NumericTable *>(a[1]); /* y Input data */
const NumericTable * yTable = a[1]; /* y Input data */

Copy link
Copy Markdown
Contributor

@Vika-F Vika-F Jul 16, 2025

Choose a reason for hiding this comment

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

Similar changes can be done in the lines 60, 61:

const NumericTable * xTable = a[0]; /* Input data */
NumericTable * rTable       = r[0]; /* Output data */

@ahuber21
Copy link
Copy Markdown
Contributor

@ahuber21 could you approve your requested changes so this PR can be merged in?

There are still some things that need to be addressed. See Vika's comments.

Copy link
Copy Markdown
Contributor

@ahuber21 ahuber21 left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of the issues as good as possible. @Vika-F let's keep an eye on this and aim for gradual improvement with future PRs.

@ahuber21 ahuber21 merged commit 4973b5c into uxlfoundation:main Jul 31, 2025
21 checks passed
@richardnorth3
Copy link
Copy Markdown
Contributor Author

Thank you @Vika-F @ahuber21 for the help!

Vika-F added a commit to Vika-F/daal that referenced this pull request Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dpc++ Issue/PR related to DPC++ functionality new algorithm New algorithm or method in oneDAL oneAPI Issue/PR related to oneAPI part

Projects

None yet

Development

Successfully merging this pull request may close these issues.