Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android平台下OpenCL使用setCacheFile(),模型的初始化时间未得到优化 #2852

Open
CloudGuardian opened this issue Apr 29, 2024 · 5 comments
Labels
question Further information is requested

Comments

@CloudGuardian
Copy link

平台(如果交叉编译请再附上交叉编译目标平台):

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耗时问题吗?谢谢

@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 29, 2024

setCacheFile 是加快第二次 createSession 的,前后两次 createSession 的耗时对比是多少?

@CloudGuardian
Copy link
Author

setCacheFile 是加快第二次 createSession 的,前后两次 createSession 的耗时对比是多少?

都是30多秒,没有变化😂

@jxt1234
Copy link
Collaborator

jxt1234 commented May 8, 2024

cache 文件是否读取成功了?

@jxt1234 jxt1234 added the question Further information is requested label May 8, 2024
@CloudGuardian
Copy link
Author

cache 文件是否读取成功了?

第一次的时候会报一个err log
image

第二次的时候就没了
image

@CloudGuardian
Copy link
Author

cache 文件是否读取成功了?

第二次读取的时候还是使用setCacheFile()吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants