Hardware-Software Codesign For Efficient Machine Learning Using In-Memory Computing