---
title: thunder.core.symbol.BoundSymbol
canonical: >-
  https://lightning.ai/docs/thunder/stable/api-reference/generated/thunder.core.symbol.BoundSymbol
---
# thunder.core.symbol.BoundSymbol {#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)` {#thunder.core.symbol.BoundSymbol}

[\[source\]](https://github.com/Lightning-AI/lightning-thunder/blob/0.2.6/thunder/core/symbol.py#L370-L728)

Bases: [`BoundSymbolInterface`](/docs/thunder/0.2.6/api-reference/generated/thunder.core.baseutils.BoundSymbolInterface.md#thunder.core.baseutils.BoundSymbolInterface "thunder.core.baseutils.BoundSymbolInterface")

Parameters:

*   **sym** ([_Symbol_](/docs/thunder/0.2.6/api-reference/generated/thunder.core.symbol.Symbol.md#thunder.core.symbol.Symbol "thunder.core.symbol.Symbol")) –
    
*   **args** ([_tuple_](https://docs.python.org/3/builtins/stdtypes.html#tuple "(in Python v3.15)")) –
    
*   **kwargs** ([_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")) –
    
*   **output** ([_Any_](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) –
    
*   **subsymbols** ([_Sequence_](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")_\[_[_BoundSymbol_](#thunder.core.symbol.BoundSymbol "thunder.core.symbol.BoundSymbol")_\]_) –
    
*   **header** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ [_list_](https://docs.python.org/3/builtins/stdtypes.html#list "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]_) –
    
*   **source\_filename** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_) –
    
*   **source\_positions** (_thunder.core.codeutils.Positions_ _|_ _None_) –
    
*   **tags** ([_set_](https://docs.python.org/3/builtins/stdtypes.html#set "(in Python v3.15)")_\[__thunder.core.symbol.BoundSymbolTag__\]_) –
    
*   **\_call\_ctx** (_None_ _|_ [_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_Any_](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")_\]_) –
    
*   **\_import\_ctx** ([_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")) –
    
*   **\_object\_ctx** ([_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")) –
    
*   **\_executor** ([_Union_](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.15)")_\[__None__,_ [_Any_](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")_\]_) –
    
*   **\_line\_no** (_None_ _|_ [_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) –
    

#### `__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)` {#thunder.core.symbol.BoundSymbol.__init__}

[\[source\]](https://github.com/Lightning-AI/lightning-thunder/blob/0.2.6/thunder/core/symbol.py)

Parameters:

*   **sym** ([_Symbol_](/docs/thunder/0.2.6/api-reference/generated/thunder.core.symbol.Symbol.md#thunder.core.symbol.Symbol "thunder.core.symbol.Symbol")) –
    
*   **args** ([_tuple_](https://docs.python.org/3/builtins/stdtypes.html#tuple "(in Python v3.15)")) –
    
*   **kwargs** ([_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")) –
    
*   **output** ([_Any_](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) –
    
*   **subsymbols** ([_Sequence_](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")_\[_[_BoundSymbol_](#thunder.core.symbol.BoundSymbol "thunder.core.symbol.BoundSymbol")_\]_) –
    
*   **header** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ [_list_](https://docs.python.org/3/builtins/stdtypes.html#list "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]_) –
    
*   **source\_filename** ([_Optional_](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]_) –
    
*   **source\_positions** ([_Optional_](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")_\[__Positions__\]_) –
    
*   **tags** ([_set_](https://docs.python.org/3/builtins/stdtypes.html#set "(in Python v3.15)")_\[__thunder.core.symbol.BoundSymbolTag__\]_) –
    
*   **\_call\_ctx** ([_Union_](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.15)")_\[__None__,_ [_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_Any_](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")_\]__\]_) –
    
*   **\_import\_ctx** ([_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")) –
    
*   **\_object\_ctx** ([_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")) –
    
*   **\_executor** ([_Optional_](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")_\[_[_Any_](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")_\]_) –
    
*   **\_line\_no** ([_Union_](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.15)")_\[__None__,_ [_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")_\]_) –
    

Return type:

None

Methods

- [`__init__(sym, args, kwargs, output[, ...])`](#thunder.core.symbol.BoundSymbol.__init__)
- `from_bsym(**kwargs)` — rtype:BoundSymbol
- [`from_bsym_swap_proxies(swap_map[, ...])`](#thunder.core.symbol.BoundSymbol.from_bsym_swap_proxies) — 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`](#thunder.core.symbol.BoundSymbol.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)` {#thunder.core.symbol.BoundSymbol.from_bsym_swap_proxies}

[\[source\]](https://github.com/Lightning-AI/lightning-thunder/blob/0.2.6/thunder/core/symbol.py#L444-L509)

Create a new [`BoundSymbol`](#thunder.core.symbol.BoundSymbol "thunder.core.symbol.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`](#thunder.core.symbol.BoundSymbol "thunder.core.symbol.BoundSymbol") in `thunder.executors.passes.CSE()`.

Parameters:

*   **skip\_inputs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) –
    
*   **skip\_output** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) –
    
*   **skip\_subsymbols** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) –
    
*   **swap\_map** ([_dict_](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")_\[__thunder.core.trace.VariableInterface__,_ _thunder.core.proxies.Proxy__\]_) –
    
*   **skip\_inputs** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) –
    
*   **skip\_output** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) –
    
*   **skip\_subsymbols** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) –
    

Return type:

[`BoundSymbol`](#thunder.core.symbol.BoundSymbol "thunder.core.symbol.BoundSymbol")

Returns:

[`BoundSymbol`](#thunder.core.symbol.BoundSymbol "thunder.core.symbol.BoundSymbol")

#### `property are_all_args_constant` {#thunder.core.symbol.BoundSymbol.are_all_args_constant}

[\[source\]](https://github.com/Lightning-AI/lightning-thunder/blob/0.2.6/thunder/core/symbol.py)

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

---

**Navigation**

- Parent: [Generated](/docs/thunder/0.2.6/api-reference/generated.md)
