Skip to content

Implement dpnp.interp() #2417

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
wants to merge 44 commits into
base: master
Choose a base branch
from
Open

Implement dpnp.interp() #2417

wants to merge 44 commits into from

Conversation

vlad-perevezentsev
Copy link
Collaborator

This PR suggests adding an implementation of dpnp.interp() with sycl_kernel including support for all function arguments.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

Copy link
Contributor

github-actions bot commented Apr 11, 2025

Array API standard conformance tests for dpnp=0.18.0dev1=py312he4f9c94_56 ran successfully.
Passed: 1222
Failed: 0
Skipped: 9

@coveralls
Copy link
Collaborator

coveralls commented Apr 11, 2025

Coverage Status

coverage: 72.039% (-0.2%) from 72.271%
when pulling 62802f8 on impl_of_interp
into 6a81e55 on master.

Copy link
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2417/index.html

@antonwolfy antonwolfy added this to the 0.18.0 release milestone Apr 14, 2025
x = dpnp.asarray(x, dtype=x_float_type, order="C")
xp = dpnp.asarray(xp, dtype=x_float_type, order="C")

out_dtype = dpnp.common_type(x, xp, fp)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the result has at least default real floating data type, isn't it?

Suggested change
out_dtype = dpnp.common_type(x, xp, fp)
out_dtype = dpnp.common_type(x_float_type, fp)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

dpnp.common_type takes *arrays as input argument and I can not pass x_float_type


if period is not None:
period = _validate_interp_param(period, "period", exec_q, usm_type)
if period == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

That check leads to SYCL queue synchronization. Is that expected?

struct value_type_of<std::complex<T>>
{
using type = T;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This implementation has a problem of not supporting const std::complex<T> case.

Better approach could be something like:

template<typename T, bool hasValueType>
struct value_type_of_impl;

template<typename T>
struct value_type_of_impl<T, false>
{
    using type = T;
};

template<typename T>
struct value_type_of_impl<T, true>
{
    using type = typename T::value_type;
};

template<T>
using value_type_of = value_type_of_impl<T, is_complex_v<T>>;

template<T>
using value_type_of_t = typename value_type_of<T>::type;

And in future is_complex could be replaced with proper has_value_type if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is good point but I would prefer using type = typename std::remove_cv_t<T>::value_type to ensure it works correctly with const types

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean something like?

struct value_type_of<std::complex<T>>
{
    using type = typename std::remove_cv_t<T>::value_type;
};

Then, I believe, it will not work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually meant removing const in value_type_of_impl<T, true>

template<typename T>
struct value_type_of_impl<T, true>
{
    using type = typename std::remove_cv_t<T>::value_type;
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 9e06cc3

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

Successfully merging this pull request may close these issues.

4 participants