Avoid potential fatal error when processing models with empty layers. #1127