As long as it's not cracked anywhere, it is perfectly safe to ride.
But, if you ride it a lot, it will eventually crack near those dents. The nice thing about aluminum though is that the cracks develop slowly, so you will see it coming. It's not likely to suddenly fall apart mid ride. (I speak from experience having put a huge dent into the top tube of my old S-Works E5 frameset. I raced it for six more weeks before a crack formed.)