Switch from jax.vmap to hk.vmap: this does not change behavior at the moment, but aligns better with API recommendations.

PiperOrigin-RevId: 423789562
This commit is contained in:
Andrew Lampinen
2022-02-16 16:09:54 +00:00
committed by Diego de Las Casas
parent 766286a7a1
commit cdd3bdb636
@@ -198,7 +198,7 @@ class HierarchicalMemoryAttention(hk.Module):
key=sub_sub_top_k_contents,
value=sub_sub_top_k_contents)
return sub_attention_results
do_attention = jax.vmap(do_attention, in_axes=0)
do_attention = hk.vmap(do_attention, in_axes=0)
attention_results = do_attention(sub_inputs, top_k_contents)
attention_results = jnp.squeeze(attention_results, axis=2)
# Now collapse results across k memories
@@ -207,8 +207,8 @@ class HierarchicalMemoryAttention(hk.Module):
return attention_results
# vmap across batch
batch_within_memory_attention = jax.vmap(_within_memory_attention,
in_axes=0)
batch_within_memory_attention = hk.vmap(_within_memory_attention,
in_axes=0)
outputs = batch_within_memory_attention(
queries,
jax.lax.stop_gradient(augmented_contents),