Issue error when serializing ANN models without MLPACK_ENABLE_ANN_SERIALIZATION
#3451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for @yurivict's suggestion in #3449.
If
MLPACK_ENABLE_ANN_SERIALIZATIONis not defined, then we issue a runtime exception. I tried to make it a static assertion only, so the failure was at compile time, but I couldn't quickly find a way to make the compilation fail only whenFFN::serialize()was called (orRNN::serialize()). I think the runtime error is fine though.I left an "escape mechanism": if the user defines
MLPACK_ANN_IGNORE_SERIALIZATION_WARNING, then the exception is not thrown. This is in case a user wants to specifically instantiate serialization for only certain layers, which would be done with customCEREAL_REGISTER_TYPE()calls.