Hardware-aware Training for In-memory Computing Systems