diff --git a/CMakeLists.txt b/CMakeLists.txt index 49cd06d1c..feca45cfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ find_package(Threads REQUIRED) add_compile_definitions(LOG_DISABLE_LOGS) add_compile_definitions(GGML_USE_CPU) +add_compile_definitions(GGML_USE_CPU_AARCH64) file(GLOB GGML_SOURCES_CUDA "ggml/src/ggml-cuda/*.cu") list(APPEND GGML_SOURCES_CUDA "ggml/src/ggml-cuda/ggml-cuda.cu") diff --git a/Makefile b/Makefile index 97e2d116b..df08953d5 100644 --- a/Makefile +++ b/Makefile @@ -54,8 +54,8 @@ ifdef KCPP_DEBUG CFLAGS = -g -O0 CXXFLAGS = -g -O0 endif -CFLAGS += -I. -Iggml/include -Iggml/src -Iggml/src/ggml-cpu -Iinclude -Isrc -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_CPU -CXXFLAGS += -I. -Iggml/include -Iggml/src -Iggml/src/ggml-cpu -Iinclude -Isrc -I./common -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c++11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_CPU +CFLAGS += -I. -Iggml/include -Iggml/src -Iggml/src/ggml-cpu -Iinclude -Isrc -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_CPU -DGGML_USE_CPU_AARCH64 +CXXFLAGS += -I. -Iggml/include -Iggml/src -Iggml/src/ggml-cpu -Iinclude -Isrc -I./common -I./include -I./include/CL -I./otherarch -I./otherarch/tools -I./otherarch/sdcpp -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c++11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_CPU -DGGML_USE_CPU_AARCH64 ifndef KCPP_DEBUG CFLAGS += -DNDEBUG -s CXXFLAGS += -DNDEBUG -s diff --git a/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp b/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp index 788f45059..386cd53d6 100644 --- a/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp +++ b/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp @@ -3821,7 +3821,9 @@ static int repack_iq4_nl_to_iq4_nl_4_bl(struct ggml_tensor * t, int interleave_b GGML_UNUSED(data_size); } -namespace ggml::cpu::aarch64 { +namespace ggml { +namespace cpu { +namespace aarch64 { //ggml::cpu::aarch64 // repack template int repack(struct ggml_tensor *, const void *, size_t); @@ -4137,6 +4139,8 @@ static const tensor_traits q4_0_8x8_q8_0; // instance for IQ4 static const tensor_traits iq4_nl_4x4_q8_0; +} +} } // namespace ggml::cpu::aarch64 static const ggml::cpu::tensor_traits * ggml_aarch64_get_optimal_repack_type(const struct ggml_tensor * cur) { @@ -4210,7 +4214,9 @@ static size_t ggml_backend_cpu_aarch64_buffer_type_get_alignment(ggml_backend_bu GGML_UNUSED(buft); } -namespace ggml::cpu::aarch64 { +namespace ggml { +namespace cpu { +namespace aarch64 { //ggml::cpu::aarch64 class extra_buffer_type : ggml::cpu::extra_buffer_type { bool supports_op(ggml_backend_dev_t, const struct ggml_tensor * op) override { if ( op->op == GGML_OP_MUL_MAT && @@ -4257,6 +4263,9 @@ class extra_buffer_type : ggml::cpu::extra_buffer_type { return nullptr; } }; + +} +} } // namespace ggml::cpu::aarch64 ggml_backend_buffer_type_t ggml_backend_cpu_aarch64_buffer_type(void) { diff --git a/ggml/src/ggml-cpu/ggml-cpu-traits.cpp b/ggml/src/ggml-cpu/ggml-cpu-traits.cpp index 62a0712da..1d92c7b32 100644 --- a/ggml/src/ggml-cpu/ggml-cpu-traits.cpp +++ b/ggml/src/ggml-cpu/ggml-cpu-traits.cpp @@ -3,10 +3,12 @@ #include "ggml-backend-impl.h" #include "ggml-backend.h" -namespace ggml::cpu { +namespace ggml { +namespace cpu { tensor_traits::~tensor_traits() {} extra_buffer_type::~extra_buffer_type() {} +} } // namespace ggml::cpu bool ggml_cpu_extra_compute_forward(struct ggml_compute_params * params, struct ggml_tensor * op) { diff --git a/ggml/src/ggml-cpu/ggml-cpu-traits.h b/ggml/src/ggml-cpu/ggml-cpu-traits.h index 99a6186b1..848f74867 100644 --- a/ggml/src/ggml-cpu/ggml-cpu-traits.h +++ b/ggml/src/ggml-cpu/ggml-cpu-traits.h @@ -15,7 +15,8 @@ bool ggml_cpu_extra_work_size(int n_threads, const struct ggml_tensor * op, size #ifdef __cplusplus } -namespace ggml::cpu { +namespace ggml { +namespace cpu { // register in tensor->extra class tensor_traits { public: @@ -30,6 +31,7 @@ class extra_buffer_type { virtual bool supports_op(ggml_backend_dev_t dev, const struct ggml_tensor * op) = 0; virtual tensor_traits * get_tensor_traits(const struct ggml_tensor * op) = 0; }; +} } // namespace ggml::cpu // implemented in ggml-cpu.cpp.