Tesla reported an uptick in quarterly revenue and profit, but the costs of pivoting to an AI future are starting to add up. Why it matters: CEO Elon Musk has directed the company to invest heavily in the development and production of humanoid robots, self-driving cars and AI chips. Driving the news: The company reported Q1 revenue of $22.4 billion, up 16% from a year earlier. Net income totaled $477 million, up 17%, but operating expenses ballooned 37%, to $3.78 billion. Its operating margin fell to 4.2%, declining sequentially for the second consecutive quarter. Musk acknowledged on an earnings call that the company is planning on "a very significant increase in capital expenditures," but he said it will be "well justified for a substantially increased future revenue stream." State of play: The company recently discontinued the Model S sedan and Model X crossover to make way for the production of the Optimus robot at its factory in Fremont, Calif.…