Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle weights file in assets and deliver to external storage #1

Draft
wants to merge 1 commit into
base: lc0
Choose a base branch
from

Conversation

lealgo
Copy link

@lealgo lealgo commented May 17, 2020

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

#ifdef __ANDROID__
  const std::string root_path = "/mnt/sdcard/lc0";
#else
  const std::string root_path = CommandLine::BinaryDirectory();
#endif

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.

@lealgo lealgo changed the title Have the engine access weights from external storage Bundle weights file in assets and deliver to external storage May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant