GB0036

Graph-Break Type

Short name describing what triggered the graph break

Dynamic shape operator

Context

Values or code snippet captured at the break point

str(cause.func)

Explanation

Explanation of why the graph break was triggered

Operator {cause.func}’s output shape depends on input Tensor data.

Hints

Hints on how to resolve the graph break

Additional Information

Example code that causes the graph break is:

def fn():
    return torch.nonzero(torch.rand([10, 10]))

A sample workaround that shows you how you can fix this:

def fn():
    return torch.nonzero(torch.rand([10, 10]))

with torch._dynamo.config.patch(capture_dynamic_output_shape_ops=True):
    compiled_fn = torch.compile(fn, backend="eager", fullgraph=True)
    result = compiled_fn()

Click here to add Additional Info

Back to Registry