diff --git a/README.md b/README.md index 1dd2337a..081f3f0d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,15 @@ **视频课程链接:**[https://space.bilibili.com/1822828582](https://space.bilibili.com/1822828582) +## 对llama的支持 +> 我们将[llama.c](https://github.com/karpathy/llama2.c )中的算子替换为了KuiperInfer中的实现 + +模型下载地址 + +链接:https://pan.baidu.com/s/1PF5KqvIvNFR8yDIY1HmTYA?pwd=ma8r + +![a.gif](imgs/a.gif) + ## 第二次课程大纲 第二次课程是第一次课程的重置版,内容更加充实和完善,第一次课程大纲见下方章节。 diff --git a/demos/llama2/CMakeLists.txt b/demos/llama2/CMakeLists.txt index f76be0ab..b62e22cb 100644 --- a/demos/llama2/CMakeLists.txt +++ b/demos/llama2/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16) set(CMAKE_CXX_STANDARD 17) -#if (MSVC) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2") -#else () -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fopenmp -march=native") -#endif () -#set(CMAKE_BUILD_TYPE Release) +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2") +else () + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fopenmp -march=native") +endif () +set(CMAKE_BUILD_TYPE Release) add_executable(llama_chat llama_chat.cpp main.cpp) target_link_directories(llama_chat PUBLIC ${PROJECT_SOURCE_DIR}/lib) target_link_libraries(llama_chat ${OpenCV_LIBS} kuiper) diff --git a/imgs/a.gif b/imgs/a.gif new file mode 100644 index 00000000..d22e778e Binary files /dev/null and b/imgs/a.gif differ diff --git a/source/layer/details/matmul.cpp b/source/layer/details/matmul.cpp index 0783bec8..b947111e 100644 --- a/source/layer/details/matmul.cpp +++ b/source/layer/details/matmul.cpp @@ -117,8 +117,7 @@ StatusCode LLamaMatmulLayer::Forward(const std::vectorraw_ptr(), input_dim1, weight_dim0_, false, true); diff --git a/test/test_layer/test_softmax.cpp b/test/test_layer/test_softmax.cpp index 170fc4dd..a8574b84 100644 --- a/test/test_layer/test_softmax.cpp +++ b/test/test_layer/test_softmax.cpp @@ -211,6 +211,32 @@ TEST(test_layer, forward_softmax_dim01) { } } + +TEST(test_layer, forward_softmax_dim011) { + using namespace kuiper_infer; + SoftmaxLayer softmax_layer(0); + uint32_t size = 97; + std::vector values; + for (uint32_t i = 0; i < size; ++i) { + values.push_back(float(i)); + } + + const uint32_t batch_size = 1; + std::vector inputs; + + sftensor input = std::make_shared(97); + input->Fill(values); + + std::vector outputs(1); + inputs.push_back(input); + softmax_layer.Forward(inputs, outputs); + softmax1(values.data(), values.size()); + for (int i = 0; i < size; ++i) { + ASSERT_EQ(input->index(i), float(i)); + ASSERT_NEAR(values.at(i), outputs.front()->index(i), 1e-3f); + } +} + TEST(test_layer, forward_softmax_dim02) { using namespace kuiper_infer; SoftmaxLayer softmax_layer(0);