@jeffdonahue why don't you just compute `mask` here and then at end if needed you copy it to `top_mask`, that way you wouldn't need to initialize it (which takes probably the same time as coping at the end), and would simplify the logic.