Skip to content
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

implement simplemath #4905

Merged
merged 60 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
44882ec
create simplemath placeholder files
HonestDeng Aug 3, 2023
f64c3e7
complete abs, fmod and sin function in simplemath.h
HonestDeng Aug 3, 2023
02bfa57
完成了simplemath的几个函数, 接下来要尝试剔除项目对libm的依赖
HonestDeng Aug 11, 2023
24fb1f7
剩下完成数学函数的实现
HonestDeng Aug 13, 2023
e547b2c
初步完成了数学函数的编写
HonestDeng Aug 14, 2023
5f3de04
完成了simplemath的所有函数,目前还剩下test_convolutiondepthwise_1无法通过
HonestDeng Aug 20, 2023
28b3b52
通过了所有的测试点!
HonestDeng Aug 22, 2023
e887cfc
通过了CI中的所有测试
HonestDeng Aug 23, 2023
98966d1
add build and test at ci
HonestDeng Aug 23, 2023
f1b07b5
clean chinese comments
HonestDeng Aug 23, 2023
7b5133a
remove some unused variables in simplemath.cpp
HonestDeng Aug 23, 2023
e116f98
change code format
HonestDeng Aug 23, 2023
90c7bba
apply code-format changes
HonestDeng Aug 23, 2023
4cdb0da
fix a bug in round function at simplemath.cpp
HonestDeng Aug 23, 2023
9c0a424
modify test-coverage.yml
HonestDeng Aug 28, 2023
2318ed8
modify test-coverage.yml and add some functions to simplemath.cpp
HonestDeng Sep 5, 2023
74f2e8d
apply code-format changes
HonestDeng Sep 5, 2023
8cc72a8
fix a bug in test-coverage.yml
HonestDeng Sep 5, 2023
9c58a56
fix a bug in test-coverage.yml
HonestDeng Sep 5, 2023
a60287c
fix a bug in test-coverage.yml
HonestDeng Sep 5, 2023
95b1bf6
fix a bug
HonestDeng Sep 5, 2023
f745dcc
fix a bug
HonestDeng Sep 5, 2023
b74c55a
modify simplemath.cpp
HonestDeng Sep 6, 2023
bdda15d
modify test-coverage.yml
HonestDeng Sep 7, 2023
e622d66
modify test-coverage.yml
HonestDeng Sep 8, 2023
10e6939
delelte an unused function
HonestDeng Sep 8, 2023
e096866
fix a bug
HonestDeng Sep 8, 2023
f9806db
Merge branch 'master' into simplemath
HonestDeng Sep 9, 2023
2cf544f
modify erf.cpp which included math.h
HonestDeng Sep 9, 2023
8126e1c
checkout master branch at ./tools directory
HonestDeng Sep 18, 2023
4320d4b
include platform.h for NCNN_SIMPLEMATH definition
HonestDeng Sep 18, 2023
78ba843
fix a bug
HonestDeng Sep 18, 2023
bda57ed
fix copyright info in simplemath.cpp and simplemath.h
HonestDeng Sep 18, 2023
dc48101
move utility constants and functions in simplemath.h to simplemath.cpp
HonestDeng Sep 18, 2023
14905f4
remove a debug printf statement in test_unaryop.cpp
HonestDeng Sep 18, 2023
11439df
guard simplemath functions with extern "C"
HonestDeng Sep 18, 2023
2280b5e
fix copyright info in simplemath.cpp
HonestDeng Sep 19, 2023
101d7a1
Merge branch 'master' into simplemath
HonestDeng Sep 19, 2023
92b3509
remove #include <math.h> statement in celu.cpp
HonestDeng Sep 19, 2023
d4e9da5
add NCNN_EXPORT macro in simplemath.h
HonestDeng Sep 19, 2023
552fee9
remove include <stdint.h> in simplemath.h
HonestDeng Sep 20, 2023
366d0c7
include plateform.h and guard all declarations with NCNN_SIMPLEMATH
HonestDeng Sep 20, 2023
883bb13
clean unused code in test_unaryop.cpp
HonestDeng Sep 20, 2023
ebf6993
checkout master branch at ./examples directory
HonestDeng Sep 20, 2023
1f2e420
guard #include <vector> with NCNN_SIMPLEMATH in benchncnn.cpp
HonestDeng Sep 20, 2023
cf0a626
apply code-format changes
HonestDeng Sep 20, 2023
3e368bd
fix a bug in .ci/linux-x64-cpu-gcc.yml
HonestDeng Sep 20, 2023
ab1f667
remove useless comments
HonestDeng Sep 21, 2023
6dbab7e
add 'static' to guard functions that not declarated in header file
HonestDeng Sep 21, 2023
9cb97b8
modify sin and cos with better implementation
HonestDeng Sep 21, 2023
72439aa
delete unused functions
HonestDeng Sep 21, 2023
9db8380
Merge branch 'master' into simplemath
HonestDeng Sep 21, 2023
454cd55
apply code-format changes
HonestDeng Sep 22, 2023
c079009
Merge branch 'Tencent:master' into simplemath
HonestDeng Sep 22, 2023
6f43ef7
successfully compile ncnn with simplemath in Mac M1
HonestDeng Sep 22, 2023
a5cc162
apply code-format changes
HonestDeng Sep 22, 2023
20e8ddd
Merge branch 'master' into simplemath
HonestDeng Sep 22, 2023
06a0dba
change comile flag
HonestDeng Sep 22, 2023
40ab383
modify some header comment
HonestDeng Oct 20, 2023
c1b4364
Merge branch 'master' into simplemath
HonestDeng Oct 20, 2023
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
8 changes: 8 additions & 0 deletions .ci/linux-x64-cpu-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,11 @@ jobs:
cmake --build . -j $(nproc)
- name: test-simplestl-simpleomp
run: cd build-simplestl-simpleomp && ctest --output-on-failure -j $(nproc)
- name: build-simplestl-simplemath
run: |
mkdir build-simplestl-simplemath && cd build-simplestl-simplemath
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/host-c.gcc.toolchain.cmake -DNCNN_STDIO=ON -DNCNN_STRING=ON -DNCNN_SIMPLESTL=ON -DNCNN_SIMPLEMATH=ON -DNCNN_BUILD_TESTS=ON -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF ..
cmake --build . -j $(nproc)
- name: test-simplestl-simplemath
run: cd build-simplestl-simplemath && ctest --output-on-failure -j $(nproc)

44 changes: 44 additions & 0 deletions .ci/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -908,3 +908,47 @@ jobs:
lcov --list lcov.info
- name: codecov
run: ./codecov -t ${{settings.CODECOV_TOKEN.access_token}} -C ${{ ci.sha }} -B ${{ ci.head_ref }} -f build/lcov.info

linux-gcc-x64-simplemath:
name: linux-gcc-x64-simplemath

runs-on:
pool-name: docker
container:
image: bkci/ci:ubuntu
steps:
- name: checkout
checkout: self
with:
strategy: FRESH_CHECKOUT
enableSubmodule: false
enableGitLfs: false

- name: install-deps
run: |
apt-get update
apt-get install -y lcov
curl https://uploader.codecov.io/verification.gpg | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://uploader.codecov.io/latest/linux/codecov
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod +x codecov

- name: build
run: |
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/host-c.gcc.toolchain.cmake -DCMAKE_BUILD_TYPE=debug -DNCNN_COVERAGE=ON -DNCNN_STDIO=ON -DNCNN_STRING=ON -DNCNN_SIMPLESTL=ON -DNCNN_SIMPLEMATH=ON -DNCNN_BUILD_TESTS=ON -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF ..
cmake --build . -j $(nproc)
- name: test
run: cd build && ctest --output-on-failure -j $(nproc)
- name: lcov-collect
run: |
cd build
lcov -d ./src -c -o lcov.info
lcov -r lcov.info '/usr/*' -o lcov.info
lcov -r lcov.info '*/build/*' -o lcov.info
lcov --list lcov.info
- name: codecov
run: ./codecov -t ${{settings.CODECOV_TOKEN.access_token}} -C ${{ ci.sha }} -B ${{ ci.head_ref }} -f build/lcov.info
11 changes: 11 additions & 0 deletions .github/workflows/linux-aarch64-cpu-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ jobs:
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
cd build-noint8
TESTS_EXECUTABLE_LOADER=qemu-aarch64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-L;/usr/aarch64-linux-gnu" ctest --output-on-failure -j 2

- name: build-simplestl-simplemath
run: |
mkdir build-simplestl-simplemath && cd build-simplestl-simplemath
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-linux-gnu-c.toolchain.cmake -DNCNN_STDIO=ON -DNCNN_STRING=ON -DNCNN_SIMPLESTL=ON -DNCNN_SIMPLEMATH=ON -DNCNN_BUILD_TESTS=ON -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF ..
cmake --build . -j 2
- name: test-simplestl-simplemath
run: |
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
cd build-simplestl-simplemath
TESTS_EXECUTABLE_LOADER=qemu-aarch64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-L;/usr/aarch64-linux-gnu" ctest --output-on-failure -j 2

linux-gcc-arm82:
runs-on: ubuntu-20.04
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ option(NCNN_INSTALL_SDK "install ncnn library and headers" ON)
option(NCNN_SIMPLEOCV "minimal opencv structure emulation" OFF)
option(NCNN_SIMPLEOMP "minimal openmp runtime emulation" OFF)
option(NCNN_SIMPLESTL "minimal cpp stl structure emulation" OFF)
option(NCNN_SIMPLEMATH "minimal cmath" OFF)
option(NCNN_THREADS "build with threads" ON)
option(NCNN_BENCHMARK "print benchmark information for every layer" OFF)
option(NCNN_C_API "build with C api" ON)
Expand Down
3 changes: 3 additions & 0 deletions benchmark/benchncnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
#include "datareader.h"
#include "net.h"
#include "gpu.h"

#ifndef NCNN_SIMPLESTL
#include <vector>
#endif

class DataReaderFromEmpty : public ncnn::DataReader
{
Expand Down
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(ncnn_SRCS
simpleocv.cpp
simpleomp.cpp
simplestl.cpp
simplemath.cpp
)

if(ANDROID)
Expand Down Expand Up @@ -207,7 +208,7 @@ if(NOT NCNN_SHARED_LIB)
set_target_properties(ncnn PROPERTIES COMPILE_FLAGS -DNCNN_STATIC_DEFINE)
endif()

if(NCNN_SIMPLESTL)
if(NCNN_SIMPLESTL AND NOT NCNN_SIMPLEMATH)
# link math lib explicitly
target_link_libraries(ncnn PUBLIC m)
endif()
Expand Down Expand Up @@ -260,7 +261,6 @@ if(NCNN_THREADS)
if(TARGET Threads::Threads)
target_link_libraries(ncnn PUBLIC Threads::Threads)
endif()

if(NCNN_SIMPLEOMP OR NCNN_SIMPLESTL)
target_link_libraries(ncnn PUBLIC pthread)
endif()
Expand Down Expand Up @@ -580,6 +580,7 @@ if(NCNN_INSTALL_SDK)
simpleocv.h
simpleomp.h
simplestl.h
simplemath.h
vulkan_header_fix.h
${CMAKE_CURRENT_BINARY_DIR}/ncnn_export.h
${CMAKE_CURRENT_BINARY_DIR}/layer_shader_type_enum.h
Expand All @@ -598,5 +599,4 @@ endif()
# add ncnn and generate-spirv to a virtual project group
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(TARGET ncnn PROPERTY FOLDER "libncnn")
set_property(TARGET ncnn-generate-spirv PROPERTY FOLDER "libncnn")

set_property(TARGET ncnn-generate-spirv PROPERTY FOLDER "libncnn")
1 change: 0 additions & 1 deletion src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#if NCNN_VULKAN

#include <math.h>
#include <string.h>
#include <vulkan/vulkan.h>

Expand Down
1 change: 0 additions & 1 deletion src/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "cpu.h"

#include <math.h>
#include <string.h>

#ifdef _MSC_VER
Expand Down
2 changes: 0 additions & 2 deletions src/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "paramdict.h"
#include "platform.h"

#include <math.h>

#if NCNN_VULKAN
#include "command.h"
#include "pipeline.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/binaryop_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "binaryop_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/binaryop_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "binaryop_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 1 addition & 1 deletion src/layer/arm/cast_arm_bf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "cpu.h"
#include "mat.h"
#include <math.h>

namespace ncnn {

#include "cast_bf16.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/gelu_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "gelu_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/gelu_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "gelu_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/gru_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "gru_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/gru_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "gru_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/innerproduct_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#define LAYER_INNERPRODUCT_ARM_H

#include "innerproduct.h"
#include <cmath>
#include <cstdlib>

namespace ncnn {

Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/interp_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "interp_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/interp_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "interp_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/lrn_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "lrn_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/lstm_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "lstm_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/lstm_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "lstm_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/mish_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "mish_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/mish_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "mish_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/quantize_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#include "quantize_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/quantize_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "quantize_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/requantize_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#include "requantize_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/rnn_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "rnn_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/rnn_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "rnn_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/sigmoid_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "sigmoid_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/sigmoid_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "sigmoid_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
1 change: 0 additions & 1 deletion src/layer/arm/softmax_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "softmax_arm.h"

#include <float.h>
#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
Expand Down
1 change: 0 additions & 1 deletion src/layer/arm/softmax_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "softmax_arm.h"

#include <float.h>
#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/swish_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "swish_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
2 changes: 0 additions & 2 deletions src/layer/arm/swish_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "swish_arm.h"

#include <math.h>

#if __ARM_NEON
#include <arm_neon.h>
#include "neon_mathfun.h"
Expand Down
Loading
Loading