mark_shareable#
- penzai.deprecated.v1.nn.parameters.mark_shareable(submodel: Any)[source]#
Marks all uninitialized parameters in
submodel
as shareable.This function is used to annotate the parameters in part of a model as being shareable: all
UninitializedParameter
instances will be replaced by equivalentShareableUninitializedParameter
instances. The submodel can then be used multiple times, as long as all uses are wrapped in a single call toattach_shared_parameters
.Parameter sharing is opt-in only to avoid accidentally sharing parameters due to name collisions. By convention, any caller that calls
make_shareable
is also responsible for constructing theattach_shared_parameters
wrapper that will actually own the shared parameters.- Parameters:
submodel – Part of a model whose parameters should be shared.
- Returns:
A copy of
submodel
where allUninitializedParameter
instances have been replaced byShareableUninitializedParameter
instances.