Check engine light on? You might want to check the stomp test as described in the PDF attached.
MAF sensor could do that or vacuum leak. Fuel pressure regulator also.
I would test for vacuum leak first, fuel pressure regulator, and then MAF. Clean it or try to run engine with MAF disconnected.
JOY = BMW