The carmaker, which is controlled by Elon Musk and is considering merging with another of his companies, SpaceX, spent heavily on artificial intelligence and other new technologies.
SpaceX’s blockbuster public offering on the Nasdaq in June helped make Elon Musk, who is also the chief executive of Tesla, the first person to be worth more than a trillion dollars.