AbstractVariable#

class penzai.core.variables.AbstractVariable[source]#

Bases: ABC

Base class for all variables.

Variables are allowed to be mutable, and should not be registered as PyTree nodes.

Methods

freeze()

Returns a frozen copy of this variable.

get_slot()

Returns the slot that this variable is replaced with when unbound.

update(new_frozen_value)

Updates the value of this variable to match a frozen variable.

Inherited Methods

(expand to view inherited methods)

__init__()

abstract freeze() AbstractVariableValue[source]#

Returns a frozen copy of this variable.

abstract get_slot() AbstractVariableSlot[source]#

Returns the slot that this variable is replaced with when unbound.

The variable slot will uniquely identify this variable within a pytree.

abstract update(new_frozen_value: AbstractVariableValue)[source]#

Updates the value of this variable to match a frozen variable.