EuclidNets: Combining Hardware and Architecture Design for Efficient Training and Inference