Automatic Perturbation Analysis on General Computational Graphs