I guess it is related to “reverse-mode vs forward-mode”. As wikipedia Automatic_differentiation 76 states, reverse-mode is more efficient for “tensor input scalar output” while forward-mode is more efficient for “scalar input tensor output”. That’s why machine learning library uses reverse-mode.
Jacobian matrix, however, is about “tensor input tensor output”. Not sure which way would be more efficient .