fix array initialization problem when import package #49
+43
−7
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.
This pull request introduces significant changes to the
braintaichi/_primitive/_ad_support.py
file, focusing on enhancing the functionality for defining JVP (Jacobian-vector product) rules for JAX primitives. The most important changes include the addition of new imports, a redefineddefjvp
function, and the implementation of helper functions to support the new functionality.Enhancements to JVP rule definitions:
functools
,partial
,jax
,tree_util
, andad
to support the new functionality.defjvp
function to handle primitives withmultiple_results=True
and added an example reference for usage._standard_jvp
helper function to manage JVP rules for primitives with multiple results, ensuring compatibility with different versions of JAX._add_tangents
helper function to combine tangents usingtree_util.tree_map
andad.add_tangents
.