What is difference between Model.register_for_auto_class and AutoModel.register?

I have created some new model and want to register it, so I can use AutoModelFor…() to call it.
I have read Sharing custom models, but I can’t tell the difference between



AutoConfig.register("resnet", ResnetConfig)
AutoModel.register(ResnetConfig, ResnetModel)
AutoModelForImageClassification.register(ResnetConfig, ResnetModelForImageClassification)

Can anyone tell me the difference and which one I should use?

The first one makes it so that the code of your model is also saved when you do model.save_pretrained so it can be re-used by another user (it’s the code on the Hub feature).

The second one allows you to use your custom model with the auto-API (but doesn’t share any custom code with other users).