torch.fx.traceback.annotate_fn
- torch.fx.traceback.annotate_fn(annotation_dict)
A decorator that wraps a function with the annotate context manager. Use this when you want to annotate an entire function instead of a specific code block.
A decorator that wraps a function with the annotate context manager. Use this when you want to annotate an entire function instead of a specific code block.
This API is not compatible with fx.symbolic_trace or jit.trace. It’s intended to be used with PT2 family of tracers, e.g. torch.export and dynamo.
All operations in my_function will have {“pp_stage”: 1} in their metadata.
>>> @annotate_fn({"pp_stage": 1})
... def my_function(x):
... return x + 1