Add Shape try into (#189)

* Add the TryInto trait for shapes.

* Use the vectorized operations in block mode too.
This commit is contained in:
Laurent Mazare
2023-07-18 10:52:16 +01:00
committed by GitHub
parent d6313d2447
commit b706f32839
3 changed files with 54 additions and 41 deletions

View File

@ -315,7 +315,6 @@ impl BertSelfAttention {
new_x_shape.pop();
new_x_shape.push(self.num_attention_heads);
new_x_shape.push(self.attention_head_size);
// Be cautious about the transposition if adding a batch dim!
let xs = xs.reshape(new_x_shape.as_slice())?.transpose(1, 2)?;
xs.contiguous()
}