Memory-Centric System Optimization for Machine Learning Training and Inference