Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ target_link_libraries(gemma_shared PRIVATE
$<LINK_LIBRARY:WHOLE_ARCHIVE,hwy>
$<LINK_LIBRARY:WHOLE_ARCHIVE,hwy_contrib>
$<LINK_LIBRARY:WHOLE_ARCHIVE,sentencepiece-static>
nlohmann_json::nlohmann_json
)
target_include_directories(gemma_shared PUBLIC ${sentencepiece_SOURCE_DIR})
target_compile_definitions(gemma_shared
Expand All @@ -324,8 +325,8 @@ if(GEMMA_ONEDNN_MATMUL)
target_link_libraries(gemma_shared PRIVATE dnnl)
endif()
install(TARGETS gemma_shared DESTINATION lib)
install(FILES gemma/c_api.h DESTINATION include/gemma)
install(FILES gemma/GemmaInterop.cs DESTINATION include/gemma)
install(FILES gemma/bindings/c_api.h gemma/bindings/context.h DESTINATION include/gemma/bindings)
install(FILES gemma/bindings/GemmaInterop.cs DESTINATION include/gemma/bindings)
endif()

# Executable Target
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"cacheVariables": {
"BUILD_SHARED_LIBS": "OFF",
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS": "ON",
"BUILD_GEMMA_DLL": "ON"
"BUILD_GEMMA_DLL": "ON",
"CMAKE_POLICY_VERSION_MINIMUM": "3.5"
}
}
],
Expand Down
2 changes: 0 additions & 2 deletions gemma/bindings/GemmaInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ static Gemma()
[DllImport("gemma", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr GemmaCreate(
[MarshalAs(UnmanagedType.LPUTF8Str)] string tokenizerPath,
[MarshalAs(UnmanagedType.LPUTF8Str)] string modelType,
[MarshalAs(UnmanagedType.LPUTF8Str)] string weightsPath,
[MarshalAs(UnmanagedType.LPUTF8Str)] string weightType,
int maxGeneratedTokens);

[DllImport("gemma", CallingConvention = CallingConvention.Cdecl)]
Expand Down
2 changes: 2 additions & 0 deletions gemma/bindings/c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ GEMMA_API void GemmaSetLogCallback(GemmaContext* ctx, GemmaLogCallback callback,
void* user_data);

// Configuration functions
GEMMA_API void GemmaSetMaxGeneratedTokens(GemmaContext* ctx, int value);
GEMMA_API void GemmaSetMultiturn(GemmaContext* ctx, int value);
GEMMA_API void GemmaSetTemperature(GemmaContext* ctx, float value);
GEMMA_API void GemmaSetTopK(GemmaContext* ctx, int value);
GEMMA_API void GemmaSetDeterministic(GemmaContext* ctx, int value);
GEMMA_API void GemmaSetPrefillTbatchSize(GemmaContext* ctx, int value);
GEMMA_API void GemmaResetConversation(GemmaContext* ctx);

// Conversation management functions (renamed)
Expand Down
6 changes: 3 additions & 3 deletions gemma/bindings/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ GemmaContext* GemmaContext::Create(const char* tokenizer_path,

ThreadingArgs threading_args;
threading_args.spin = gcpp::Tristate::kFalse;

threading_args.spin = gcpp::Tristate::kFalse;
GemmaArgs args(LoaderArgs(tokenizer_path, weights_path), threading_args);
GemmaArgs args(LoaderArgs(tokenizer_path ? tokenizer_path : "",
weights_path ? weights_path : ""),
threading_args);

// Initialize cached args
LogDebug("Initializing inference args");
Expand Down