RRAM-CMOS integrated hardware for efficient learning and inference at the edge