pymc-devs / pymc-devs/pytensor
CGemv fails with strides0 x
Open
Nobody has claimed this yet.
bug
C-backend
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
import pytensor
import pytensor.tensor as pt
import numpy as np
from pytensor.compile.mode import get_mode
from pytensor.tensor.blas_c import CGemv
A = pt.tensor("A", shape=(None, None))
x = pt.tensor("x", shape=(None,))
out = CGemv(inplace=False)(
pt.empty(A.shape[0]),
pt.constant(np.array(1.0, dtype="float64")),
A,
x,
pt.constant(np.array(0.0, dtype="float64"))
)
fn = pytensor.function([A, x], out)
A_test = np.array(np.ones((5, 3)), dtype="float64")
x_test = np.array(1.0, dtype="float64")
x_test = np.broadcast_to(x_test, (3,)) # x_test.strides == (0,)
fn(A_test, x_test) # Intel oneMKL ERROR: Parameter 8 was incorrect on entry to DGEMV .
This showed up in a PyMC test now that DimShuffle creates 0-strides inputs
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 at the CGemv entry point in pytensor.tensor.blas_c and reproduce the provided example with the broadcasted x input whose stride is zero. Trace how that input reaches the BLAS call, then verify the example runs without the DGEMV parameter error and add coverage for the zero-stride case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100