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

IOS Metal 推理 createSession 卡在 MetalRaster::onResize #2814

Closed
roachsinai opened this issue Apr 7, 2024 · 7 comments
Closed

IOS Metal 推理 createSession 卡在 MetalRaster::onResize #2814

roachsinai opened this issue Apr 7, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@roachsinai
Copy link
Contributor

roachsinai commented Apr 7, 2024

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

MacOS

Github版本:

2.8.2

编译方式:

直接编译的 project/ios/MNN 和 project/ios/demo 工程,然后在 demo 中添加的自己测试的模型

出现的问题

在使用 METAL 推理时,createSession 卡在一个 MatMul 算子的 onResize 处。

这个 MatMul 算子的两个输入的维度分别是 1x64x104x80x2x21x64x104x80x2x1

调试到 MetalRaster::onResize 发现会有一个特别大的循环:

for (int i=0; i< des->regions.size(); ++i) {

这里 des->regions.size() 的值为 532480,而且每一次循环都非常耗时。

请教一下,这个较大的耗时,是因为 MatMul 的输入导致的么?

@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 8, 2024

你的模型可以发来看下?这个问题可能是前面有个 tile 算子几何计算拆解不合理

@jxt1234 jxt1234 added the bug Something isn't working label Apr 8, 2024
@roachsinai
Copy link
Contributor Author

好的,我先试试排查下模型的问题。

@roachsinai
Copy link
Contributor Author

打开 MNN_PIPELINE_DEBUG=1 之后运行最后的回显如下:

160.446609, before Resize: /adaAT/Neg_output_0 - 0
2024-04-10 19:37:53.645390+0800 demo[22262:5310953] before Resize 2, calling: /adaAT/Neg_output_0 - 0
before Resize 2, calling: /adaAT/Neg_output_0 - 0 
2024-04-10 19:37:53.645542+0800 demo[22262:5310953] ===== 156
===== 157 
2024-04-10 19:37:53.645799+0800 demo[22262:5310953] 160.446609, before Resize: /adaAT/Mul_2_output_0 - 0
160.446609, before Resize: /adaAT/Mul_2_output_0 - 0
2024-04-10 19:37:53.646053+0800 demo[22262:5310953] before Resize 2, calling: /adaAT/Mul_2_output_0_raster_0 - 0
before Resize 2, calling: /adaAT/Mul_2_output_0_raster_0 - 0 
2024-04-10 19:37:53.646227+0800 demo[22262:5310953] ===== 158
===== 159 
2024-04-10 19:37:53.646501+0800 demo[22262:5310953] 160.446609, before Resize: /adaAT/Mul_2_output_0 - 1
160.446609, before Resize: /adaAT/Mul_2_output_0 - 1
2024-04-10 19:37:53.729138+0800 demo[22262:5310953] before Resize 2, calling: /adaAT/Mul_2_output_0_raster_1 - 1
before Resize 2, calling: /adaAT/Mul_2_output_0_raster_1 - 1 
2024-04-10 19:37:53.729273+0800 demo[22262:5310953] ===== 160
===== 161 

===== [num] 是我自己打印的 counter。

@roachsinai
Copy link
Contributor Author

模型转换命令:~/aarch64/MNN/build/MNNConvert -f ONNX --modelFile ./small_pruned_random.onnx --MNNModel ./small_pruned_random.mnn --bizCode 0000

small_pruned_random.zip

@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 17, 2024

已经有解决方案,等待验证与合并中

@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 19, 2024

2.8.4 修正

@jxt1234 jxt1234 closed this as completed Apr 19, 2024
@roachsinai
Copy link
Contributor Author

感谢!但是 #2839 这个 pr 包含的东西太大了。大佬,有时间的时候,麻烦给个链接啥的看看哪些文件改动修复的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants