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

Implementation of convolve #2205

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Implementation of convolve #2205

wants to merge 14 commits into from

Conversation

AlexanderKalistratov
Copy link
Collaborator

Add implementation of dpnp.convolve. Implementation is mostly based on already existing functionality developed for dpnp.correlate
Similar to scipy.signal.convolve method keyword is introduced, but unlike scipy.signal.convolve dpnp.convolve works only with 1-d arrays.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to 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?
  • If this PR is a work in progress, are you filing the PR as a draft?

Copy link
Contributor

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

Copy link
Contributor

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

@coveralls
Copy link
Collaborator

coveralls commented Mar 14, 2025

Coverage Status

coverage: 72.228% (+0.08%) from 72.152%
when pulling 4bb43c0 on convolve
into 04bfac7 on master.

Copy link
Contributor

github-actions bot commented Mar 14, 2025

Array API standard conformance tests for dpnp=0.18.0dev0=py312he4f9c94_66 ran successfully.
Passed: 1197
Failed: 0
Skipped: 14

@AlexanderKalistratov
Copy link
Collaborator Author

@antonwolfy please review

Copy link
Collaborator Author

@AlexanderKalistratov AlexanderKalistratov left a comment

Choose a reason for hiding this comment

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

@vtavana thanks for the review

please re-review.

Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com>
f"Received shapes: a.shape={a.shape}, v.shape={v.shape}"
)

a, v = dpnp.atleast_1d(a, v)
Copy link
Contributor

Choose a reason for hiding this comment

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

It needs to be done prior lines#477-486, because should check type of input arrays first. Otherwise there might be AttributeError exception raised:

np.convolve(1, 2)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 np.convolve(1, 2)

File ~/code/dpnp/dpnp/dpnp_iface_statistics.py:477, in convolve(a, v, mode, method)
    379 def convolve(a, v, mode="full", method="auto"):
    380     r"""
    381     Returns the discrete, linear convolution of two one-dimensional sequences.
    382     The convolution operator is often seen in signal processing, where it
   (...)    474
    475     """
--> 477     if a.size == 0 or v.size == 0:
    478         raise ValueError(
    479             f"Array arguments cannot be empty. "
    480             f"Received sizes: a.size={a.size}, v.size={v.size}"
    481         )
    482     if a.ndim > 1 or v.ndim > 1:

AttributeError: 'int' object has no attribute 'size'

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