[inductor][subgraph] Plumbing to get ShapeAsConstantBuffer from subgraph to main graph output (#147559)

I am unable to create a test case that fails without the next PR. The idea is to have a symint which is returned by the inner subgraph and then returned by the forward graph after partitioning.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/147559
Approved by: https://github.com/eellison
This commit is contained in:
Animesh Jain 2025-02-28 14:15:05 -08:00 committed by PyTorch MergeBot
parent c87097e74a
commit fd16311e7f
2 changed files with 5 additions and 1 deletions

View File

@ -1269,6 +1269,7 @@ class GraphLowering(torch.fx.Interpreter):
sympy.logic.boolalg.Boolean,
int,
ir.EffectfulKernel,
ir.ShapeAsConstantBuffer,
),
)
for x in result

View File

@ -208,6 +208,7 @@ def validate_ir(node_or_nodes: Optional[_NodeOrNodes]) -> None:
Expr,
int,
EffectfulKernel,
ShapeAsConstantBuffer,
),
), (
f"Found {type(nodes)}, which is not a supported top level IR node. See [Note: Inductor IR]"
@ -5166,7 +5167,7 @@ class ExternKernel(InputsKernel):
# TODO(jansel): impose layout preference on realized buffer
x.realize()
return x
if isinstance(x, (NonTensorObj)):
if isinstance(x, (NonTensorObj, ShapeAsConstantBuffer)):
return x
return cls.copy_input(x)
@ -7041,6 +7042,8 @@ class MutableBox(IRNode):
class TensorBox(MutableBox):
@staticmethod
def create(data): # type: ignore[no-untyped-def]
if isinstance(data, ShapeAsConstantBuffer):
return data
return TensorBox(StorageBox(data))