Android平台下OpenCL使用setCacheFile(),模型的初始化时间未得到优化
平台(如果交叉编译请再附上交叉编译目标平台):
Platform(Include target platform as well if cross-compiling):
Android平台GPU:Arm Mali-G57
Github版本:
Github Version:
2-8-1
代码如下:
std::shared_ptr<MNN::Interpreter> mnnNet;
mnnNet = std::shared_ptr<MNN::Interpreter>(MNN::Interpreter::createFromFile(model_name.c_str()));
mnnNet->setCacheFile(".tempcache");
ScheduleConfig netConfig;
netConfig.type = MNN_FORWARD_OPENCL;
netConfig.mode = MNN_GPU_TUNING_NORMAL | MNN_GPU_MEMORY_BUFFER;
netConfig.numThread = 1;
BackendConfig backendConfig;
backendConfig.precision = BackendConfig::Precision_High;
backendConfig.power = BackendConfig::Power_Normal;
netConfig.backendConfig = &backendConfig;
MNN::Session* session = mnnNet->createSession(netConfig);
/*
推理
*/
mnnNet->updateCacheFile(session);
Log:
The device support i8sdot:1, support fp16:1, support i8mm: 0
Update cache to .tempcache, from size:329124 -> size:347844
主要是createSession的耗时过长,需要30多秒,使用setCacheFile()后耗时仍是这么多; 还有办法进一步优化createSession耗时问题吗?谢谢
setCacheFile 是加快第二次 createSession 的,前后两次 createSession 的耗时对比是多少?
setCacheFile 是加快第二次 createSession 的,前后两次 createSession 的耗时对比是多少?
都是30多秒,没有变化😂
cache 文件是否读取成功了?
cache 文件是否读取成功了?
第一次的时候会报一个err log
第二次的时候就没了
cache 文件是否读取成功了?
第二次读取的时候还是使用setCacheFile()吗?
cache 文件是否读取成功了?
我试了一下,如果是小模型(500k)的话.cache是有收益的,但是原本的模型大约8M,基本没有收益
Marking as stale. No activity in 60 days.