Skip to navigation

aitune.global_context

View as Markdown

Global context for torch.

Module Contents

Classes

NameDescription
GlobalContextGlobal context holding key value pairs.

Data

BACKEND_CONTEXT_KEY

BATCH_SIZE_KEY

LIBRARY_LOGGING_KEY

MODULE_CONTEXT_KEY

global_context

API

class aitune.global_context.GlobalContext()

Global context holding key value pairs.

Creates only one instance (singleton) and can be used as a context manager to push and pop context.

_current_data

Return the current context.

_data_stack
= [{}]
_lock
= threading.Lock()
aitune.global_context.GlobalContext.__enter__()

Enter a new context.

aitune.global_context.GlobalContext.__exit__(
exc_type,
exc_val,
exc_tb
)

Exit the current context.

aitune.global_context.GlobalContext.__getitem__(
key
)

Get a value from the current context.

aitune.global_context.GlobalContext.__setitem__(
key,
value
)

Set a key-value pair in the current context.

aitune.global_context.GlobalContext.clear()

Clear the current context.

aitune.global_context.GlobalContext.get(
key,
default = None
)

Get a value from the current context.

aitune.global_context.GlobalContext.set(
key,
value
)

Set a key-value pair in the current context.

aitune.global_context.BACKEND_CONTEXT_KEY = 'current_backend'
aitune.global_context.BATCH_SIZE_KEY = 'batch_size'
aitune.global_context.LIBRARY_LOGGING_KEY = 'library_logging'
aitune.global_context.MODULE_CONTEXT_KEY = 'current_module'
aitune.global_context.global_context = GlobalContext()