-
Notifications
You must be signed in to change notification settings - Fork 184
Initial dpctl tensor removal #2779
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
Open
ethanglaser
wants to merge
7
commits into
uxlfoundation:main
Choose a base branch
from
ethanglaser:dev/eglaser-dcptl-rm-pt1
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.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c869820
Initial dpctl tensor removal
ethanglaser a78832f
fixes and formatting
ethanglaser 9f59916
re-add internal dpctl handling
ethanglaser 7878669
minor
ethanglaser 860c6d7
Merge branch 'main' into dev/eglaser-dcptl-rm-pt1
ethanglaser 8dde020
remove unnecessary dpnp.asnumpy calls
ethanglaser a933b3c
fixes
ethanglaser 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,11 +14,11 @@ | |
| # limitations under the License. | ||
| # ============================================================================== | ||
|
|
||
| # sklearnex IncrementalPCA example for GPU offloading with DPCtl usm ndarray: | ||
| # sklearnex IncrementalPCA example for GPU offloading with DPNP ndarray: | ||
|
Contributor
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. Does it make sense to have examples that offload to GPU through DPNP arrays if there's already support for array API that can avoid transferring data back and forth with a one-liner change? |
||
| # SKLEARNEX_PREVIEW=YES python ./incremental_pca_dpctl.py | ||
|
|
||
| import dpctl | ||
| import dpctl.tensor as dpt | ||
| import dpnp | ||
|
|
||
| # Import estimator via sklearnex's patch mechanism from sklearn | ||
| from sklearnex import patch_sklearn, sklearn_is_patched | ||
|
|
@@ -35,23 +35,23 @@ | |
| # Or just directly import estimator from sklearnex namespace. | ||
| # from sklearnex.preview.decomposition import IncrementalPCA | ||
|
|
||
| # We create GPU SyclQueue and then put data to dpctl tensor using | ||
| # We create GPU SyclQueue and then put data to dpnp arrays using | ||
| # the queue. It allows us to do computation on GPU. | ||
| queue = dpctl.SyclQueue("gpu") | ||
|
|
||
| incpca = IncrementalPCA() | ||
|
|
||
| # We do partial_fit for each batch and then print final result. | ||
| X_1 = dpt.asarray([[-1, -1], [-2, -1]], sycl_queue=queue) | ||
| X_1 = dpnp.asarray([[-1, -1], [-2, -1]], sycl_queue=queue) | ||
| result = incpca.partial_fit(X_1) | ||
|
|
||
| X_2 = dpt.asarray([[-3, -2], [1, 1]], sycl_queue=queue) | ||
| X_2 = dpnp.asarray([[-3, -2], [1, 1]], sycl_queue=queue) | ||
| result = incpca.partial_fit(X_2) | ||
|
|
||
| X_3 = dpt.asarray([[2, 1], [3, 2]], sycl_queue=queue) | ||
| X_3 = dpnp.asarray([[2, 1], [3, 2]], sycl_queue=queue) | ||
| result = incpca.partial_fit(X_3) | ||
|
|
||
| X = dpt.concat((X_1, X_2, X_3)) | ||
| X = dpnp.concat((X_1, X_2, X_3)) | ||
| transformed_X = incpca.transform(X) | ||
|
|
||
| print(f"Principal components:\n{result.components_}") | ||
|
|
@@ -61,7 +61,7 @@ | |
| # We put the whole data to fit method, it is split automatically and then | ||
| # partial_fit is called for each batch. | ||
| incpca = IncrementalPCA(batch_size=3) | ||
| X = dpt.asarray([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) | ||
| X = dpnp.asarray([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) | ||
| result = incpca.fit(X) | ||
| transformed_X = incpca.transform(X) | ||
|
|
||
|
|
||
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Is it Ok to still have
dpctl.SyclQueueafter dpctl tensor removal?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, that's not going to be removed.
But since this is using a queue object, maybe it'd be better to offload to that instead of creating dpnp arrays on GPU that will then be moved to CPU and back again to GPU during the call.