LDP: Learnable Dynamic Precision for Efficient Deep Neural Network Training and Inference