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

Update oneDAL PCA infer method #2410

Closed

Conversation

md-shafiul-alam
Copy link
Contributor

@md-shafiul-alam md-shafiul-alam commented Jun 6, 2023

Description

The changes are proposed to move some computations from python wrappers to oneDAL to improve performance of python libraries.

Changes proposed in this pull request:

  • Oneapi model class for PCA has been extended to allow passing means, eigenvalues, and variances from python
  • Support for whiten has been added in oneDAL if eigenvalues are passed
  • Data for inference will be mean centered if mean is passed
  • Three primitives have been added: Elementwise subtraction of 1d array from 2d array (required for mean centering), elementwise division of 2d array by 1d array (required for whitening), SQRT of an 1d array (required for whitening). The primitives are placed under stat temporarily.

cpp/oneapi/dal/algo/pca/backend/gpu/infer_kernel_dpc.cpp Outdated Show resolved Hide resolved
}

const auto res_array = res_nd.flatten(queue, { gemm_event });
const auto res_table = homogen_table::wrap(res_array, row_count, component_count);
return result_t{}.set_transformed_data(res_table);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

it seems to me that our bazel tests almost do not cover infer for pca, might be a good time to add them

Float(1.0),
Float(0.0),
{ mean_center_event });
gemm_event.wait_and_throw();
Copy link
Contributor

Choose a reason for hiding this comment

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

WHat is the point of waiting for the event here?

@@ -51,6 +51,98 @@ sycl::event means(sycl::queue& q,
});
}

// Subtract 1d array from 2d array elementwise
template <typename Float>
sycl::event elementwise_difference(sycl::queue& q,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use elementwise operations that are already present


// SQRT of 1d array elementwise
template <typename Float>
sycl::event elementwise_sqrt(sycl::queue& q,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same


// Divide 2d array by 1d array elementwise
template <typename Float>
sycl::event elementwise_division(sycl::queue& q,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

@md-shafiul-alam md-shafiul-alam marked this pull request as draft July 17, 2023 11:59
@icfaust
Copy link
Contributor

icfaust commented Nov 10, 2023

How does this PR compare to #2573 ?

@md-shafiul-alam
Copy link
Contributor Author

How does this PR compare to #2573 ?

2573 is an updated version of this. Closing this one as duplicate.

@md-shafiul-alam
Copy link
Contributor Author

Changes have been moved to #2573, closed as duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants