concepts.dsl.executors.value_quantizers.PyObjectStore#
- class PyObjectStore[source]#
Bases:
object
A store for Python objects. This class is used to map Python objects to integers (so that they can be stored in a TensorValue object) and vice versa.
Methods
add
(typename, python_object)The lowest-API to add a Python object to the store.
A context manager that can be used to checkpoint all the stored Python objects.
make_batched_value
(typename, pyobj_list[, ...])Make a TensorValue object from a list of (or nested lists of) Python objects.
make_value
(typename, python_object)Make a TensorValue object from a single Python object.
retrieve
(typename, index)The lowest-API to retrieve a Python object from the store.
retrieve_value
(value)Retrieve one or multiple Python object from the store.
Attributes
The executor that uses this object store.
The underlying domain for the PyObjectStore.
- __init__(executor)[source]#
Initialize the PyObjectStore object.
- Parameters:
executor (TensorValueExecutorBase) – the executor that uses this object store.
- __new__(**kwargs)#
- add(typename, python_object)[source]#
The lowest-API to add a Python object to the store. Most of the time, you should use other higher-level APIs such as
make_value()
andmake_batched_value()
.
- checkpoint()[source]#
A context manager that can be used to checkpoint all the stored Python objects. This is useful when you performs a series of executions and want to restore the objects to save memory.
- make_batched_value(typename, pyobj_list, batch_variables=None)[source]#
Make a TensorValue object from a list of (or nested lists of) Python objects.
- make_value(typename, python_object)[source]#
Make a TensorValue object from a single Python object.
- Parameters:
- Returns:
the TensorValue object.
- Return type:
- retrieve(typename, index)[source]#
The lowest-API to retrieve a Python object from the store. Most of the time, you should use other higher-level APIs such as
retrieve_value()
.
- retrieve_value(value)[source]#
Retrieve one or multiple Python object from the store. When the value is a batched value, this function will return a list of (or nested lists of) Python objects.
- Parameters:
value (TensorValue)
- Return type:
- domain: DSLDomainBase#
The underlying domain for the PyObjectStore.
- executor: TensorValueExecutorBase#
The executor that uses this object store.