mirror of https://github.com/google/gemma.cpp.git
Merge pull request #58 from google:dev-cleanup
PiperOrigin-RevId: 610942948
This commit is contained in:
commit
f4a14bfdf2
|
|
@ -0,0 +1 @@
|
||||||
|
BasedOnStyle: Google
|
||||||
|
|
@ -71,6 +71,18 @@ The implementation code is roughly split into 4 layers, from high to low level:
|
||||||
4. Backend (`highway`) - Low-level hardware interface (SIMD in the case of
|
4. Backend (`highway`) - Low-level hardware interface (SIMD in the case of
|
||||||
highway) supporting the implementations in (3).
|
highway) supporting the implementations in (3).
|
||||||
|
|
||||||
|
Besides these layers, supporting utilities are:
|
||||||
|
|
||||||
|
- `compression/` - model compression operations. The 8-bit switched floating
|
||||||
|
point model conversion is here.
|
||||||
|
- `util/` - command line argument handling and any other utilities.
|
||||||
|
|
||||||
|
## Style and Formatting
|
||||||
|
|
||||||
|
A `.clang-format` configuration is provided with our defaults, please run source
|
||||||
|
files through `clang-format` (or a formatter that produces equivalent behavior)
|
||||||
|
before finalizing PR for submission.
|
||||||
|
|
||||||
## Compile-Time Flags (Advanced)
|
## Compile-Time Flags (Advanced)
|
||||||
|
|
||||||
There are several compile-time flags to be aware of (note these may or may not
|
There are several compile-time flags to be aware of (note these may or may not
|
||||||
|
|
|
||||||
13
gemma.h
13
gemma.h
|
|
@ -26,15 +26,19 @@
|
||||||
|
|
||||||
// copybara:import_next_line:gemma_cpp
|
// copybara:import_next_line:gemma_cpp
|
||||||
#include "compression/compress.h" // SfpStream/NuqStream
|
#include "compression/compress.h" // SfpStream/NuqStream
|
||||||
|
// copybara:end
|
||||||
// copybara:import_next_line:gemma_cpp
|
// copybara:import_next_line:gemma_cpp
|
||||||
#include "configs.h" // kSeqLen
|
#include "configs.h" // kSeqLen
|
||||||
|
// copybara:end
|
||||||
// copybara:import_next_line:gemma_cpp
|
// copybara:import_next_line:gemma_cpp
|
||||||
#include "util/args.h" // ArgsBase
|
#include "util/args.h" // ArgsBase
|
||||||
|
// copybara:end
|
||||||
#include "hwy/aligned_allocator.h"
|
#include "hwy/aligned_allocator.h"
|
||||||
#include "hwy/base.h" // hwy::bfloat16_t
|
#include "hwy/base.h" // hwy::bfloat16_t
|
||||||
#include "hwy/contrib/thread_pool/thread_pool.h"
|
#include "hwy/contrib/thread_pool/thread_pool.h"
|
||||||
// copybara:import_next_line:sentencepiece
|
// copybara:import_next_line:sentencepiece
|
||||||
#include "src/sentencepiece_processor.h"
|
#include "src/sentencepiece_processor.h"
|
||||||
|
// copybara:end
|
||||||
|
|
||||||
namespace gcpp {
|
namespace gcpp {
|
||||||
|
|
||||||
|
|
@ -115,7 +119,8 @@ struct LoaderArgs : public ArgsBase<LoaderArgs> {
|
||||||
Path cache; // compressed weights
|
Path cache; // compressed weights
|
||||||
std::string model_type;
|
std::string model_type;
|
||||||
|
|
||||||
template <class Visitor> void ForEach(const Visitor &visitor) {
|
template <class Visitor>
|
||||||
|
void ForEach(const Visitor& visitor) {
|
||||||
visitor(tokenizer, "tokenizer", Path(),
|
visitor(tokenizer, "tokenizer", Path(),
|
||||||
"Path name of tokenizer model file. (required)");
|
"Path name of tokenizer model file. (required)");
|
||||||
visitor(
|
visitor(
|
||||||
|
|
@ -175,7 +180,8 @@ struct InferenceArgs : public ArgsBase<InferenceArgs> {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Visitor> void ForEach(const Visitor &visitor) {
|
template <class Visitor>
|
||||||
|
void ForEach(const Visitor& visitor) {
|
||||||
visitor(max_tokens, "max_tokens", size_t{3072},
|
visitor(max_tokens, "max_tokens", size_t{3072},
|
||||||
"Maximum number of tokens in prompt + generation.");
|
"Maximum number of tokens in prompt + generation.");
|
||||||
visitor(max_generated_tokens, "max_generated_tokens", size_t{2048},
|
visitor(max_generated_tokens, "max_generated_tokens", size_t{2048},
|
||||||
|
|
@ -186,7 +192,8 @@ struct InferenceArgs : public ArgsBase<InferenceArgs> {
|
||||||
"Make top-k sampling deterministic", 2);
|
"Make top-k sampling deterministic", 2);
|
||||||
visitor(multiturn, "multiturn", false,
|
visitor(multiturn, "multiturn", false,
|
||||||
"Multiturn mode (if 0, this clears the KV cache after every "
|
"Multiturn mode (if 0, this clears the KV cache after every "
|
||||||
"interaction without quitting)\n Default = 0 (conversation resets every turn)");
|
"interaction without quitting)\n Default = 0 (conversation "
|
||||||
|
"resets every turn)");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue