Tesla announced Tuesday it would cut 9 percent of its workforce in an effort to reduce costs.

The layoffs, first reported by Bloomberg and later confirmed by Tesla's CEO Elon Musk in a tweet, will largely affect salaried employees and not the company's manufacturing line. Musk said the cuts were "difficult, but necessary" and won't hurt Tesla's ability to meet production targets for its Model 3 vehicle.

"They're focusing on the jobs that are going to be driving revenue and profit for the company and cutting everything else," said Galileo Russell, founder of HyperChange TV. "Obviously the Model 3 ramp is the most important thing right now and keeping that production line fully staffed is a must."

Tesla has experienced repeated production delays of its mass-market Model 3 for almost a year. Musk had said he expected to roll out 5,000 cars a week by the end of 2017, but with the assembly line mired in what he called "manufacturing hell," the target has been pushed back several times.

At the company's shareholder meeting last week, Musk said Tesla was now on track to make 6,000 Model 3 cars a week by the end of the month. That news sent shares soaring nearly 10 percent, their biggest gain since November 2015.

The stock was up as much as 7 percent Tuesday morning after the research firm Keybanc Capital raised its forecast for Model 3 deliveries by as much as 50 percent, to 35,000 cars, in the second quarter.

News of the layoffs ate into the stock's gains.

A Tesla spokesman said the job cuts would reduce Tesla's headcount to about 37,000 employees.

For full interview, click here.