Skip to content

Improve pos_embed calculation#20

Open
ZhiyuanChen wants to merge 2 commits intoguolinke:masterfrom
ZhiyuanChen:patch-3
Open

Improve pos_embed calculation#20
ZhiyuanChen wants to merge 2 commits intoguolinke:masterfrom
ZhiyuanChen:patch-3

Conversation

@ZhiyuanChen
Copy link
Contributor

Make rpe_bucket nn.Parameter to avoid copying in forward
Use a single linear to calculate pos_q and pos_k to increase forward speed

Make `rpe_bucket` `nn.Parameter` to avoid copying in forward
Use a single linear to calculate `pos_q` and `pos_k` to increase forward speed
self.pos = nn.Embedding(self.max_seq_len + 1, self.embedding_dim)
self.pos_q_linear = nn.Linear(self.embedding_dim, self.embedding_dim)
self.pos_k_linear = nn.Linear(self.embedding_dim, self.embedding_dim)
self.pos_proj = nn.Linear(self.embedding_dim, self.embedding_dim * 2)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will break backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants