Motivation: Finite-element analysis (FEA) is widely used as a standard tool for stress and deformation analysis of solid structures, including human tissues and organs. For instance, FEA can be applied at a patient-specific level to assist in medical diagnosis and treatment planning, such as risk assessment of thoracic aortic aneurysm rupture/dissection. These FEA-based biomechanical assessments often involve both forward and inverse mechanics problems. Current commercial FEA software packages (e.g., Abaqus) and inverse methods exhibit performance issues in either accuracy or speed. Methods: In this study, we propose and develop a new library of FEA code and methods, named PyTorch-FEA, by taking advantage of autograd, an automatic differentiation mechanism in PyTorch. We develop a class of PyTorch-FEA functionalities to solve forward and inverse problems with improved loss functions, and we demonstrate the capability of PyTorch-FEA in a series of applications related to human aorta biomechanics. In one of the inverse methods, we combine PyTorch-FEA with deep neural networks (DNNs) to further improve performance. Results: We applied PyTorch-FEA in four fundamental applications for biomechanical analysis of human aorta. In the forward analysis, PyTorch-FEA achieved a significant reduction in computational time without compromising accuracy compared with Abaqus, a commercial FEA package. Compared to other inverse methods, inverse analysis with PyTorch-FEA achieves better performance in either accuracy or speed, or both if combined with DNNs.