pytensor icon indicating copy to clipboard operation
pytensor copied to clipboard

Merge consecutive reduces

Open ricardoV94 opened this issue 1 year ago • 1 comments

Description

This PR does some cleanup and extends reduction rewrites. Check each commit for the individual changes. Summary:

  1. Remove list of ALL_REDUCE. AFAICT the tracks machinery already handles subclasses automatically. It did not always do it, which is probably why the list existed
  2. ~~Stop defining Min as negative of Max, to later undo it and actually use Min. I think this is just some historical accident?~~ Reverted, too many things depend on this for me to tackle now: #904
  3. Generalize a chain of reductions of the same type to any CAReduce. It was previously limited only to Sum and Prod, but I can't see a good reason for it. This showed up in vectorized logps where All reductions (related to the parameter checks) were not being combined.
  4. Generalize local_reduce_join to any axis and regardless of whether the inputs along that axis are broadcastable because of expand_dims or any other reason. It shouldn't matter, as long as we can squeeze it out.

Checklist

Type of change

  • [x] New feature / enhancement
  • [ ] Bug fix
  • [ ] Documentation
  • [ ] Maintenance
  • [ ] Other (please specify):

ricardoV94 avatar Jul 05 '24 19:07 ricardoV94