GraphAppendingTracer#
- class torch.fx.proxy.GraphAppendingTracer(graph)[source]#
Note
Backwards-compatibility for this API is guaranteed.
- create_arg(a)[source]#
A method that lowers the objects seen as arguments during symbolic evaluation into Argument types that can be stored in IR.
Can be override to support more trace-specific types.
Note
Backwards-compatibility for this API is guaranteed.
- create_node(kind, target, args, kwargs, name=None, type_expr=None)[source]#
Inserts a graph node given target, args, kwargs, and name.
This method can be overridden to do extra checking, validation, or modification of values used in node creation. For example, one might want to disallow in-place operations from being recorded.
Note
Backwards-compatibility for this API is guaranteed.
- Return type:
- create_proxy(kind, target, args, kwargs, name=None, type_expr=None, proxy_factory_fn=None)[source]#
Create a Node from the given arguments, then return the Node wrapped in a Proxy object.
If kind = ‘placeholder’, then we’re creating a Node that represents the parameter of a function. If we need to encode a default parameter, we use the
argstuple.argsis otherwise empty forplaceholderNodes.Note
Backwards-compatibility for this API is guaranteed.
- Return type:
- iter(obj)[source]#
- Called when a proxy object is being iterated over, such as
when used in control flow. Normally we don’t know what to do because we don’t know the value of the proxy, but a custom tracer can attach more information to the graph node using create_node and can choose to return an iterator.
Note
Backwards-compatibility for this API is guaranteed.
- Return type:
- keys(obj)[source]#
- Called when a proxy object is has the keys() method called.
This is what happens when ** is called on a proxy. This should return an iterator it ** is suppose to work in your custom tracer.
Note
Backwards-compatibility for this API is guaranteed.
- Return type:
- to_bool(obj)[source]#
- Called when a proxy object is being converted to a boolean, such as
when used in control flow. Normally we don’t know what to do because we don’t know the value of the proxy, but a custom tracer can attach more information to the graph node using create_node and can choose to return a value.
Note
Backwards-compatibility for this API is guaranteed.
- Return type: