Memory efficient computation for large scale machine learning and data inference