Commit 702fd16
Sigrid Jin (Sionic AI)
perf: optimize vision token detection using torch.isin
Implement efficiency improvements suggested by DarkLight1337:
- Consolidate get_pooling_params method for "embed" and "encode" tasks
- Pre-compute vision token IDs tensor in constructor
- Replace range checks with torch.isin for more efficient vision token detection
at lines 209-210 and 261-262
This reduces redundant code and improves performance when checking for
vision tokens by using optimized tensor operations.
Signed-off-by: Sigrid Jin (Sionic AI) <[email protected]>1 parent 1b4f405 commit 702fd16
1 file changed
+9
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | | - | |
210 | | - | |
| 210 | + | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
258 | 259 | | |
259 | 260 | | |
260 | 261 | | |
261 | | - | |
262 | | - | |
| 262 | + | |
| 263 | + | |
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
| |||
0 commit comments