Skip to content

Improve readability #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/causal_lm_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install OpenVINO
run: |
mkdir ./ov/
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2023.3.0-13739-294cc6668c4/l_openvino_toolkit_ubuntu20_2023.3.0.dev20231219_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.0.0-14004-a240ae8fadd/l_openvino_toolkit_ubuntu20_2024.0.0.dev20240116_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
sudo ./ov/install_dependencies/install_openvino_dependencies.sh
- name: Download, convert and build
run: |
Expand Down Expand Up @@ -145,20 +145,20 @@ jobs:
- name: Install OpenVINO
shell: bash
run: |
curl --output ov.zip https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2023.3.0-13739-294cc6668c4/w_openvino_toolkit_windows_2023.3.0.dev20231219_x86_64.zip
curl --output ov.zip https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.0.0-14004-a240ae8fadd/w_openvino_toolkit_windows_2024.0.0.dev20240116_x86_64.zip
unzip ov.zip
- name: Download, convert and build
shell: cmd
run: |
call w_openvino_toolkit_windows_2023.3.0.dev20231219_x86_64\setupvars.bat
call w_openvino_toolkit_windows_2024.0.0.dev20240116_x86_64\setupvars.bat
python -m pip install --upgrade-strategy eager transformers==4.35.2 "optimum>=1.14" -r ./llm_bench/python/requirements.txt ./thirdparty/openvino_contrib/modules/custom_operations/[transformers] --extra-index-url https://download.pytorch.org/whl/cpu
python ./llm_bench/python/convert.py --model_id TinyLlama/TinyLlama-1.1B-Chat-v0.6 --output_dir ./TinyLlama-1.1B-Chat-v0.6/ --precision FP16 --stateful
cmake -DCMAKE_BUILD_TYPE=Release -S ./text_generation/causal_lm/cpp/ -B ./build/
cmake --build ./build/ --config Release -j
- name: Compare
shell: cmd
run: |
call w_openvino_toolkit_windows_2023.3.0.dev20231219_x86_64\setupvars.bat
call w_openvino_toolkit_windows_2024.0.0.dev20240116_x86_64\setupvars.bat
convert_tokenizer .\TinyLlama-1.1B-Chat-v0.6\pytorch\dldt\FP16\ --output .\TinyLlama-1.1B-Chat-v0.6\pytorch\dldt\FP16\ --with-detokenizer

.\build\Release\beam_search_causal_lm.exe .\TinyLlama-1.1B-Chat-v0.6\pytorch\dldt\FP16\ "69" > .\pred.txt
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
- name: Install OpenVINO
run: |
mkdir ./ov/
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2023.3.0-13739-294cc6668c4/l_openvino_toolkit_ubuntu20_2023.3.0.dev20231219_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.0.0-14004-a240ae8fadd/l_openvino_toolkit_ubuntu20_2024.0.0.dev20240116_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
sudo ./ov/install_dependencies/install_openvino_dependencies.sh
- name: Download, convert and build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stable_diffusion_1_5_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: true
jobs:
stable_diffusion_1_5_cpp:
runs-on: ubuntu-20.04
runs-on: ubuntu-20.04-8-cores
steps:
- uses: actions/checkout@v4
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cd "`abs_path`"

# initialize OpenVINO
rm -fr ./openvino && mkdir ./openvino
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2023.3.0-13739-294cc6668c4/l_openvino_toolkit_ubuntu20_2023.3.0.dev20231219_x86_64.tgz | tar --directory ./openvino/ --strip-components 1 -xz
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.0.0-14004-a240ae8fadd/l_openvino_toolkit_ubuntu20_2024.0.0.dev20240116_x86_64.tgz | tar --directory ./openvino/ --strip-components 1 -xz
sudo -E ./openvino/install_dependencies/install_openvino_dependencies.sh
source ./openvino/setupvars.sh

Expand Down
4 changes: 2 additions & 2 deletions image_generation/stable_diffusion_1_5/cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ int32_t main(int32_t argc, char* argv[]) try {
return EXIT_SUCCESS;
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
return 1;
return EXIT_FAILURE;
} catch (...) {
std::cerr << "Non-exception object thrown\n";
return 2;
return EXIT_FAILURE;
}
6 changes: 3 additions & 3 deletions text_generation/causal_lm/cpp/beam_search_causal_lm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) try {
std::vector<int32_t> next_beams;
for (size_t length_count = 0; length_count < parameters.max_new_tokens; ++length_count) {
lm.infer();
std::tie(next_tokens, next_beams) = group_beam_searcher.process(lm.get_tensor("logits"));
std::tie(next_tokens, next_beams) = group_beam_searcher.select_next_tokens(lm.get_tensor("logits"));
if (next_tokens.empty()) {
break;
}
Expand Down Expand Up @@ -86,8 +86,8 @@ int main(int argc, char* argv[]) try {
lm.reset_state();
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
return 1;
return EXIT_FAILURE;
} catch (...) {
std::cerr << "Non-exception object thrown\n";
return 1;
return EXIT_FAILURE;
}
4 changes: 2 additions & 2 deletions text_generation/causal_lm/cpp/greedy_causal_lm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ int main(int argc, char* argv[]) try {
lm.reset_state();
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
return 1;
return EXIT_FAILURE;
} catch (...) {
std::cerr << "Non-exception object thrown\n";
return 1;
return EXIT_FAILURE;
}
2 changes: 1 addition & 1 deletion text_generation/causal_lm/cpp/group_beam_searcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct GroupBeamSearcher {
group.ongoing.front().score = 0.0;
}
}
std::pair<std::vector<int64_t>, std::vector<int32_t>> process(const ov::Tensor& logits) {
std::pair<std::vector<int64_t>, std::vector<int32_t>> select_next_tokens(const ov::Tensor& logits) {
std::vector<int64_t> next_tokens;
std::vector<int32_t> next_beams;
next_tokens.reserve(parameters.n_groups * parameters.group_size);
Expand Down
2 changes: 1 addition & 1 deletion text_generation/causal_lm/cpp/set_up_and_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function abs_path() {
cd "`abs_path`"

mkdir ./ov/
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2023.3.0-13739-294cc6668c4/l_openvino_toolkit_ubuntu20_2023.3.0.dev20231219_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.0.0-14004-a240ae8fadd/l_openvino_toolkit_ubuntu20_2024.0.0.dev20240116_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
sudo ./ov/install_dependencies/install_openvino_dependencies.sh

source ./ov/setupvars.sh
Expand Down