torch.compiler.allow_in_graph¶
- torch.compiler.allow_in_graph(fn)[source]¶
Customize which functions compilation will include in the generated graph. It bypasses all introspection of the symbolic python code in favor of directly writing it to the graph. If fn is a list or tuple of callables it recursively applies
allow_in_graph()
to each function and returns a new list or tuple containing the modified functions- Parameters
fn – A callable representing the function to be included in the graph.
Warning
allow_in_graph()
skips TorchDynamo completely on the decorated function skipping all TorchDynamo safety checks (graph breaks, handling closures, etc). Therefore, one has to be very careful withallow_in_graph()
since subsystems like AOT Autograd rely on torchdynamo If not careful, this could lead to soundness and really hard-to-debug issues.