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

Extractor::extract中调用的Net::forward_layer递归,易导致栈空间耗尽 #594

Closed
lvyes1988 opened this issue Sep 28, 2018 · 2 comments

Comments

@lvyes1988
Copy link

lvyes1988 commented Sep 28, 2018

No description provided.

@fanxingzju
Copy link

我也觉得作者用递归的方式实现整个网络的forward不合理,除了栈空间,也会给调试带来很大麻烦。

作者这么做的目的,大抵是不执行网络中无用的分支吧。

https://github.com/Tencent/ncnn/wiki/%E6%9F%90%E4%BA%9B%E5%B0%8F%E7%A7%98%E5%AF%86#%E5%8F%AA%E8%BF%90%E7%AE%97%E4%B8%80%E9%83%A8%E5%88%86%E5%B9%B6%E4%BF%9D%E7%95%99%E4%B8%AD%E9%97%B4%E7%BB%93%E6%9E%9C

先分析net中必要的layer,然后按照最朴素的方式从前到后依次执行这些layer的forward,速度并不会比当前的实现慢,而且这种方式对开发者更加友好!!

@ganchunsheng
Copy link

我也分析到这个问题了,其实从原理上来说整个网络的forward确实没必要使用递归的方式,效率其实并不高,再者现在网络动辄上百层,太浪费栈空间了,期待大佬的解答。

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

No branches or pull requests

3 participants