The cuts come as the software giant invests billions of dollars in expanding its artificial intelligence infrastructure.