Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Variable(..., is_hijax=True)can now be used toHijaxVariableinstances, which is type registered in the new Hijax system. HijaxVariable is a Mutable Hijax type meaning its instances will automatically propagate state through JAX transforms in a similar manner tojax.Ref.nnx.using_refsandnnx.use_refswere dropped in favor ofnnx.using_hijaxandnnx.use_hijax.Variable(..., is_mutable=False)can now be used to disallow any form of updates on the Variable instances. Whenis_mutable=Falsethen neitheris_hijax=Trueorhas_ref=Trueare allowed.Added APIs to create an updated copy of a Variable or structure of Variables with a new value for
is_hijax,has_ref, oris_mutable:as_immutable_vars: create copies of Variables withis_mutableset toFalse.is_hijaxorhad_refwill be set toFalseas well if they had been active.as_mutable_vars: create copies of Variables withis_mutableset toTrue.is_hijaxorhad_refwill be set back toTrueif they had been ifas_immutable_varsas previously set them toFalse.as_hijax_vars: create copies of Variables withis_hijaxset toTrue.as_pytree_vars: create copies of Variables withis_hijaxset toFalse.as_ref_vars: create copies of Variables withhas_refset toTrue.as_array_vars: create copies of Variables withhas_refset toFalse.Note: there is currently some coupling between
is_hijax,has_ref, oris_mutablewhich will be removed in the near future as HijaxVariable improves.