Skip to content

Renamed output_type_depends_on_input_value to data_dependent_output_shapes #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pytensor/graph/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ def clone_with_new_inputs(

# Some Ops like Alloc require the node to always be rebuilt in non-strict mode
# as the output type depends on the input values and not just their types
output_type_depends_on_input_value = self.op._output_type_depends_on_input_value
data_dependent_output_shape = self.op.data_dependent_output_shape

for i, (curr, new) in enumerate(zip(self.inputs, new_inputs, strict=True)):
# Check if the input type changed or if the Op has output types that depend on input values
if (curr.type != new.type) or output_type_depends_on_input_value:
if (curr.type != new.type) or data_dependent_output_shape:
# In strict mode, the cloned graph is assumed to be mathematically equivalent to the original one.
# We only need to rebuild a node when the new input has a different, but compatible, type.
# This can happen e.g., when we provide a new input with a more specialized static shape.
Expand Down
2 changes: 1 addition & 1 deletion pytensor/graph/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Op(MetaObject):
itypes: Sequence["Type"] | None = None
otypes: Sequence["Type"] | None = None

_output_type_depends_on_input_value = False
data_dependent_output_shape = False
"""
Whether the static output type depends on the inferred value of one of the inputs.
(e.g, via constant folding or static shape inference).
Expand Down
6 changes: 3 additions & 3 deletions pytensor/tensor/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ def triu_indices_from(


class Eye(Op):
_output_type_depends_on_input_value = True
data_dependent_output_shape = True
__props__ = ("dtype",)

def __init__(self, dtype=None):
Expand Down Expand Up @@ -1577,7 +1577,7 @@ class Alloc(COp):
"""

_f16_ok = True
_output_type_depends_on_input_value = True
data_dependent_output_shape = True

__props__ = ()

Expand Down Expand Up @@ -4213,7 +4213,7 @@ def perform(self, node, inputs, outputs):
class AllocEmpty(COp):
"""Implement Alloc on the cpu, but without initializing memory."""

_output_type_depends_on_input_value = True
data_dependent_output_shape = True

__props__ = ("dtype",)
params_type = ParamsType(typecode=int32)
Expand Down
2 changes: 1 addition & 1 deletion pytensor/tensor/random/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RandomVariable(Op):

"""

_output_type_depends_on_input_value = True
data_dependent_output_shape = True

__props__ = ("name", "signature", "dtype", "inplace")
default_output = 1
Expand Down
4 changes: 2 additions & 2 deletions pytensor/tensor/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class SpecifyShape(COp):
view_map = {0: [0]}
__props__ = ()
_f16_ok = True
_output_type_depends_on_input_value = True
data_dependent_output_shape = True

def make_node(self, x, *shape):
x = ptb.as_tensor_variable(x)
Expand Down Expand Up @@ -619,7 +619,7 @@ class Reshape(COp):

view_map = {0: [0]} # output 0 is potentially aliased to inputs [0]
_f16_ok = True
_output_type_depends_on_input_value = True
data_dependent_output_shape = True

check_input = False
__props__ = ("ndim",)
Expand Down