Discrete 1D convolutions [FR]
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
I’m working on a project whose main bottleneck is a series of 1d discrete convolutions, basically a lot of dot products within a for loop. Similar computations also came up in the forums a couple of times (for example here).
I’m wondering if there is a way to make them more efficient. Would it be helpful to add something like a conv1d function to stan-math? Is there a way to implement conv1d(x, kernel) such that it is more efficient than:
for (i in T:n) {
y[i] = dot_product(kernel, x[(i-T+1):i]);
}
I guess there are many subtleties here that I'm not aware of (numpy convolve has 3 modes - "full", "valid" and "same" - to handle various padding and border scenarios), just curious if this is relevant/interesting.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposed conv1d(x, kernel) API and the existing Stan loop shown in the issue, then review the linked forum discussion for prior performance considerations. Define the supported boundary modes and establish whether the implementation is faster than direct dot products; no source file or test is named, so both the API location and validation plan must be determined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100