-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Description
Description
This is a weird one, it showed up when I tried to benchmark the same Scan with CVM vs C linker.
import numpy as np
import pytensor
import pytensor.tensor as pt
from pytensor.compile.mode import Mode
from pytensor.graph.basic import NominalVariable
x1 = NominalVariable(0, pt.vector("x", shape=(10,)).type)
y1 = NominalVariable(1, pt.vector("y", shape=(10,)).type)
const1 = np.arange(10)
out = x1 + const1 * y1
fn = pytensor.function([x1, y1], [pytensor.Out(out, borrow=True)], mode=Mode(linker="c", optimizer="fast_run"))
fn(np.zeros(10), np.zeros(10))
fn = pytensor.function([x1, y1], [pytensor.Out(out, borrow=True)], mode=Mode(linker="cvm", optimizer="fast_run"))
fn(np.zeros(10), np.zeros(10)) # ValueError: expected an ndarray, not None
Compiling the first function with borrow=True
, with a fresh cache, causes the other to fail (regardless of which one is first). It only works with NominalVariables and borrow=True. I suspect the C code between the two linkers is getting mixed up due to having the same hash.
Without NominalVariables I get two compiled C-files with hashes:
C-vm linker hash: me15b4d900f6d9189f2af261d5e6d9ac30f6ce6b9a0ae40b3ec2ab81e097b6c69
C-linker hash: m1a6dcbffbd7ed86f7db9c47290cd9ba06bd840fe2681c1fb1be255908078682f
But with NominalVariables, only the first gets built, suggesting it is being reused for the second linker incorrectly
Metadata
Metadata
Assignees
Labels
No labels