Implement dpnp.compress and dpnp_array.compress method#2177
Merged
antonwolfy merged 21 commits intoIntelPython:masterfrom Nov 26, 2024
Merged
Implement dpnp.compress and dpnp_array.compress method#2177antonwolfy merged 21 commits intoIntelPython:masterfrom
dpnp.compress and dpnp_array.compress method#2177antonwolfy merged 21 commits intoIntelPython:masterfrom
Conversation
cf9df6d to
9b05295
Compare
antonwolfy
reviewed
Nov 18, 2024
antonwolfy
reviewed
Nov 18, 2024
antonwolfy
reviewed
Nov 19, 2024
antonwolfy
reviewed
Nov 19, 2024
antonwolfy
reviewed
Nov 19, 2024
antonwolfy
reviewed
Nov 19, 2024
Also disable checks for protected access, as `compress` uses dpctl.tensor private functions
Also removes an unnecessary check per PR review
Also fix a typo when `condition` is not an array
Also tweaks to docstring
Should slightly improve efficiency by escaping an additional copy where `out` is not `None` and flattening of indices
f8886cd to
edace9e
Compare
antonwolfy
reviewed
Nov 25, 2024
antonwolfy
approved these changes
Nov 26, 2024
Contributor
antonwolfy
left a comment
There was a problem hiding this comment.
Thank you @ndgrigorian. I have only a minor comment, but in overall LGTM!
antonwolfy
approved these changes
Nov 26, 2024
Contributor
antonwolfy
left a comment
There was a problem hiding this comment.
Thank you @ndgrigorian
Collaborator
Author
|
@antonwolfy CI is passed, please merge at your convenience |
github-actions bot
added a commit
that referenced
this pull request
Nov 26, 2024
* Implement dpnp.compress * Add `dpnp_array.compress` method * Break up `compress` to satisfy pylint Also disable checks for protected access, as `compress` uses dpctl.tensor private functions * Unmute third-party tests for `compress` * Use `get_usm_allocations` in `compress` * Fix bug where `out` in `compress` is dpnp_array Also removes an unnecessary check per PR review * Apply comments per PR review by @antonwolfy Also fix a typo when `condition` is not an array * Remove branching when `condition` is an array Also tweaks to docstring * Add tests for `compress` * Re-use `_take_index` for `dpnp.take` Should slightly improve efficiency by escaping an additional copy where `out` is not `None` and flattening of indices * Change error for incorrect out array dtype to `TypeError` * Move compress tests into a TestCompress class * Use NumPy in compress tests * Add `no_none=True` to `test_compress_condition_all_dtypes` * Add USM type and SYCL queue tests for `compress` * More tests for compress added * Docstring change per PR review * Integrate test for compute follows data in compress into test_2in_1out * Add test for `dpnp_array.compress` and add a test for strided inputs to `compress` * Refactor `test_compress` in test_usm_type.py into `test_2in_1out` 367e74e
vtavana
pushed a commit
that referenced
this pull request
Dec 2, 2024
* Implement dpnp.compress * Add `dpnp_array.compress` method * Break up `compress` to satisfy pylint Also disable checks for protected access, as `compress` uses dpctl.tensor private functions * Unmute third-party tests for `compress` * Use `get_usm_allocations` in `compress` * Fix bug where `out` in `compress` is dpnp_array Also removes an unnecessary check per PR review * Apply comments per PR review by @antonwolfy Also fix a typo when `condition` is not an array * Remove branching when `condition` is an array Also tweaks to docstring * Add tests for `compress` * Re-use `_take_index` for `dpnp.take` Should slightly improve efficiency by escaping an additional copy where `out` is not `None` and flattening of indices * Change error for incorrect out array dtype to `TypeError` * Move compress tests into a TestCompress class * Use NumPy in compress tests * Add `no_none=True` to `test_compress_condition_all_dtypes` * Add USM type and SYCL queue tests for `compress` * More tests for compress added * Docstring change per PR review * Integrate test for compute follows data in compress into test_2in_1out * Add test for `dpnp_array.compress` and add a test for strided inputs to `compress` * Refactor `test_compress` in test_usm_type.py into `test_2in_1out`
vtavana
pushed a commit
that referenced
this pull request
Dec 2, 2024
* Implement dpnp.compress * Add `dpnp_array.compress` method * Break up `compress` to satisfy pylint Also disable checks for protected access, as `compress` uses dpctl.tensor private functions * Unmute third-party tests for `compress` * Use `get_usm_allocations` in `compress` * Fix bug where `out` in `compress` is dpnp_array Also removes an unnecessary check per PR review * Apply comments per PR review by @antonwolfy Also fix a typo when `condition` is not an array * Remove branching when `condition` is an array Also tweaks to docstring * Add tests for `compress` * Re-use `_take_index` for `dpnp.take` Should slightly improve efficiency by escaping an additional copy where `out` is not `None` and flattening of indices * Change error for incorrect out array dtype to `TypeError` * Move compress tests into a TestCompress class * Use NumPy in compress tests * Add `no_none=True` to `test_compress_condition_all_dtypes` * Add USM type and SYCL queue tests for `compress` * More tests for compress added * Docstring change per PR review * Integrate test for compute follows data in compress into test_2in_1out * Add test for `dpnp_array.compress` and add a test for strided inputs to `compress` * Refactor `test_compress` in test_usm_type.py into `test_2in_1out`
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR proposes an implementation for
dpnp.compressusingdpctl.tensorkernels.nonzerois used to accumulate theconditioninto 1d array of indices, which are then used to take the appropriate slices of the array. WhenaxisisNone, the operand array is flattened.The coupled
dpnp_array.compressmethod is implemented through a simple call to thecompressfunction,