torch.compile¶
- torch.compile(model=None, *, fullgraph=False, dynamic=False, backend='inductor', mode=None, options=None, disable=False)[source]¶
- Optimizes given model/function using TorchDynamo and specified backend. - Parameters:
- model (Callable) – Module/function to optimize 
- fullgraph (bool) – Whether it is ok to break model into several subgraphs 
- dynamic (bool) – Use dynamic shape tracing 
- backend (str or Callable) – backend to be used 
- mode (str) – Can be either “default”, “reduce-overhead” or “max-autotune” 
- options (dict) – A dictionary of options to pass to the backend. 
- disable (bool) – Turn torch.compile() into a no-op for testing 
 
- Return type:
 - Example: - @torch.compile(options={"matmul-padding": True}, fullgraph=True) def foo(x): return torch.sin(x) + torch.cos(x)