thunder.core.trace.TraceCtx

class thunder.core.trace.TraceCtx(fn=None)[source]

Bases: object

Trace representing fn.

Parameters:
fn[source]

Callable to represent. It’s either a callable written with pytorch functions or Module.

Type:

Callable | None

args[source]

Arguments of fn. Elements are proxified, e.g., torch.Tensor is converted to TensorProxy.

Type:

Any

kwargs[source]

Keyword arguments of fn. Values are converted to Proxy if possible.

Type:

dict[str, Any]

bound_symbols[source]

Each BoundSymbol represents one line of trace.

Type:

list[BoundSymbol]

scopes[source]

In most cases, same as [self.bound_symbols]. Direct modification of this attribute would provide better flexibility to trace transformation as in insert_inplace() and replace_inplace(). Also [tutorial] How to Implement CPU Offloading as Trace Transform would be a great read.

Type:

list[list[BoundSymbol]]

__init__(fn=None)[source]
Parameters:

fn (Optional[Callable]) –

Methods

__init__([fn])

add_bound_symbol(bsym)

rtype:

None

add_name(name)

rtype:

None

add_object(x)

rtype:

ContextObject

get_provenance()

rtype:

Optional[TraceProvenance]

has_name(name)

rtype:

bool

is_constant(x)

rtype:

bool

make_name([name, prefix])

rtype:

str

make_object_name(x)

rtype:

str

mark_complete()

rtype:

None

peek_scope()

rtype:

Optional[list]

pop_scope()

rtype:

list

post_unpack(fn)

rtype:

None

push_scope(scope)

rtype:

None

python(*[, print_depth, include_decorators])

rtype:

str

python_callable(*[, global_dicts])

rtype:

Callable

python_ctx()

rtype:

dict

save_trace(filename)

rtype:

None

set_current_source_location(filename, positions)

set_provenance(provenance)

rtype:

None

siginfo()

rtype:

SigInfo

unpacked()

rtype:

None

unpacking()

rtype:

None

Attributes

bound_symbols

output

tags