thunder.core.symbol.BoundSymbol

class thunder.core.symbol.BoundSymbol(sym, args, kwargs, output, subsymbols=(), header='', source_filename=None, source_positions=None, tags=<factory>, _call_ctx=None, _import_ctx=<factory>, _object_ctx=<factory>, _executor=None, _line_no=None)[source]

Bases: BoundSymbolInterface

Parameters:
  • sym (Symbol) –

  • args (tuple) –

  • kwargs (dict) –

  • output (Any) –

  • subsymbols (Sequence[BoundSymbol]) –

  • header (str | list[str]) –

  • source_filename (str | None) –

  • source_positions (thunder.core.codeutils.Positions | None) –

  • tags (set[thunder.core.symbol.BoundSymbolTag]) –

  • _call_ctx (None | dict[str, Any]) –

  • _import_ctx (dict) –

  • _object_ctx (dict) –

  • _executor (Union[None, Any]) –

  • _line_no (None | int) –

__init__(sym, args, kwargs, output, subsymbols=(), header='', source_filename=None, source_positions=None, tags=<factory>, _call_ctx=None, _import_ctx=<factory>, _object_ctx=<factory>, _executor=None, _line_no=None)[source]
Parameters:
Return type:

None

Methods

__init__(sym, args, kwargs, output[, ...])

from_bsym(**kwargs)

rtype:

BoundSymbol

from_bsym_swap_proxies(swap_map[, ...])

Create a new BoundSymbol with its inputs, output, and subsymbols updated with swap_map.

gather_ctxs()

rtype:

tuple[dict, dict, dict]

has_input(coll)

rtype:

bool

import_ctx()

name_with_module()

object_ctx()

python(indent[, commented, print_depth])

rtype:

list[str]

Attributes

are_all_args_constant

Returns True if all arguments are constant (i.e.

flat_args

flat_args_and_spec

flat_outs

flat_outs_and_spec

flat_proxy_args

flat_proxy_outs

flat_variableified_proxy_args

flat_variableified_proxy_outs

header

rhs

source_filename

source_positions

subsymbols

sym

args

kwargs

output

tags

from_bsym_swap_proxies(swap_map, skip_inputs=False, skip_output=False, skip_subsymbols=False)[source]

Create a new BoundSymbol with its inputs, output, and subsymbols updated with swap_map.

This replaces :class:Proxy``s, e.g. :class:`TensorProxy`, of inputs and output with another ones already seen recorded in ``swap_map (swap_map maps variableified :class:Proxy to an existing one generated by the same expression), and do the same to subsymbols.

Turning on some of positional arguments following swap_map can be useful, for example, when querying right-hand side expression of a BoundSymbol in thunder.executors.passes.CSE().

Parameters:
  • skip_inputs (bool) –

  • skip_output (bool) –

  • skip_subsymbols (bool) –

  • swap_map (dict[thunder.core.trace.VariableInterface, thunder.core.proxies.Proxy]) –

  • skip_inputs (bool) –

  • skip_output (bool) –

  • skip_subsymbols (bool) –

Return type:

BoundSymbol

Returns:

BoundSymbol

property are_all_args_constant[source]

Returns True if all arguments are constant (i.e. not Variables).