DietCode: Automatic Optimization for Dynamic Tensor Programs