Skip to content

Commit

Permalink
github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
grazder committed Apr 10, 2024
1 parent 585c779 commit 2dc2186
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on: [push]

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest]
python-version: ["3.8"]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Clone ggerganov/ggml
run: git clone https://github.com/ggerganov/ggml.git
- name: Install packages
run: pip install -r requirements.txt
- name: Saving model weights
run: python save_model_weights.py
- name: Creating build folder
run: mkdir build; cd build
- name: Cmake
run: cmake ..
- name: Make
run: make
- name: Try running model.cpp
run: ./model
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ add_subdirectory(ggml)
set(TEST_TARGET model)
add_executable(${TEST_TARGET} model.cpp)
target_link_libraries(${TEST_TARGET} PRIVATE ggml)
target_compile_features(${TEST_TARGET} PUBLIC cxx_std_14)
target_compile_features(${TEST_TARGET} PUBLIC cxx_std_11)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cmake ..; make
- [ ] Trying on real model
- [ ] Adept template for real case usage
- [ ] Writing comments
- [ ] Add argparse for `model.cpp`
- [ ] Support FP16
- [ ] Quantization (?)

9 changes: 5 additions & 4 deletions model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,15 @@ int main(void)
{
ggml_time_init();

// Create example tensor
std::vector<float> input = {1, 2, 3, 4, 5};

// Load model and run forward
module model;
load_model("../ggml-model.bin", model);

// perform computation in cpu
std::vector<float> input = {1, 2, 3, 4, 5};
struct ggml_tensor *result = compute(model, input);

// get the result data pointer as a float array to print
// Printing
std::vector<float> out_data(ggml_nelements(result));
memcpy(out_data.data(), result->data, ggml_nbytes(result));

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
torch
numpy

0 comments on commit 2dc2186

Please sign in to comment.