Closed
Description
Description
The changes introduced in aesara-devs/aesara#902 make it hard to safely subclass OpFromGraph
with initialization kwargs.
Here is an example:
import pytensor
import pytensor.tensor as pt
from pytensor.compile.builders import OpFromGraph
class OpFromGraphSub(OpFromGraph):
def __init__(self, *args, kwarg, **kwargs):
self.kwarg = kwarg
super().__init__(*args, **kwargs)
x = pytensor.shared(2)
y = pytensor.shared(3)
out = OpFromGraphSub([], [x + 1], kwarg="test")()
out.owner.op(y)
# TypeError: OpFromGraphSub.__init__() missing 1 required keyword-only argument: 'kwarg'
One would have to subclass made_node
for this to work correctly, but that's highly non-trivial.