diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml new file mode 100644 index 00000000..33dd5223 --- /dev/null +++ b/.github/workflows/ios.yml @@ -0,0 +1,38 @@ +name: ios +on: + push: + branches: + - master + - 'feature/**' + paths: + - 'src/**' + - 'ios/**' + - '.github/workflows/ios.yml' + pull_request: + branches: [master] + paths: + - 'src/**' + - 'ios/**' + - '.github/workflows/ios.yml' + +jobs: + build: + name: ios-build + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: download_mode + run: | + wget -c -nv https://github.com/wangzhaode/mnn-llm/releases/download/qwen1.5-0.5b-chat-mnn/Qwen1.5-0.5B-Chat-MNN.zip + unzip Qwen1.5-0.5B-Chat-MNN.zip + mv Qwen1.5-0.5B-Chat-MNN/* ios/mnn-llm/model/qwen1.5-0.5b-chat/ + + - name: build + run: | + pwd + ls .. + ./script/ios_build.sh \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 76a1baeb..6fd0a585 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -17,7 +17,7 @@ on: jobs: build: - name: linux-build + name: python-build runs-on: ubuntu-latest steps: diff --git a/ios/mnn-llm/mnn-llm.xcodeproj/project.pbxproj b/ios/mnn-llm/mnn-llm.xcodeproj/project.pbxproj index 5f19f611..aae6b136 100644 --- a/ios/mnn-llm/mnn-llm.xcodeproj/project.pbxproj +++ b/ios/mnn-llm/mnn-llm.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4D3B58022C207A1F00E2A1E0 /* qwen1.5-0.5b-chat in Resources */ = {isa = PBXBuildFile; fileRef = 4D3B58012C207A1F00E2A1E0 /* qwen1.5-0.5b-chat */; }; 4D5B978C2B2B21D3003AF2F1 /* mnn_llmApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5B978B2B2B21D3003AF2F1 /* mnn_llmApp.swift */; }; 4D5B978E2B2B21D3003AF2F1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5B978D2B2B21D3003AF2F1 /* ContentView.swift */; }; 4D5B97902B2B21D5003AF2F1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4D5B978F2B2B21D5003AF2F1 /* Assets.xcassets */; }; @@ -182,7 +183,6 @@ 4D94A73A2C2025B6004E5A87 /* SparseConvolutionTiledExecutor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D9488742C2025B0004E5A87 /* SparseConvolutionTiledExecutor.cpp */; }; 4D94A73B2C2025B6004E5A87 /* StrassenMatmulComputor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D9488762C2025B0004E5A87 /* StrassenMatmulComputor.cpp */; }; 4D94A73C2C2025B6004E5A87 /* WinogradOptFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D9488782C2025B0004E5A87 /* WinogradOptFunction.cpp */; }; - 4D94A7702C2025B6004E5A87 /* CMakeLists.txt in Resources */ = {isa = PBXBuildFile; fileRef = 4D9488CB2C2025B0004E5A87 /* CMakeLists.txt */; }; 4D94A7712C2025B6004E5A87 /* CPUArgMax.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D9488CC2C2025B0004E5A87 /* CPUArgMax.cpp */; }; 4D94A7722C2025B6004E5A87 /* CPUAttention.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D9488CE2C2025B0004E5A87 /* CPUAttention.cpp */; }; 4D94A7732C2025B6004E5A87 /* CPUBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D9488D02C2025B0004E5A87 /* CPUBackend.cpp */; }; @@ -403,10 +403,10 @@ 4D94AB0D2C2025B8004E5A87 /* SizeComputer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D948EB42C2025B0004E5A87 /* SizeComputer.cpp */; }; 4D94AB0E2C2025B8004E5A87 /* InitNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D948EB72C2025B0004E5A87 /* InitNet.cpp */; }; 4D94AB0F2C2025B8004E5A87 /* JNIHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D948EB92C2025B0004E5A87 /* JNIHelper.cpp */; }; - 4D94B93A2C203DA7004E5A87 /* qwen1.5-0.5b-chat in Resources */ = {isa = PBXBuildFile; fileRef = 4D94B9392C203DA7004E5A87 /* qwen1.5-0.5b-chat */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 4D3B58012C207A1F00E2A1E0 /* qwen1.5-0.5b-chat */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "qwen1.5-0.5b-chat"; path = "model/qwen1.5-0.5b-chat"; sourceTree = ""; }; 4D5B97882B2B21D3003AF2F1 /* mnn-llm.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "mnn-llm.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4D5B978B2B2B21D3003AF2F1 /* mnn_llmApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mnn_llmApp.swift; sourceTree = ""; }; 4D5B978D2B2B21D3003AF2F1 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -657,7 +657,6 @@ 4D9488782C2025B0004E5A87 /* WinogradOptFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WinogradOptFunction.cpp; sourceTree = ""; }; 4D9488792C2025B0004E5A87 /* WinogradOptFunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WinogradOptFunction.hpp; sourceTree = ""; }; 4D9488CA2C2025B0004E5A87 /* BinaryUtils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BinaryUtils.hpp; sourceTree = ""; }; - 4D9488CB2C2025B0004E5A87 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 4D9488CC2C2025B0004E5A87 /* CPUArgMax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUArgMax.cpp; sourceTree = ""; }; 4D9488CD2C2025B0004E5A87 /* CPUArgMax.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CPUArgMax.hpp; sourceTree = ""; }; 4D9488CE2C2025B0004E5A87 /* CPUAttention.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUAttention.cpp; sourceTree = ""; }; @@ -989,7 +988,6 @@ 4D948EB82C2025B0004E5A87 /* InitNet.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InitNet.hpp; sourceTree = ""; }; 4D948EB92C2025B0004E5A87 /* JNIHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JNIHelper.cpp; sourceTree = ""; }; 4D948EBA2C2025B0004E5A87 /* JNIHelper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JNIHelper.hpp; sourceTree = ""; }; - 4D94B9392C203DA7004E5A87 /* qwen1.5-0.5b-chat */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "qwen1.5-0.5b-chat"; path = "../../../model/public/qwen1.5-0.5b-chat"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1006,7 +1004,7 @@ 4D5B977F2B2B21D3003AF2F1 = { isa = PBXGroup; children = ( - 4D94B9392C203DA7004E5A87 /* qwen1.5-0.5b-chat */, + 4D3B58012C207A1F00E2A1E0 /* qwen1.5-0.5b-chat */, 4D5B978A2B2B21D3003AF2F1 /* mnn-llm */, 4D5B97892B2B21D3003AF2F1 /* Products */, 4D5B97C52B2B2C26003AF2F1 /* Frameworks */, @@ -1423,7 +1421,6 @@ 4D9488352C2025B0004E5A87 /* arm */, 4D94887A2C2025B0004E5A87 /* compute */, 4D9488CA2C2025B0004E5A87 /* BinaryUtils.hpp */, - 4D9488CB2C2025B0004E5A87 /* CMakeLists.txt */, 4D9488CC2C2025B0004E5A87 /* CPUArgMax.cpp */, 4D9488CD2C2025B0004E5A87 /* CPUArgMax.hpp */, 4D9488CE2C2025B0004E5A87 /* CPUAttention.cpp */, @@ -1894,10 +1891,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4D3B58022C207A1F00E2A1E0 /* qwen1.5-0.5b-chat in Resources */, 4D5B97932B2B21D5003AF2F1 /* Preview Assets.xcassets in Resources */, 4D5B97902B2B21D5003AF2F1 /* Assets.xcassets in Resources */, - 4D94A7702C2025B6004E5A87 /* CMakeLists.txt in Resources */, - 4D94B93A2C203DA7004E5A87 /* qwen1.5-0.5b-chat in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/resource/models/download_models.ps1 b/resource/models/download_models.ps1 deleted file mode 100644 index 0661a50f..00000000 --- a/resource/models/download_models.ps1 +++ /dev/null @@ -1,96 +0,0 @@ -function help { - Write-Host "model download script" - Write-Host "Usage: ./download_model.ps1 [OPTIONS]" - Write-Host "" - Write-Host "Options:" - Write-Host " -h,--help Print this help message and exit" - Write-Host " fp16,int8,int4 Chose different models" - Write-Host " proxy Use https://ghproxy.com to proxy github when download file" -} - -function fp16_model { - mkdir fp16 - for ($i = 0; $i -le 27; $i++) { - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.1/glm_block_$i.mnn" -OutFile "fp16\glm_block_$i.mnn" - } - - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.1/lm.mnn" -OutFile "fp16\lm.mnn" - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.1/slim_word_embeddings.bin" -OutFile "fp16\slim_word_embeddings.bin" -} - -function int8_model { - mkdir int8 - for ($i = 0; $i -le 27; $i++) { - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.2/glm_block_$i.mnn" -OutFile "int8\glm_block_$i.mnn" - } - - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.1/lm.mnn" -OutFile "int8\lm.mnn" - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.1/slim_word_embeddings.bin" -OutFile "int8\slim_word_embeddings.bin" -} - -function int4_model { - mkdir int4 - for ($i = 0; $i -le 27; $i++) { - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.3/glm_block_$i.mnn" -OutFile "int4\glm_block_$i.mnn" - } - - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.1/lm.mnn" -OutFile "int4\lm.mnn" - Invoke-WebRequest -Uri "$($args[0])https://github.com/wangzhaode/ChatGLM-MNN/releases/download/v0.1/slim_word_embeddings.bin" -OutFile "int4\slim_word_embeddings.bin" -} - -if ($args.Length -eq 0) { - help - exit 1 -} - -$proxy = $false - -foreach ($arg in $args) { - switch ($arg) { - "--help" { - help - } - "-h" { - help - } - "proxy" { - $proxy = $true - } - } -} - -if ($proxy) { - foreach ($arg in $args) { - switch ($arg) { - "fp16" { - fp16_model "https://ghproxy.com/" - } - "int8" { - int8_model "https://ghproxy.com/" - } - "int4" { - int4_model "https://ghproxy.com/" - } - default { - help - } - } - } -} else { - foreach ($arg in $args) { - switch ($arg) { - "fp16" { - fp16_model "" - } - "int8" { - int8_model "" - } - "int4" { - int4_model "" - } - default { - help - } - } - } -} \ No newline at end of file diff --git a/script/ios_build.sh b/script/ios_build.sh new file mode 100755 index 00000000..89a69507 --- /dev/null +++ b/script/ios_build.sh @@ -0,0 +1,5 @@ +xcodebuild \ +CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED=NO \ +-project ios/mnn-llm/mnn-llm.xcodeproj \ +-target mnn-llm \ +-destination "platform=iOS,id=dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder,name=Any iOS Device" \ No newline at end of file