Do not forward parent's value range to CSE variable for variables created within codegen. (#123099)

Consider we are generating code for `ops.gt`, and within it we call
`ops.to_dtype`. Before, we would forward the bounds from `gt` to the
to the result of `to_dtype`, which is wrong.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/123099
Approved by: https://github.com/jgong5, https://github.com/peterbell10
This commit is contained in:
lezcano 2024-04-22 18:44:32 +00:00 committed by PyTorch MergeBot
parent edcd968b51
commit 9a5b4d2403

View File

@ -1456,8 +1456,9 @@ class Kernel(CodeGen):
def inner(*args, **kwargs):
# TritonTemplateKernel has no current_node
buf_bounds = ValueRanges.unknown()
if hasattr(V.interpreter, "current_node"):
fx_node = V.interpreter.current_node
if (
fx_node := getattr(V.interpreter, "current_node", None)
) and fx_node.target == name:
assert isinstance(self.node_to_bounds, dict)
buf_bounds = self.node_to_bounds.get(
fx_node, ValueRanges.unknown()