|
As part of a library (https://github.com/scipp-atlas/pyhs3/), we keep track of the inputs globally based on what the user provides to be able to compile functions later, however there was some interesting behavior where the from pytensor.printing import debugprint
import pytensor.tensor as pt
from pytensor.graph.traversal import explicit_graph_inputs
x = pt.vector("x")[:, None]
y = pt.vector("y")[:, None]
c = pt.scalar("c")
print(f'id(x) = {id(x)}')
print(f'id(y) = {id(y)}')
print(f'id(c) = {id(c)}')
result = pt.math.exp(x*y*c)
print('debugprint(result)')
debugprint(result)
for variable in explicit_graph_inputs([result]):
print(f'variable={variable}, id={id(variable)}, debugprint:')
debugprint(variable)The output of the above gives and I noticed the |
Replies: 1 comment 2 replies
|
For further context, I am trying to reproduce or MWE this problematic code below: where this version works however, I'm likely running into problems where my inputs need to be the variable, not the expanded-dimensions-variable when I compile the function? |
Ahh, I think I'm understanding and I hit a red-herring when I'm trying to debug. I should keep track of the variable, not the expanded-dimension one, when I'm trying to build these graphs and use
clone_replace. Here's why:This works absolutely fine (a subgraph here). …