Skip to content

Commit

Permalink
Add is_initializing API
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 728413664
  • Loading branch information
IvyZX authored and Flax Authors committed Feb 19, 2025
1 parent c01ff11 commit 8d3c22b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flax/nnx/bridge/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,16 @@ def init_with_output(
**kwargs,
)

def is_initializing(self) -> bool:
return self._object__state._initializing


def compact(f: F) -> F:
@functools.wraps(f)
def compact_wrapper(self, *args, **kwargs):
if not isinstance(self, Module):
raise ValueError(
f"Expected 'self' to be a nnx.compat.Module, got {type(self).__name__}"
f"Expected 'self' to be a nnx.bridge.Module, got {type(self).__name__}"
)

MODULE_CONTEXT.parent_stack.append(CompactContext(self))
Expand Down

0 comments on commit 8d3c22b

Please sign in to comment.