brainstate module#
Core State Classes#
State classes are the fundamental building blocks for managing dynamic data in BrainState. They provide a unified interface for tracking, tracing, and transforming stateful computations.
Basic State Types#
Basic state types provide semantic distinctions for different data lifecycles in your program.
A generic class representing a dynamic data pointer in the BrainState framework. |
|
A class representing short-term state in a program. |
|
The long-term state, which is used to store the long-term data in the program. |
|
The parameter state, which is used to store the trainable parameters in the model. |
|
The batch state, which is used to store the batch data in the program. |
|
Short-term state for storing delay data. |
Special State Types#
Special-purpose state types for advanced use cases and PyTree integration.
The faked state, which is used to store the faked data in the program. |
|
The state as a pytree. |
State Management#
Tools for managing collections of states and tracking state access patterns during program execution.
State Collections#
Organize and manipulate multiple states as cohesive units.
State stack, for collecting all |
State Tracing#
Track state read/write operations for automatic differentiation and program transformation.
A stack for tracing and managing states during program execution. |
State Utilities#
Helper functions and context managers for working with states effectively.
Context Managers#
Control state behavior within specific code blocks.
The contex manager to check weather the tree structure of the state value keeps consistently. |
|
The context manager to check whether the state is valid to trace. |
|
A context manager that catches and tracks new states created within its scope. |
Helper Functions#
Utility functions for common state operations.
Extracts the value from a State object if given, otherwise returns the input value. |
Error Handling#
Custom exceptions for state-related errors and debugging.
Exception Classes#
A custom exception class for BrainState-related errors. |
|
Exception raised for errors related to batch axis operations. |