Have a Car Question? Ask a Mechanic Online.
Hello and welcome to Justanswer!
There are quite a few things that could cause your problem.
The first thing I would recommend is checking for fault codes using a code reader or scan tool. The engine controller may have identified a failure in a monitored component or sensor and set a fault code that will be helpful in diagnosis. If there are any codes stored then the first thing you'll need to do is diagnose and repair those particular issues.
You may be losing spark or fuel. If it dies abruptly like the key was shut off then it's more likely to be a spark issue, which could be a bad coil, loss of cam or crank sensor signal, wiring, or the engine controller itself could be the issue. If there are no codes stored and it's dying abruptly like an ignition issue then the controller may be failing or losing a power or ground feed. If this were the case it wouldn't usually start right back up though.
You might be losing fuel pressure. Fuel demand is greater under higher engine loads, if pressure is low then that may be why it is dying as you try to accelerate. A loss of fuel pressure would usually cause the engine to hesitate and die more smoothly than it would if you lost spark where it would die abruptly. If this seems to be what is happening and there are no codes then I would recommend checking fuel pressure next. A fuel pressure gauge can be borrowed or rented from most large parts stores like Autozone if you don't have one available to you.