Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
8e4c3c53
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8e4c3c53
编写于
9月 14, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(imperative/opr): fix extern c opr mace example md
GitOrigin-RevId: b83fa4568b4659e539c827378f9a02e5161ea1af
上级
27f2ecc4
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
20 deletion
+30
-20
sdk/c-opr-loaders/mace/Makefile
sdk/c-opr-loaders/mace/Makefile
+4
-8
sdk/c-opr-loaders/mace/README.md
sdk/c-opr-loaders/mace/README.md
+26
-12
未找到文件。
sdk/c-opr-loaders/mace/Makefile
浏览文件 @
8e4c3c53
...
...
@@ -15,7 +15,8 @@ endif
TARGET
:=
libmace_loader.so
all
:
$(TARGET)
CXX
=
aarch64-linux-android-g++
# can be find at NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/
CXX
=
aarch64-linux-android21-clang++
CXXFLAGS
=
-std
=
c++14
-I
$(SDKPATH)
/include
\
-Dmgb_mace_loader_init
=
mgb_c_opr_init
...
...
@@ -27,12 +28,7 @@ else
CXXFLAGS
+=
-O2
endif
LDFLAGS
=
-L
$(SDKPATH)
/lib
\
-lmace_static
-lcore
-lgenerated_version
\
-lport_android
-lport_linux_base
-lport_posix
-lport_base
\
-lproto
-lutils
-lgenerated_opencl_kernel
\
-lops
-lcore
-lprotobuf-lite
-llog
\
-lpthread
-l
:rpcmem.a
LDFLAGS
=
-L
$(SDKPATH)
/lib
-lmace
-llog
LDLIBS
=
-shared
-fPIC
...
...
sdk/c-opr-loaders/mace/README.md
浏览文件 @
8e4c3c53
# Extern-C-Opr with MACE
### Build MegEngine `load_and_run` for arm64-v8a
NOTICE: build depends on
[
NDK
](
https://developer.android.com/ndk/downloads
)
after download, please config env by:
```
bash
export
NDK_ROOT
=
path/to/ndk
export
ANDROID_NDK_HOME
=
${
NDK_ROOT
}
export
PATH
=
${
NDK_ROOT
}
/toolchains/llvm/prebuilt/linux-x86_64/bin/:
$PATH
```
```
bash
cd
$MEGENGINE_HOME
git checkout v1.0.0
(
we only
test
v1.0.0 version
)
./scripts/cmake-build/cross_build_android_arm_inference.sh
-a
arm64-v8a
-r
```
After successfully built, load_and_run should be in
`$MEGENGINE_HOME/build_dir/android/arm64-v8a/Release/install/bin`
After successfully built:
*
load_and_run should be in
`$MEGENGINE_HOME/build_dir/android/arm64-v8a/Release/install/bin`
*
libmegengine.so should be in
`$MEGENGINE_HOME/build_dir/android/arm64-v8a/Release/install/lib`
### Build MACE libraries for arm64-v8a with GPU runtime
```
bash
cd
$MACE_HOME
RUNTIME
=
GPU bash tools/cmake/cmake-build-arm64-v8a.sh
cp
-r
$MACE_HOME
/build/cmake-build/arm64-v8a/install
$MEGENGINE_HOME
/sdk/c-opr-loaders/mace/arm64-v8a
export
SDKPATH
=
${
MACE_HOME
}
/build/cmake-build/arm64-v8a/install
```
After successfully libmace.so should be in
`$MACE_HOME/build/cmake-build/arm64-v8a/install/lib/libmace.so`
### Build MACE loader for MegEngine
```
SDK_PATH=/path/to/mace-sdk make
```
If
`SDK_PATH`
is not set, by default it's
`./arm64-v8a`
If
`SDKPATH`
is not set, by default it's
`./arm64-v8a`
You can run with debug mode(by adding
`DEBUG=1`
to make command), which will show more running information
### Prepare a MACE model(for example: resnet_50), wrap it with MegEngine extern c opr
```
python3 dump_model.py
path/to/resnet_50.pb path/to/resnet_50.data path/to/resnet_50.mdl
path/to/resnet_50.yml
python3 dump_model.py
--input path/to/resnet_50.pb --param path/to/resnet_50.data --output resnet_50.mdl --config
path/to/resnet_50.yml
```
`*.pb`
file denotes the model structure,
`*.data`
denotes the model parameters
...
...
@@ -40,14 +46,22 @@ Check [here](https://github.com/XiaoMi/mace-models) to learn how to write yml fi
### Run with load-and-run
First of all, send all files to the executed device:
First of all, send all files to the executed device
(for example: /data/local/tmp/test/)
:
-
load_and_run
-
resnet_50.mdl
-
libmace_loader.so
-
libmegengine.so
-
libmace.so
As mace build with
`c++_shared`
by default, but old AOSP device do not have
`libc++_shared.so`
by default, if you use this class devices
also need send it to devices, which always can be found at
`${NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so`
```
MGB_MACE_RUNTIME=GPU MGB_MACE_OPENCL_CACHE_PATH=/path/to/opencl MGB_MACE_LOADER_FORMAT=NCHW /path/to/load_and_run /path/to/resnet_50.mdl --c-opr-lib /path/to/libmace_loader.so
login to device
cd /path/to/ (for example: /data/local/tmp/test/)
MGB_MACE_RUNTIME=GPU MGB_MACE_OPENCL_CACHE_PATH=./ MGB_MACE_LOADER_FORMAT=NCHW LD_LIBRARY_PATH=. ./load_and_run resnet_50.mdl --c-opr-lib libmace_loader.so --input input-bs1.npy
```
RUNTIME candidates:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录