A Programmable Approach to Model Compression