Understanding Diffusion Models: A Unified Perspective