3 ms·
> you're very likely to find a "large" sample early that rarely gets updated. From then on, this branch will virtually always be false Good point, provided th
by shoo 5y ago
> you're very likely to find a "large" sample early that rarely gets updated. From then on, this branch will virtually always be false
Good point, provided there's a decent number of elements being reduced.
In the application I've been focusing on, many of the batched log-exp-sum reductions are over tiny arrays containing 1 to 4 log-prob elements. There's already branching to guard against the case where all elements are log-prob -inf (aka probability zero). I found it helpful to also branch to special case the 1 element case, in which case the reduction is the identity operation, saving both an exp and a log. It's probably the case that inside the exp and log there's branching as well, so doesn't make sense to get too myopically focused on that single aspect of performance.