class YourExecutor : public BaseExecutor {
public:
YourExecutor() :
BaseExecutor(executor_type, device_type, model_file, weight_file) {}
// Init method should invoke the initializing process for your executor
// (e.g. Mace needs to compile OpenCL kernel once per target). It will be
// called only once when creating executor engine.
virtual Status Init(int num_threads);
// Load model and prepare to run. It will be called only once before
// benchmarking the model.
virtual Status Prepare();
// Run the model. It will be called more than once.
virtual Status Run(const std::map<std::string, BaseTensor> &inputs,
std::map<std::string, BaseTensor> *outputs);
// Unload model and free the memory after benchmarking. It will be called
// only once.
virtual void Finish();
};
English
近年来,智能手机以及IoT设备上的离线深度学习应用变得越来越普遍。在设备上部署深度学习模型给开发者带来挑战,对于手机应用开发者,需要在众多深度学习框架中选择一款合适的框架,对于IoT硬件开发者而言,则还需要从不同的芯片方案中做出选择。同时,除了软硬件的选择之外,开发者还需要从模型量化压缩与模型精度角度进行权衡,最终将模型部署到设备上。对比测试这些不同的芯片,框架以及量化方案,并从中选择最佳组合是一个非常繁琐耗时的工作。
MobileAIBench 是一个端到端的测试工具,用于评测相同的模型在不同硬件和软件框架上运行的性能和精度表现,对开发者的技术选型给出客观参考数据。
每日评测结果
请查看最新的CI Pipeline页面中的benchmark步骤的运行结果,由于设备原因,运行结果不会覆盖所有的设备和框架。
FAQ
参考英文文档。
准备环境
MobileAIBench 现在支持多种框架 (MACE, SNPE, ncnn, TensorFlow Lite 以及 HIAI),需要安装以下的依赖:
备注1: 鉴于SNPE的许可不允许第三方再分发, 目前Bazel WORKSPACE配置中的链接只能在CI Server中访问。 如果想测评SNPE(通过
--executors指定all或者显式指定了SNPE) ,需从官方地址 下载并解压,复制libgnustl_shared.so,然后修改WORKSPACE文件如下。备注2: 鉴于HIAI的许可不允许第三方再分发, 目前Bazel WORKSPACE配置中的链接只能在CI Server中访问。 如果想测评HIAI(通过
--executors指定all或者显式指定了HIAI) ,需从官方地址 登录账号下载HiAI DDK.zip并解压,获得其中的HiAI_DDK_100.200.010.011.zip文件并解压,然后修改WORKSPACE文件如下。数据结构
如何使用
测试所有模型在所有框架上的性能
运行时间可能比较长,如果只想测试指定模型和框架,可以添加如下选项。当前只有MACE支持精度测试。
配置连接方式为ssh的设备
对abi为aarch64、armhf的ARM-Linux设备,支持以ssh方式进行连接,需添加yaml配置信息。 在
generic-mobile-devices/devices_for_ai_bench.yml配置ssh设备,下面是一个例子:在已有框架中添加新模型评测
在
aibench/proto/base.proto添加新模型名。在
aibench/proto/model.meta配置模型信息。在
aibench/proto/benchmark.meta配置benchmark信息。运行测试 性能benchmark:
精度benchmark。当前仅支持以ImageNet图像为输入测试MACE精度。
查看结果
在浏览器中打开相应链接查看。
加入新的 AI 框架
定义
executor并实现其接口:在
aibench/benchmark/benchmark_main.cc中包含头文件:添加依赖
third_party/your_executor,aibench/benchmark/BUILD和WORKSPACE。测试模型
在已有框架中添加新模型评测。
License
Apache License 2.0。