Skip to content

Commit 6a9dff6

Browse files
committed
init
0 parents  commit 6a9dff6

File tree

426 files changed

+136893
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

426 files changed

+136893
-0
lines changed

.clang-format

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 4

.daq_pm/configs/arm64-v8a

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
5+
binary ~/adb_push_and_run.sh tests/fconv_test

.daq_pm/configs/arm64-v8a-wo-test

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_arm64_no_test
4+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release-DBUILD_TEST=OFF -DBUILD_BENCHMARK=OFF
5+
binary ~/adb_push_and_run.sh binaries/run /sdcard/model.daq

.daq_pm/configs/bconv_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
target bconv_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
6+
binary ~/adb_push_and_run.sh tests/bconv_test

.daq_pm/configs/benchmark

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_release
4+
build_type Release
5+
target dabnn_benchmark
6+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
7+
binary ~/adb_push_and_run.sh benchmark/bnn_benchmark

.daq_pm/configs/benchmark_macro

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_benchmark_macro
4+
build_type Release
5+
target run
6+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DBNN_NET_BENCHMARK=ON
7+
binary ~/adb_push_and_run.sh binaries/run /data/local/tmp/model_imagenet.daq 188 && adb pull /data/local/tmp/mat.txt

.daq_pm/configs/bgemm_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_bgemm_test
4+
target bgemm_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
6+
binary ~/adb_push_and_run.sh tests/bgemm_test

.daq_pm/configs/bitpack_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
target bitpack_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
6+
binary ~/adb_push_and_run.sh tests/bitpack_test

.daq_pm/configs/converter

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_x86
4+
cmake_options -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
5+
binary tools/onnx2bnn/onnx2bnn ~/repos/bnn.pytorch/model_imagenet_24g2.onnx br24g2.daq && adb push br24g2.daq /data/local/tmp

.daq_pm/configs/fconv_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
target fconv_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
6+
binary ~/adb_push_and_run.sh tests/fconv_test

.daq_pm/configs/gemm_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
target gemm_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
6+
binary ~/adb_push_and_run.sh tests/gemm_test

.daq_pm/configs/im2col_test

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
5+
binary ~/adb_push_and_run.sh tests/im2col_test

.daq_pm/configs/jni

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_jni
4+
cmake_options -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DCMAKE_ANDROID_STL_TYPE=c++_static -DANDROID_PLATFORM=android-28 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBNN_BUILD_TEST=OFF -DBNN_BUILD_BENCHMARK=OFF -DCMAKE_BUILD_TYPE=Release -DBNN_BUILD_JNI=ON

.daq_pm/configs/mat_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
target mat_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
6+
binary ~/adb_push_and_run.sh tests/mat_test

.daq_pm/configs/net_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_net_test
4+
target net_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
6+
binary ~/adb_push_and_run.sh tests/net_test

.daq_pm/configs/pad_test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
target pad_test
5+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
6+
binary ~/adb_push_and_run.sh tests/pad_test

.daq_pm/configs/pool_test

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build
4+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
5+
binary ~/adb_push_and_run.sh tests/pool_test

.daq_pm/configs/raw_benchmark

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_release
4+
build_type Release
5+
target raw_benchmark
6+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release
7+
binary ~/adb_push_and_run.sh benchmark/raw_benchmark 1

.daq_pm/configs/run_net

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name binary-nn
2+
type cpp
3+
build_dir build_arm64_no_test
4+
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DBNN_BUILD_TEST=OFF -DBNN_BUILD_BENCHMARK=OFF
5+
binary ~/adb_push_and_run.sh binaries/run /data/local/tmp/br24g2.daq 242 && adb pull /data/local/tmp/mat.txt

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake-build-*/
2+
.idea/
3+
*.swp
4+
*.swo
5+
build/
6+
.ccls-cache/
7+
compile_commands.json
8+
build-*/
9+
build_*/
10+
.daq_pm/status/

.gitmodules

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "third_party/benchmark"]
2+
path = third_party/benchmark
3+
url = https://github.com/google/benchmark
4+
[submodule "third_party/onnx"]
5+
path = third_party/onnx
6+
url = https://github.com/onnx/onnx
7+
[submodule "third_party/glog"]
8+
path = third_party/glog
9+
url = https://github.com/google/glog
10+
[submodule "third_party/googletest"]
11+
path = third_party/googletest
12+
url = https://github.com/daquexian/googletest

CMakeLists.txt

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright 2019 JD.com Inc. JD AI
2+
3+
cmake_minimum_required(VERSION 3.12)
4+
project(dabnn CXX)
5+
6+
set(CMAKE_CXX_STANDARD 17)
7+
8+
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
9+
message("No build type, set to Release")
10+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
11+
endif()
12+
message("Build type: ${CMAKE_BUILD_TYPE}")
13+
14+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
15+
16+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
17+
18+
option(BNN_BUILD_JNI "Build jni" OFF)
19+
option(BNN_BUILD_TEST "Build test" ON)
20+
option(BNN_BUILD_BENCHMARK "Build benchmark" ON)
21+
option(BNN_NET_BENCHMARK "define BNN_BENCHMARK" OFF)
22+
option(BNN_CHECK_CONSISTENCY "Make some layers non inplace to check results" OFF)
23+
24+
if (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
25+
set(BNN_BUILD_ANDROID ON)
26+
else()
27+
set(BNN_BUILD_ANDROID OFF)
28+
endif()
29+
30+
include(cmake/common.cmake)
31+
include(cmake/system.cmake)
32+
33+
include(cmake/glog.cmake)
34+
configure_glog()
35+
36+
add_compile_options("-DEIGEN_MPL2_ONLY")
37+
if (${BNN_NET_BENCHMARK})
38+
add_compile_options("-DBNN_BENCHMARK")
39+
endif()
40+
41+
if (${BNN_BUILD_ANDROID})
42+
if (${BNN_BUILD_TEST})
43+
include(cmake/gtest.cmake)
44+
configure_gtest()
45+
add_subdirectory(third_party/googletest)
46+
endif()
47+
48+
add_subdirectory(dabnn)
49+
50+
add_subdirectory(binaries)
51+
if (BNN_BUILD_TEST)
52+
add_subdirectory(tests)
53+
endif()
54+
if (BNN_BUILD_BENCHMARK)
55+
include(cmake/benchmark.cmake)
56+
configure_benchmark()
57+
add_subdirectory(benchmark)
58+
endif()
59+
60+
else()
61+
include(cmake/onnx.cmake)
62+
configure_onnx()
63+
add_subdirectory(tools)
64+
endif()

Eigen/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include(RegexUtils)
2+
test_escape_string_as_regex()
3+
4+
file(GLOB Eigen_directory_files "*")
5+
6+
escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
7+
8+
foreach(f ${Eigen_directory_files})
9+
if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src")
10+
list(APPEND Eigen_directory_files_to_install ${f})
11+
endif()
12+
endforeach(f ${Eigen_directory_files})
13+
14+
install(FILES
15+
${Eigen_directory_files_to_install}
16+
DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel
17+
)
18+
19+
install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h")

Eigen/Cholesky

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// This file is part of Eigen, a lightweight C++ template library
2+
// for linear algebra.
3+
//
4+
// This Source Code Form is subject to the terms of the Mozilla
5+
// Public License v. 2.0. If a copy of the MPL was not distributed
6+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
8+
#ifndef EIGEN_CHOLESKY_MODULE_H
9+
#define EIGEN_CHOLESKY_MODULE_H
10+
11+
#include "Core"
12+
#include "Jacobi"
13+
14+
#include "src/Core/util/DisableStupidWarnings.h"
15+
16+
/** \defgroup Cholesky_Module Cholesky module
17+
*
18+
*
19+
*
20+
* This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.
21+
* Those decompositions are also accessible via the following methods:
22+
* - MatrixBase::llt()
23+
* - MatrixBase::ldlt()
24+
* - SelfAdjointView::llt()
25+
* - SelfAdjointView::ldlt()
26+
*
27+
* \code
28+
* #include <Eigen/Cholesky>
29+
* \endcode
30+
*/
31+
32+
#include "src/Cholesky/LLT.h"
33+
#include "src/Cholesky/LDLT.h"
34+
#ifdef EIGEN_USE_LAPACKE
35+
#ifdef EIGEN_USE_MKL
36+
#include "mkl_lapacke.h"
37+
#else
38+
#include "src/misc/lapacke.h"
39+
#endif
40+
#include "src/Cholesky/LLT_LAPACKE.h"
41+
#endif
42+
43+
#include "src/Core/util/ReenableStupidWarnings.h"
44+
45+
#endif // EIGEN_CHOLESKY_MODULE_H
46+
/* vim: set filetype=cpp et sw=2 ts=2 ai: */

Eigen/CholmodSupport

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This file is part of Eigen, a lightweight C++ template library
2+
// for linear algebra.
3+
//
4+
// This Source Code Form is subject to the terms of the Mozilla
5+
// Public License v. 2.0. If a copy of the MPL was not distributed
6+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
8+
#ifndef EIGEN_CHOLMODSUPPORT_MODULE_H
9+
#define EIGEN_CHOLMODSUPPORT_MODULE_H
10+
11+
#include "SparseCore"
12+
13+
#include "src/Core/util/DisableStupidWarnings.h"
14+
15+
extern "C" {
16+
#include <cholmod.h>
17+
}
18+
19+
/** \ingroup Support_modules
20+
* \defgroup CholmodSupport_Module CholmodSupport module
21+
*
22+
* This module provides an interface to the Cholmod library which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
23+
* It provides the two following main factorization classes:
24+
* - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization.
25+
* - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial).
26+
*
27+
* For the sake of completeness, this module also propose the two following classes:
28+
* - class CholmodSimplicialLLT
29+
* - class CholmodSimplicialLDLT
30+
* Note that these classes does not bring any particular advantage compared to the built-in
31+
* SimplicialLLT and SimplicialLDLT factorization classes.
32+
*
33+
* \code
34+
* #include <Eigen/CholmodSupport>
35+
* \endcode
36+
*
37+
* In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies.
38+
* The dependencies depend on how cholmod has been compiled.
39+
* For a cmake based project, you can use our FindCholmod.cmake module to help you in this task.
40+
*
41+
*/
42+
43+
#include "src/CholmodSupport/CholmodSupport.h"
44+
45+
#include "src/Core/util/ReenableStupidWarnings.h"
46+
47+
#endif // EIGEN_CHOLMODSUPPORT_MODULE_H
48+

0 commit comments

Comments
 (0)