Skip to content

Commit

Permalink
Merge branch 'master' into doc
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian authored May 27, 2019
2 parents d401219 + 072cad0 commit 686b8ca
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 67 deletions.
15 changes: 6 additions & 9 deletions ci/build_aar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -e

nproc=$(ci/get_cores.sh)
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "The system is Mac OS X, alias sed to gsed"
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
Expand All @@ -14,22 +15,18 @@ MY_ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-$MY_ANDROID_HOME/ndk-bundle}"
JNI_BUILD_DIR=build_jni_tmp
rm -rf ${JNI_BUILD_DIR} && mkdir ${JNI_BUILD_DIR} && pushd ${JNI_BUILD_DIR}
cmake -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=${MY_ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake -DANDROID_CPP_FEATURES=exceptions -DANDROID_PLATFORM=android-21 -DANDROID_ABI=arm64-v8a -DBNN_BUILD_JNI=ON -DBNN_BUILD_TEST=OFF -DBNN_BUILD_BENCHMARK=OFF ..
cmake --build . -- "-j$(nproc)"
cmake --build . -- -j$nproc
popd
mkdir -p ci/android_aar/dabnn/src/main/jniLibs/arm64-v8a
cp ${JNI_BUILD_DIR}/dabnn/jni/libdabnn-jni.so ci/android_aar/dabnn/src/main/jniLibs/arm64-v8a/

# Increase version code and update version name

echo "Build source branch: $BUILD_SOURCEBRANCH"

if (($# == 0)); then
ret=0; tag=`git describe --exact-match --tags` || ret=$?
if [ $ret != 0 ]; then
echo "HEAD is not tagged, skip deploy aar"
exit 0
fi
# tag is expected to be something like "v0.2", so remove the leading "v"
if [[ `echo $tag | cut -c -1` == "v" ]]; then
ver=`echo $tag | cut -c 2-10`
if [[ $BUILD_SOURCEBRANCH == refs/tags/v* ]]; then
ver=`echo $BUILD_SOURCEBRANCH | cut -c 12-`
else
echo "HEAD is not tagged as a version, skip deploy aar"
exit 0
Expand Down
3 changes: 2 additions & 1 deletion ci/build_dabnn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
set -e

echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'ndk-bundle'
nproc=$(ci/get_cores.sh)

mkdir build_dabnn && cd build_dabnn
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -- -j$(nproc)
cmake --build . -- -j$nproc
cd -
4 changes: 3 additions & 1 deletion ci/build_onnx2bnn.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#! /usr/bin/env bash
set -e

nproc=$(ci/get_cores.sh)

mkdir build_onnx2bnn && cd build_onnx2bnn
cmake ..
cmake --build . -- -j$(nproc)
cmake --build . -- -j$nproc
cd -
23 changes: 21 additions & 2 deletions ci/dabnn_build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
trigger:
branches:
include:
- refs/heads/*
- refs/tags/*
- master
tags:
include:
- v*
paths:
include:
- '*'
exclude:
- README.md
- docs/*
pr:
branches:
include:
- '*'
paths:
include:
- '*'
exclude:
- README.md
- docs/*

pool:
vmImage: 'macOS-10.14'
steps:
Expand Down
5 changes: 5 additions & 0 deletions ci/get_cores.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [[ "$OSTYPE" == "drawin*" ]]; then
echo $(sysctl -n hw.physicalcpu)
else
echo $(nproc)
fi
101 changes: 49 additions & 52 deletions ci/onnx2bnn_build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
trigger:
branches:
include:
- refs/heads/*
- refs/tags/*
- master
tags:
include:
- v*
paths:
include:
- '*'
exclude:
- README.md
- docs/*
# not trigger onnx2bnn build when only dabnn is edited
- dabnn/*
pr:
branches:
include:
- '*'
paths:
include:
- '*'
exclude:
- README.md
- docs/*
# not trigger onnx2bnn build when only dabnn is edited
- dabnn/*

jobs:
- job: Linux_AppImage
- job: LinuxAppImage
pool:
vmImage: 'ubuntu-16.04'
steps:
Expand All @@ -20,63 +43,37 @@ jobs:
inputs:
contents: 'onnx2bnn.AppImage'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: onnx2bnn AppImage
- task: GitHubRelease@0
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
inputs:
gitHubConnection: 'dabnn release'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tag: '$(Build.SourceBranchName)'
target: '$(Build.SourceVersion)'
assets: '$(Build.ArtifactStagingDirectory)/*'
assetUploadMode: 'replace'
- job: Windows_Python_Package
- template: template_onnx2bnn_publish_artifacts.yml
- template: template_onnx2bnn_github_release.yml
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- checkout: self
submodules: true
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml
- task: UsePythonVersion@0
inputs:
versionSpec: '3.5'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml
- template: template_onnx2bnn_build_python_all_version.yml
- task: CopyFiles@2
inputs:
sourceFolder: '.setuptools-cmake-build\tools\onnx2bnn\Release\'
contents: 'onnx2bnn.exe'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: GitHubRelease@0
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
- template: template_onnx2bnn_publish_artifacts.yml
- template: template_onnx2bnn_github_release.yml
- template: template_onnx2bnn_upload_to_pypi.yml
- job: macOS
pool:
vmImage: 'macOS-10.14'
steps:
- checkout: self
submodules: true
- template: template_onnx2bnn_build_python_all_version.yml
- script: 'cp .setuptools-cmake-build/tools/onnx2bnn/onnx2bnn .setuptools-cmake-build/tools/onnx2bnn/onnx2bnn-macos'
displayName: 'Rename onnx2bnn'
- task: CopyFiles@2
inputs:
gitHubConnection: 'dabnn release'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tag: '$(Build.SourceBranchName)'
target: '$(Build.SourceVersion)'
assets: '$(Build.ArtifactStagingDirectory)/*'
assetUploadMode: 'replace'
- script: python -m twine upload dist/* --verbose
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
displayName: Upload wheel to PyPI
workingDirectory: tools/onnx2bnn/python/
env:
TWINE_USERNAME: $(twineUsername)
TWINE_PASSWORD: $(twinePassword)
sourceFolder: '.setuptools-cmake-build/tools/onnx2bnn'
contents: 'onnx2bnn-macos'
targetFolder: $(Build.ArtifactStagingDirectory)
- template: template_onnx2bnn_publish_artifacts.yml
- template: template_onnx2bnn_github_release.yml
- template: template_onnx2bnn_upload_to_pypi.yml
2 changes: 1 addition & 1 deletion ci/template_onnx2bnn_build_python.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
steps:
- script: python -m pip install --user --upgrade setuptools wheel twine
displayName: Install setuptools, wheel and twine
- script: python setup.py sdist bdist_wheel
- script: python setup.py bdist_wheel
workingDirectory: tools/onnx2bnn/python/
displayName: Build onnx2bnn python package
20 changes: 20 additions & 0 deletions ci/template_onnx2bnn_build_python_all_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml
- task: UsePythonVersion@0
inputs:
versionSpec: '3.5'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml

12 changes: 12 additions & 0 deletions ci/template_onnx2bnn_github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
steps:
- task: GitHubRelease@0
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
inputs:
gitHubConnection: 'dabnn release'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tag: '$(Build.SourceBranchName)'
target: '$(Build.SourceVersion)'
assets: '$(Build.ArtifactStagingDirectory)/*'
assetUploadMode: 'replace'

6 changes: 6 additions & 0 deletions ci/template_onnx2bnn_publish_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: onnx2bnn

9 changes: 9 additions & 0 deletions ci/template_onnx2bnn_upload_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- script: python -m twine upload dist/* --verbose
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
displayName: Upload wheel to PyPI
workingDirectory: tools/onnx2bnn/python/
env:
TWINE_USERNAME: $(twineUsername)
TWINE_PASSWORD: $(twinePassword)

2 changes: 1 addition & 1 deletion dabnn/bconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ inline void bnn::bconv_3x3(const Mat &bottom_blob, const Mat &weight,
bconv_3x3_64(bottom_blob, weight, top_blob, stride);
} else if (bottom_blob.c == 2 && top_blob.c == 128) {
top_blob.fill<float>(0.f);
if (stride == 1) {
if (stride == 1 && top_blob.w % 2 == 0) {
bconv_3x3_128_internal_s1(
static_cast<uint64_t *>(bottom_blob.data), bottom_blob.w,
static_cast<uint64_t *>(weight.data),
Expand Down

0 comments on commit 686b8ca

Please sign in to comment.