Advanced Compiler and Runtime Optimizations for ML Workloads