That’s interesting. Would it be possible to somehow sort the images so that you would start with a large one and using smaller inputs in the following iterations?
This could probably reuse the memory without reallocating new memory.
Maybe you’ll be able to lower the memory footprint using it.