Skip to content

Commit 58a6fa4

Browse files
squash: integrate llama-gguf-viewer into testing-branch10
1 parent 7adc79c commit 58a6fa4

File tree

14 files changed

+7934
-0
lines changed

14 files changed

+7934
-0
lines changed

tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ llama_add_compile_flags()
1515
if (EMSCRIPTEN)
1616
else()
1717
add_subdirectory(batched-bench)
18+
add_subdirectory(gguf-viewer)
1819
add_subdirectory(gguf-split)
1920
add_subdirectory(imatrix)
2021
add_subdirectory(llama-bench)

tools/gguf-viewer/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
set(TARGET llama-gguf-viewer)
2+
3+
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
4+
5+
set(TARGET_SRCS
6+
viewer.cpp
7+
)
8+
9+
set(PUBLIC_ASSETS
10+
index.html
11+
)
12+
13+
foreach(asset ${PUBLIC_ASSETS})
14+
set(input "${CMAKE_CURRENT_SOURCE_DIR}/public/${asset}")
15+
set(output "${CMAKE_CURRENT_BINARY_DIR}/${asset}.hpp")
16+
list(APPEND TARGET_SRCS ${output})
17+
add_custom_command(
18+
DEPENDS "${input}"
19+
OUTPUT "${output}"
20+
COMMAND "${CMAKE_COMMAND}" "-DINPUT=${input}" "-DOUTPUT=${output}" -P "${PROJECT_SOURCE_DIR}/scripts/xxd.cmake"
21+
)
22+
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
23+
endforeach()
24+
25+
add_executable(${TARGET} ${TARGET_SRCS})
26+
install(TARGETS ${TARGET} RUNTIME)
27+
28+
# ensure common headers available
29+
include_directories(${CMAKE_SOURCE_DIR})
30+
31+
find_package(Threads REQUIRED)
32+
33+
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
34+
35+
target_compile_features(${TARGET} PRIVATE cxx_std_17)

tools/gguf-viewer/public/app.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
window.addEventListener("resize", () => {
2+
syncHeatmapToViewport(true);
3+
const statisticsVisible = normalizePageId(activePage || DEFAULT_PAGE) === "statistics";
4+
syncHistogramToViewport(statisticsVisible && !!heatmapState.tensor);
5+
});
6+
7+
syncHeatmapToViewport(false);
8+
resetViewer();
9+
10+
(async function init() {
11+
await loadModelList();
12+
if (currentModelPath) {
13+
await refreshAll();
14+
} else {
15+
resetViewer();
16+
}
17+
urlSyncReady = true;
18+
syncFullUrlState({ force: true });
19+
})();

0 commit comments

Comments
 (0)