Bundle weights file in assets and deliver to external storage #1
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.
Motivation: The current method to include the weights file is to embed it into the engine binary. But now that we target more architectures (armv7, aarch64 and x86) the weights file must be embedded into each one, making the app size grow a little too much. Maybe this is OK, but I though about another approach that's less wasteful and may also have other advantages.
This PR bundles the weights file in the app's assets and copies it to external storage at install time, or when the user grants permission. This way the weights file lives in a user visible folder from where the autodiscover feature will pick it up. The user could provide a newer one, and maybe we could make the app download fresh weights from the internet into this folder.
The issue with this approach is that there's no way for the engine to detect the actual path of the external storage accross different devices. This exact path can be discoverd in the app (java) but not from the engine (process). We would need to use a list of common used paths and let the autodiscover try them all. For now I'm hardcoding the root path with a good guess in
loader.cc
Fixing the following engine issue will definitely help:
LeelaChessZero/lc0#976
Worst case scenario is the path doesn't work on the device and the user should edit weights path by hand. The app could advise the user with the correct path.