Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 711491914
  • Loading branch information
tensorflower-gardener committed Jan 2, 2025
1 parent 1bdb87d commit cc7dcff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions official/nlp/modeling/layers/block_sparse_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ def __init__(
"sigmoid_attn_bias must be specified for sigmoid attn."
)

def get_config(self):
config = super().get_config()
config.update({
"src_block_size": self._src_block_size,
"tgt_block_size": self._tgt_block_size,
"use_sigmoid_attn": self._use_sigmoid_attn,
"sigmoid_attn_bias": self._sigmoid_attn_bias,
"num_kv_heads": self._num_kv_heads,
})
return config

def _build_from_signature(self, query, value, key=None):
# pytype: disable=attribute-error
super()._build_from_signature(query, value, key)
Expand Down
5 changes: 5 additions & 0 deletions official/nlp/modeling/layers/multi_query_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def __init__(self, num_kv_heads=None, **kwargs):
self._num_heads % self._num_kv_heads == 0
), "num_kv_heads needs to divide num_heads exactly."

def get_config(self):
config = super().get_config()
config.update({"num_kv_heads": self._num_kv_heads})
return config

def _build_from_signature(
self,
query: Union[tf.Tensor, tf.TensorShape],
Expand Down

0 comments on commit cc7dcff

Please sign in to comment.