Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions keras_hub/src/models/parseq/parseq_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,19 @@ def call(
null_context = self.hidden_dim**0.5 * self.token_embedding(
token_ids[:, :1]
)
if tokens_length > 1:
content = self.pos_query_embeddings[:, : tokens_length - 1, :]
content = content + self.hidden_dim**0.5 * self.token_embedding(
# Use ops.cond for TFLite/graph mode compatibility
def _content_with_positions():
c = self.pos_query_embeddings[:, : tokens_length - 1, :]
c = c + self.hidden_dim**0.5 * self.token_embedding(
token_ids[:, 1:]
)
content = ops.concatenate([null_context, content], axis=1)
else:
content = null_context
return ops.concatenate([null_context, c], axis=1)

content = ops.cond(
tokens_length > 1,
_content_with_positions,
lambda: null_context,
)

content = self.dropout(content)

Expand Down
Loading