Elon Musk said the layoffs are due to a need to reduce costs while increasing productivity.