For modules with parameters, next(m.parameters()).device. Modules without parameters should take tensors on any device.
This will fail for modules with mixed devices, but you probably don’t expect those to work, do you?
Best regards
Thomas