Merge branch 'master' into concedo

This commit is contained in:
Concedo 2023-03-19 00:07:32 +08:00
commit e3d85aa08b
3 changed files with 58 additions and 3 deletions

View file

@ -1,5 +1,20 @@
name: CI name: CI
on: [push, pull_request]
on:
workflow_dispatch: # allows manual triggering
inputs:
create_release:
description: 'Create new release'
required: true
type: boolean
push:
paths: ['.github/workflows/**', 'CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
pull_request:
types: [opened, synchronize, edited, reopened, review_requested, ready_for_review]
paths: ['CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs: jobs:
ubuntu-latest-make: ubuntu-latest-make:
@ -7,14 +22,17 @@ jobs:
steps: steps:
- name: Clone - name: Clone
id: checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: Dependencies - name: Dependencies
id: depends
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install build-essential sudo apt-get install build-essential
- name: Build - name: Build
id: make_build
run: | run: |
make make
@ -42,13 +60,16 @@ jobs:
steps: steps:
- name: Clone - name: Clone
id: checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: Dependencies - name: Dependencies
id: depends
run: | run: |
brew update brew update
- name: Build - name: Build
id: make_build
run: | run: |
make make
@ -75,15 +96,49 @@ jobs:
steps: steps:
- name: Clone - name: Clone
id: checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: Build - name: Build
id: cmake_build
run: | run: |
mkdir build mkdir build
cd build cd build
cmake .. cmake ..
cmake --build . --config Release cmake --build . --config Release
- name: Get commit hash
id: commit
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: pr-mpt/actions-commit-hash@v2
- name: Pack artifacts
id: pack_artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
run: |
7z a llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip .\build\Release\*
- name: Create release
id: create_release
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: zendesk/action-create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}
- name: Upload release
id: upload_release
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: .\llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
asset_name: llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
asset_content_type: application/octet-stream
# ubuntu-latest-gcc: # ubuntu-latest-gcc:
# runs-on: ubuntu-latest # runs-on: ubuntu-latest
# #

View file

@ -1015,7 +1015,7 @@ int main(int argc, char ** argv) {
if(params.use_color) printf(ANSI_BOLD ANSI_COLOR_GREEN); if(params.use_color) printf(ANSI_BOLD ANSI_COLOR_GREEN);
if (scanf("%255[^\n]%n%*c", buf, &n_read) <= 0) { if (scanf("%255[^\n]%n%*c", buf, &n_read) <= 0) {
// presumable empty line, consume the newline // presumable empty line, consume the newline
scanf("%*c"); std::ignore = scanf("%*c");
n_read=0; n_read=0;
} }
if(params.use_color) printf(ANSI_COLOR_RESET); if(params.use_color) printf(ANSI_COLOR_RESET);

View file

@ -302,7 +302,7 @@ std::vector<gpt_vocab::id> llama_tokenize(const gpt_vocab & vocab, const std::st
// Forward pass // Forward pass
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
int max_len = std::min(len - i, MAX_TOKEN_LEN); int max_len = std::min(len - i, MAX_TOKEN_LEN);
for (int sub_len = 1; sub_len <= len - i; sub_len++) { for (int sub_len = 1; sub_len <= max_len; sub_len++) {
auto sub = text.substr(i, sub_len); auto sub = text.substr(i, sub_len);
auto token = vocab.token_to_id.find(sub); auto token = vocab.token_to_id.find(sub);
if (token != vocab.token_to_id.end()) { if (token != vocab.token_to_id.end()) {