Commit 6b26218
committed
Add weighted einsum implementation (#671)
* more precise stream type
* add tests for weighted rules
* add reduction rule for weighted streams and tests
* add test to demo expectation
* add numpyro monoid module
* add quadrature
* add tests
* wip
* refactor tests
* wip
* test composition of lifting and weighting
* drop numpyro changes
* drop unused ops
* lint
* make weighted a Monoid method
* fix typing of jax arrays
* change weighted typing to take callable
* fix test
* fix test
* resolve type aliases before dispatching
* wip
* wip
* remove typeof_full
* wip
* wip
* wip
* format
* refactor test harness
* fix behavior of delta terms
* add baseline einsum
* rework einsum to work on shapes instead of concrete tensors
* add einsum benchmark
* wip
* wip
* finish sum/product contraction
* allow bind_dims to bind nonexistent named dimensions
* wip
* add custom partial eval for reductions
* working benchmarks
* fix infinite loop
* eliminate identity indexing when possible
* wip
* handle getitem where dimensions are created
* treat any index with bare ops and slice(None) as canonical
* simplify range op and add reduction rules
* wip
* remove old benchmark code
* another try at removing identity gathers
* refactor
* fix test
* lint
* clean up comment
* fix some test failures
* drop sketchy bind_dims rule
* drop more type-incompatible plus rules
* format
* fix reduction issue
* drop dimension creating behavior from bind_dims
* lint
* simplify comment
* drop partition
* fix docstring
* handle negative dimension indexing
* fix creation of empty tensors
* fully restore previous behavior for missing named dims
* reduce any arraylike or named tensor
* require at least one jax array to reduce
* fix typing test
* drop typing test
* drop einsum parser in favor of opt_einsum
* more agressive factorization that hoists shared streams
* reduce nesting
* comment
* replace with simpler push-based rule
* format
* drop unused disjoint set
* remove unused
* push multiple streams instead of one at a time
* drop contraction ordering handler
* fold BindDimsBindDims into default behavior
* handle Sum.reduce instead of Monoid.reduce
* wip
* wip
* hacks
* extract contraction heuristic
* lint
* fix test
* use a named dimension einsum for contractions
* lint
* drop custom arange op
* wip
* simplify by targetting delta rules
* wip
* fixes
* fixes
* lint
* drop unused
* pick up constants but not rest of module
* lint1 parent 3b1ac2a commit 6b26218
10 files changed
Lines changed: 982 additions & 396 deletions
File tree
- effectful
- handlers/jax
- numpy
- scipy
- ops
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | | - | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
69 | | - | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
72 | 80 | | |
73 | 81 | | |
74 | 82 | | |
| |||
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
92 | | - | |
93 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| |||
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
145 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
146 | 159 | | |
147 | 160 | | |
148 | 161 | | |
| |||
182 | 195 | | |
183 | 196 | | |
184 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
185 | 285 | | |
186 | 286 | | |
187 | 287 | | |
| |||
215 | 315 | | |
216 | 316 | | |
217 | 317 | | |
| 318 | + | |
| 319 | + | |
218 | 320 | | |
219 | 321 | | |
220 | 322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| 470 | + | |
470 | 471 | | |
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
474 | 475 | | |
475 | 476 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
489 | 528 | | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
| 529 | + | |
495 | 530 | | |
496 | 531 | | |
497 | 532 | | |
| |||
0 commit comments