Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/google-deepmind/penzai
/ functions
Functions
1,092 in github.com/google-deepmind/penzai
⨍
Functions
1,092
◇
Types & classes
360
↳
Endpoints
3
↓ 199 callers
Method
tag
(self, *names)
penzai/core/named_axes.py:1539
↓ 177 callers
Method
wrap
Wraps a positional array as a ``NamedArray``. Args: array: Array to wrap. *names: Optional names for the axes of the array. If provid
penzai/core/named_axes.py:1420
↓ 137 callers
Method
select
Wraps this struct in a selection, enabling functional-style mutations. This is a convenience wrapper around selectors.select to enable easier
penzai/core/struct.py:551
↓ 102 callers
Method
apply
( self, fn: Callable[[SelectedSubtree], Any], *, keep_selected: Literal[False] = False
penzai/core/selectors.py:264
↓ 102 callers
Method
at_instances_of
Selects subtrees that are an instance of the given type. Convenience wrapper for:: .at_subtrees_where(lambda subtree: isinstance(subtree,
penzai/core/selectors.py:897
↓ 88 callers
Method
untag
(self, *axis_order: AxisName)
penzai/core/named_axes.py:1536
↓ 66 callers
Method
from_config
( cls, init_base_rng: jax.Array | None, feature_sizes: list[int], name: str = "mlp",
penzai/models/simple_mlp.py:30
↓ 46 callers
Method
canonicalize
Ensures that the named axes are stored in a canonical order. Returns: Equivalent `NamedArray` whose data array contains the positional axes
penzai/core/named_axes.py:1012
↓ 43 callers
Function
_wrap_array_method
Wraps an array method on a named array.
penzai/core/named_axes.py:368
↓ 42 callers
Function
_make_redirector
Builds a redirector module for the given target module.
penzai/experimental/v2/__init__.py:35
↓ 38 callers
Function
make_example_object
()
tests/core/selectors_test.py:38
↓ 37 callers
Function
_nmap_with_doc
Builds a nmap-wrapped function with a docstring.
penzai/core/named_axes.py:172
↓ 37 callers
Method
dtype
(self)
penzai/core/named_axes.py:1445
↓ 35 callers
Method
where
( self: "Selection[SelectedSubtree]", filter_fn: Callable[[SelectedSubtree], bool], *,
penzai/core/selectors.py:682
↓ 26 callers
Method
add
(self, values, /, **kwargs)
penzai/core/named_axes.py:661
↓ 25 callers
Method
handling
Builds a ``WithRandomKeyFromArg`` that handles effects in this layer. Args: body: The layer to wrap. Usually will contain random effects in
penzai/deprecated/v1/data_effects/random.py:135
↓ 24 callers
Method
get
Returns the result of a singleton selection. Returns: The selected subtree from this selection. Raises: ValueError: If this sele
penzai/core/selectors.py:238
↓ 23 callers
Method
tag_prefix
Attaches names to the first positional axes in an array or view. This is a version of `tag` that allows you to name only a subset of the arra
penzai/core/named_axes.py:828
↓ 23 callers
Method
update
Updates the value of this variable to match a frozen variable.
penzai/core/variables.py:525
↓ 19 callers
Method
at
Selects a specific child of each selected node. ``Selection.at(...)`` allows you to modify a tree with an almost-imperative style while maint
penzai/core/selectors.py:501
↓ 19 callers
Method
unwrap
(self, *names)
penzai/core/named_axes.py:1494
↓ 16 callers
Method
get_sequence
Gets the selected subtree(s) in order. Convenience wrapper for ``.selected_by_path.values()``. Returns: A tuple containing the selecte
penzai/core/selectors.py:409
↓ 15 callers
Method
check_valid
(self)
penzai/core/named_axes.py:1448
↓ 15 callers
Method
deselect
Rebuilds the tree, forgetting which nodes were selected. Returns: A copy of `remainder` with the holes filled by the values in `selec
penzai/core/selectors.py:212
↓ 15 callers
Method
with_positional_prefix
(self)
penzai/core/named_axes.py:1516
↓ 14 callers
Method
get_array_data_with_truncation
( self, array: named_axes.NamedArrayBase, mask: named_axes.NamedArrayBase | jax.Array | np.n
penzai/core/_treescope_handlers/named_axes_handlers.py:181
↓ 13 callers
Function
_swapped_binop
Swaps the order of operations for a binary operation.
penzai/core/named_axes.py:345
↓ 13 callers
Method
freeze
(self)
penzai/core/variables.py:598
↓ 13 callers
Method
set
Replaces the selected subtree(s) with a fixed replacement. Args: replacement: The pytree to replace with. Returns: A modified ve
penzai/core/selectors.py:343
↓ 13 callers
Method
untag_prefix
Adds the requested axes to the front of the array's positional axes. This is a version of `untag` that can be called on NamedArrays or NamedA
penzai/core/named_axes.py:809
↓ 12 callers
Function
_show_dim
Summarizes a dimension variable into a human-readable summary.
penzai/core/shapecheck.py:647
↓ 12 callers
Method
at_subtrees_where
( self, filter_fn: Callable[[SelectedSubtree], bool], *, with_keypath: Literal[False]
penzai/core/selectors.py:730
↓ 12 callers
Method
set
Sets the current state of the local variable.
penzai/deprecated/v1/data_effects/local_state.py:76
↓ 11 callers
Function
_build_selection_from_boundary
Internal function to build a selection from a boundary. This function, like the `_InProgressSelectionBoundary` class, is an implementation detail
penzai/core/selectors.py:1456
↓ 11 callers
Method
count
Returns the number of elements in the selection.
penzai/core/selectors.py:200
↓ 11 callers
Method
from_config
Builds a GemmaAttention block from a configuration. Args: config: The configuration of the Gemma model. Returns: A GemmaAttentio
penzai/deprecated/v1/example_models/gemma/model_core.py:193
↓ 11 callers
Method
order_like
Ensures that this array's PyTree structure matches another array's. This can be used to ensure that one named array has the same PyTree struc
penzai/core/named_axes.py:885
↓ 10 callers
Method
_nmap_update_op
Updates values in the array.
penzai/core/named_axes.py:576
↓ 10 callers
Method
as_namedarrayview
(self)
penzai/core/named_axes.py:1520
↓ 10 callers
Method
at_children
Selects all direct children of each selected subtree. This can be used to implement recursive tree traversals in a generic way, using somethi
penzai/core/selectors.py:648
↓ 10 callers
Method
bind_variables
Convenience function to bind variables to a layer. `layer.bind_variables(variables)` is a simple alias for `pz.bind_variables(layer, variable
penzai/nn/layer.py:78
↓ 9 callers
Method
get
Gets the current state of the local variable.
penzai/deprecated/v1/data_effects/local_state.py:73
↓ 9 callers
Method
next_key
Returns the next key in the sequence, and advances the stream.
penzai/core/random_stream.py:51
↓ 8 callers
Method
_ordering_tuple
Builds a tuple that can be used to compare this object to other types.
penzai/core/auto_order_types.py:72
↓ 8 callers
Method
apply_and_inline
( self, fn: Callable[[SelectedSubtree], Iterable[Any]], *, with_keypath: Literal[False
penzai/core/selectors.py:1105
↓ 8 callers
Method
ask
Retrieves the value for the side input.
penzai/deprecated/v1/data_effects/side_input.py:46
↓ 7 callers
Function
_summarize_pattern
Summarizes a pattern into a human-readable summary.
penzai/core/shapecheck.py:665
↓ 7 callers
Function
_wrap_dimvar
(msg: str)
penzai/core/_treescope_handlers/shapecheck_handlers.py:29
↓ 7 callers
Function
_wrap_selection_errors
Context manager to add informative details to selection errors.
penzai/core/selectors.py:1415
↓ 7 callers
Method
capture
Captures positional and keyword arguments from this call.
penzai/toolshed/unflaxify.py:49
↓ 7 callers
Method
freeze
(self)
penzai/core/variables.py:750
↓ 7 callers
Method
from_base_key
Returns a new random stream with the given base key.
penzai/core/random_stream.py:41
↓ 7 callers
Method
tell
Writes a value to the side output.
penzai/deprecated/v1/data_effects/side_output.py:43
↓ 6 callers
Method
build
(cls)
penzai/deprecated/v1/toolshed/interleave_intermediates.py:47
↓ 6 callers
Method
unfreeze_as_copy
(self)
penzai/core/variables.py:621
↓ 5 callers
Function
_try_match_one
Internal helper to match a pattern with a value. Args: keypath: Keypath for the current value. pattern: Pattern to match. value: Value
penzai/core/shapecheck.py:511
↓ 5 callers
Function
_wrap_scalar_conversion
Wraps a scalar conversion operator on a named array.
penzai/core/named_axes.py:354
↓ 5 callers
Method
at_equal_to
Selects subtrees that are equal to a particular object. Mostly a convenience wrapper for :: .at_subtrees_where(lambda subtree: template ==
penzai/core/selectors.py:923
↓ 5 callers
Method
get_axis_info_for_array_data
( self, array: named_axes.NamedArrayBase )
penzai/core/_treescope_handlers/named_axes_handlers.py:164
↓ 5 callers
Method
initialize
Randomly initializes the parameter. Args: prng_key: Key to use for initialization. Returns: A new instance of ``Parameter``.
penzai/deprecated/v1/nn/parameters.py:292
↓ 5 callers
Method
initialize_with_value
Directly initializes the parameter with particular value. This can be used to bypass the initializer function and set the value directly, whi
penzai/deprecated/v1/nn/parameters.py:328
↓ 5 callers
Method
is_empty
Returns True if the selection is empty.
penzai/core/selectors.py:208
↓ 5 callers
Function
name_to_name_sharding
Shards a tree of `pz.nx.NamedArray` objects based on their axis names. Args: tree: A PyTree of `pz.nx.NamedArray` instances, with the same stru
penzai/toolshed/sharding_util.py:30
↓ 5 callers
Function
nmap
Automatically vectorizes ``fun`` over named axes of NamedArray inputs. ``nmap`` is a "named-axis vectorizing map". It wraps an ordinary positiona
penzai/core/named_axes.py:120
↓ 5 callers
Method
order_as
Ensures that the named axes are stored in this order, keeping them named. This function can be used if it is important for the axis names to appe
penzai/core/named_axes.py:851
↓ 5 callers
Method
set_by_path
Replaces the selected subtree(s) based on their path(s). If you need both the value and the key, see ``.apply(fn, with_keypath=True)``.
penzai/core/selectors.py:363
↓ 5 callers
Method
stateless_call
Calls a layer with temporary variables, without modifying its state. This is a convenience method for: * freezing any variables currently
penzai/nn/layer.py:102
↓ 4 callers
Function
_active_renderer_extended_with_penzai_repr
Extends the default renderer to support __penzai_repr__.
penzai/treescope/_compatibility_setup.py:31
↓ 4 callers
Function
_type_filtered_predicate
( predicate: Callable[[AbstractVariable], bool] | None, var_type: type[Any], )
penzai/core/variables.py:812
↓ 4 callers
Method
assert_count_is
Checks that an expected number of nodes is selected. Args: count: The expected number of nodes. Returns: The original selection
penzai/core/selectors.py:1321
↓ 4 callers
Method
at_pytree_leaves
Selects all PyTree leaves of each selected subtree. This selects all of the leaves of the PyTree according to `jax.tree_util`, giving the mos
penzai/core/selectors.py:631
↓ 4 callers
Method
body
(carry_data, slice_data)
penzai/nn/layer_stack.py:205
↓ 4 callers
Method
build
(cls)
penzai/deprecated/v1/toolshed/annotate_shapes.py:43
↓ 4 callers
Method
check_valid
(self)
penzai/core/named_axes.py:1589
↓ 4 callers
Function
fix_qkvo
(which, arr)
penzai/models/transformer/variants/llamalike_common.py:626
↓ 4 callers
Method
from_sublayer_builder
Builds a layer stack of layers with non-shared parameters. This function assumes that all variables returned by this builder are defined insi
penzai/nn/layer_stack.py:267
↓ 4 callers
Method
from_uncached
Builds a caching attention from an uncached attention. Args: original: The original attention layer that this block should replace. s
penzai/nn/attention.py:354
↓ 4 callers
Method
get_by_path
Retrieves the selected subtree(s) based on their path(s). Returns: A dictionary of selected nodes, indexed by their path
penzai/core/selectors.py:355
↓ 4 callers
Function
get_effect_color
Gets the default color for a given effect (for treescope rendering).
penzai/deprecated/v1/data_effects/effect_base.py:98
↓ 4 callers
Method
get_slot
(self)
penzai/core/variables.py:603
↓ 4 callers
Method
input_structure
Returns the input structure of this layer. The input structure of a layer is a PyTree describing the structure the layer expects to be called
penzai/deprecated/v1/core/layer.py:135
↓ 4 callers
Method
invert
Inverts a selection, selecting subtrees with no selected children. ``selection.invert()`` selects the largest set of subtrees such that those
penzai/core/selectors.py:1052
↓ 4 callers
Method
tree_flatten
Flattens this tree node. See `jax.tree_util.register_pytree_with_keys_class`. This method should not be overridden by subclasses, since
penzai/core/struct.py:617
↓ 4 callers
Function
unbind_variables
( tree: Any, predicate: Callable[[AbstractVariable], bool] | None = None, freeze: Literal[False] =
penzai/core/variables.py:174
↓ 3 callers
Method
IdToPiece
Decodes a token ID to a string.
penzai/toolshed/token_visualization.py:41
↓ 3 callers
Function
add_intercept_values_inside
Inserts inserted_cls layers around sublayers of a layer.
penzai/toolshed/save_intermediates.py:96
↓ 3 callers
Function
add_intercept_values_inside
Inserts _InterceptValues layers around sublayers of a layer.
penzai/deprecated/v1/toolshed/interleave_intermediates.py:93
↓ 3 callers
Method
broadcast_to
Broadcasts a named array to a possibly-larger shape. Args: positional_shape: Desired positional shape for the array. Will be broadc
penzai/core/named_axes.py:957
↓ 3 callers
Method
build
(cls)
tests/deprecated/v1/data_effects/local_state_test.py:34
↓ 3 callers
Method
check_valid
Checks that the names in the array are correct.
penzai/core/named_axes.py:697
↓ 3 callers
Method
effect_protocol
Returns the protocol that this effect request handles.
penzai/deprecated/v1/data_effects/effect_base.py:152
↓ 3 callers
Method
into_pytree
Converts an ``ArraySpec`` into a (possibly wrapped) PyTree leaf. By default, an ``ArraySpec`` has no PyTree children. This method can be used
penzai/core/shapecheck.py:324
↓ 3 callers
Method
output_structure
Returns the output structure of this layer. The output structure of a layer is a PyTree describing the structure of the layer's return value,
penzai/deprecated/v1/core/layer.py:178
↓ 3 callers
Function
select
Wraps a tree in a singleton selection for processing. Args: tree: A tree to select. Returns: A selection of the entire tree. Useful beca
penzai/core/selectors.py:1499
↓ 3 callers
Method
set_sequence
Replaces the selected subtree(s) in order. Args: replacements: An iterable of PyTrees to insert at the selected locations, in order
penzai/core/selectors.py:419
↓ 3 callers
Method
tag
Attaches names to the positional axes of an array or view. Args: *names: Axis names to assign to each positional axis in the array or view.
penzai/core/named_axes.py:790
↓ 2 callers
Function
_find_and_hoist
(subtree)
penzai/deprecated/v1/data_effects/side_input.py:377
↓ 2 callers
Function
_fixup_tokens_and_name_order
Helper function to preprocess token arrays and axis names.
penzai/toolshed/token_visualization.py:48
↓ 2 callers
Function
_head_info
Computes query, key, and value head axes and einsum names.
penzai/models/transformer/variants/llamalike_common.py:194
↓ 2 callers
Function
_make_label
(inspect_device_data)
penzai/core/_treescope_handlers/named_axes_handlers.py:111
next →
1–100 of 1,092, ranked by callers