移动端是Caffe2是发力的方向之一。Caffe2支持通过OpenGL调用移动GPU。然而移动端GPU却无法保持桌面上对CPU的优势,多CPU核心配弱GPU更是安卓界的一大特色。即使强大如iPhone,对于iPhone 6s以下的设备,NNPACK加速的CPU实现也比Apple的MPSCNNConvolution性能好。
Android
Android支持设备列表:
#if CAFFE2_ANDROID
// whitelist of supported GPUs
bool isSupportedRenderer() {
static std::unordered_set<std::string> supported_renderers = {
"Adreno (TM) 540",
"Adreno (TM) 530",
"Adreno (TM) 510",
"Adreno (TM) 430",
"Adreno (TM) 418",
"Mali-G71",
"Mali-T880",
"NVIDIA Tegra"};
std::string rendererStr((const char*)glGetString(GL_RENDERER));
LOG(INFO) << "GL_RENDERER: " << rendererStr;
int start = rendererStr.find_first_not_of(" ");
int end = rendererStr.find_last_not_of(" ");
rendererStr = rendererStr.substr(start, end - start + 1);
return supported_renderers.count(rendererStr) > 0;
}
#endif
AndroidGLContext在构造函数中进行检查
iOS
对于iOS,只支持iPhone 6以上
bool isSupportedDevice() {
#if CAFFE2_IOS
return iPhoneVersion() >= 7; // iPhone 6 and up
#elif CAFFE2_ANDROID
return isSupportedRenderer();
#else
return false;
#endif
}