Add inplace flatten task for sum, min and max