Compute-in-Memory Primitives for Energy-Efficient Machine Learning