FIX ensure output and input have same dtype