Atlas-Download-Tools icon indicating copy to clipboard operation
Atlas-Download-Tools copied to clipboard

Avoid recomputatation of `transformation` inside of `DisplacementField.warp`

Open jankrepl opened this issue 4 years ago • 0 comments
trafficstars

Whenever one calls warp the transformation needs to be computed from the displacements.

https://github.com/BlueBrain/Atlas-Download-Tools/blob/60f0221916f4f9987a4728807be0b37934784cd0/src/atldld/base.py#L319

This operation requires np.meshgrid or np.indices and can be costly for big shapes. Anyway, the DisplacementField should be immutable and it should be enough to compute the transformation once.

Some ideas

  • LRU cache
  • Explicit caching e.g. (self._tx, self._ty)
  • Optionally pass it in the constructor (assuming it was computed already)

Why relevant?

The primary example is when we download both the section and the expression image. We use the same DisplacementField to warp them, however, transformation is computed twice.

jankrepl avatar Aug 25 '21 11:08 jankrepl