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

can extract be reused? #243

Closed
cscyangj opened this issue Jan 19, 2018 · 5 comments
Closed

can extract be reused? #243

cscyangj opened this issue Jan 19, 2018 · 5 comments

Comments

@cscyangj
Copy link

<1> below code get correct result;
for(i = 0 ; i < I; i++)
{
ncnn::Extractor Net_ex_ = Net_.create_extractor();
Net_ex_.set_light_mode(true);

Net_ex_.input("data", input);
Net_ex_.extract("conv3",output);

}

<2> after i change the code below, can not get correct result, so can bet extract be re-used?In my opinion, net should be independent to data input to net.

ncnn::Extractor Net_ex_ = Net_.create_extractor();
Net_ex_.set_light_mode(true);
for(i = 0 ; i < I; i++)
{
Net_ex_.input("data", input);
Net_ex_.extract("conv3",output);
}

@nihui
Copy link
Member

nihui commented Jan 19, 2018

Net can be reused, as you've shown in <1>
Extractor is the context of each inference, which should not be reused.

@nihui nihui closed this as completed Jan 19, 2018
@cscyangj
Copy link
Author

@nihui ,thanks.
in such case, if Extractor can be re-used, may get better performance.

@nihui
Copy link
Member

nihui commented Jan 19, 2018

Creating an Extractor is nearly instantly like allocating an array.
you will get little performance if reused, compared with the inference itself.

@GarrickLin
Copy link

In mtcnn, there are a few pyramids, can I create a number of pnets to avoid reallocate memory again and again ?

@Paseam
Copy link

Paseam commented Oct 12, 2018

Creating an Extractor is nearly instantly like allocating an array.
you will get little performance if reused, compared with the inference itself.

but i think every time extractor will allocate new memory for intermediate layer output and release it later, this will be bad results for meachine

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

4 participants