-
output:
So is it safe to use |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
In addition, I don't understand why an inplace function like |
Beta Was this translation helpful? Give feedback.
-
Whether or not it's safe to use In the snippet you shared, it is safe: explicit dict arguments to However, if you remove |
Beta Was this translation helpful? Give feedback.
Whether or not it's safe to use
dict.pop
withinjax.jit
depends on the context.In the snippet you shared, it is safe: explicit dict arguments to
jit
-compiled functions will be passed throughjax.tree_util
flattening, and so the dict you are operating on within the function is a copy of the dict passed to the function, and mutating it will not affect the dict in the outer scope.However, if you remove
jax.jit
or execute your function in ajax.disable_jit
context, mutating the dict will mutate the dict in the outer scope. So that's something to be aware of if you're using this kind of pattern.