Skip to content

Implement np.take in kernel by dpnp #246

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

Merged
merged 9 commits into from
Feb 24, 2021

Conversation

vlad-perevezentsev
Copy link
Contributor

No description provided.

@vlad-perevezentsev vlad-perevezentsev linked an issue Feb 10, 2021 that may be closed by this pull request
@@ -0,0 +1,63 @@
import numba_dppy.dpnp_glue.dpnpimpl as dpnp_ext
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to add copyright header

return c

test_indices = []
test_indices.append(np.array([1, 5, 1, 11, 3]))
Copy link
Contributor

Choose a reason for hiding this comment

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

May be it's better to simplify? Or what the reason of iterating over the list of indexes if you test them in the separate test?

Suggested change
test_indices.append(np.array([1, 5, 1, 11, 3]))
test_indices = [np.array([1, 5, 1, 11, 3]),]

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with Angelina.

for ind in test_indices:
self.assertTrue(
self.check_take_for_different_datatypes(
f, np.take, self.get_np_array(ind), [12], self.tys, matrix=False
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just cast value to np.array here for indexes. Function get_np_array is redundant

Copy link
Contributor

Choose a reason for hiding this comment

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

I also think the get_np_array is redundant, what are we trying to test throught this function?

@akharche
Copy link
Contributor

@reazulhoque Could you please look into this PR?


def test_take_indices(self):
@njit
def f(a, ind):
Copy link
Contributor

Choose a reason for hiding this comment

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

Both the f() function seems to perform the same thing, may be 1 common is good enough. Line 1453 and 1466.

):
for ty in tys:
if matrix:
a = np.arange(np.prod(np.array(dims)), dtype=ty).reshape(
Copy link
Contributor

Choose a reason for hiding this comment

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

If dims is expected to be a np.array may be let us pass an np.array instead of a list.

tys = [np.int32, np.uint32, np.int64, np.uint64, np.float, np.double]

def check_take_for_different_datatypes(
self, fn, test_fn, ind, dims, tys, matrix=None
Copy link
Contributor

Choose a reason for hiding this comment

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

Since matrix seems to be a boolean, let us assign a boolean as a default value?

@reazulhoque
Copy link
Contributor

@vlad-perevezentsev This should be merged with main and also Elena has a PR that adds the same file and other function of same category, we need to be aware of that.

Copy link
Contributor

@PokhodenkoSA PokhodenkoSA left a comment

Choose a reason for hiding this comment

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

LGTM

@PokhodenkoSA PokhodenkoSA merged commit 01bc8cb into IntelPython:main Feb 24, 2021
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.

Implement the take function via dpnp
4 participants