pymc-devs / pymc-devs/pytensor

CGemv fails with strides0 x

Open
#1,262 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.