Fix debug_prompt and other binaries (internal init)

PiperOrigin-RevId: 644367683
This commit is contained in:
Jan Wassenberg 2024-06-18 06:48:32 -07:00 committed by Copybara-Service
parent 15135f5b3d
commit 70506b0a62
1 changed files with 10 additions and 4 deletions

View File

@ -86,15 +86,21 @@ GemmaEnv::GemmaEnv(const LoaderArgs& loader, const InferenceArgs& inference,
}; };
} }
// Note: the delegating ctor above is called before any other initializers here. // Internal init must run before the GemmaEnv ctor above, hence it cannot occur
GemmaEnv::GemmaEnv(int argc, char** argv) // in the argv ctor below because its body runs *after* the delegating ctor.
: GemmaEnv(LoaderArgs(argc, argv), InferenceArgs(argc, argv), // This helper function takes care of the init, and could be applied to any of
AppArgs(argc, argv)) { // the *Args classes, it does not matter which.
static AppArgs MakeAppArgs(int argc, char** argv) {
{ // So that indentation matches expectations. { // So that indentation matches expectations.
// Placeholder for internal init, do not modify. // Placeholder for internal init, do not modify.
} }
return AppArgs(argc, argv);
} }
GemmaEnv::GemmaEnv(int argc, char** argv)
: GemmaEnv(LoaderArgs(argc, argv), InferenceArgs(argc, argv),
MakeAppArgs(argc, argv)) {}
std::pair<std::string, size_t> GemmaEnv::QueryModel( std::pair<std::string, size_t> GemmaEnv::QueryModel(
const std::vector<int>& tokens) { const std::vector<int>& tokens) {
std::string res; std::string res;