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

Expose a interface to create all variables and enable the test of not creating variables every time. #9301

Merged
merged 8 commits into from
Apr 9, 2018

Conversation

Xreki
Copy link
Contributor

@Xreki Xreki commented Mar 21, 2018

Fix #9653

Sometimes users do not want to create and destroy variables in every run.

Here is the performance comparision for test_inference_image_classificaion_resnet.
GPU: Tesla K40m, CUDA 8.0, CUDNN v7.

  1 2 4 8 16 32 64 128 256
2018/03/14 866.048 852.3 858.021 987.86 1115.01 1556.01 2232.87 4375.75 8443.42
2018/03/31, not create variables in every run 775.283 758.788 777.694 906.402 1045.67 1489.28 2155.31 4280.39 8330.89
speed up 1.117073 1.123239 1.103289 1.08987 1.066312 1.044807 1.035986 1.022278 1.013508

@Xreki Xreki added the 预测 原名Inference,包含Capi预测问题等 label Mar 21, 2018
@Xreki Xreki requested a review from qingqing01 March 22, 2018 11:37
@Xreki Xreki added this to Basic Usage (DOING) in Inference Framework Apr 3, 2018
@Xreki Xreki moved this from Basic Usage (DOING) to Performance Tuning (DOING) in Inference Framework Apr 3, 2018
@Xreki Xreki changed the title Enable the test of not creating variables every time. Expose a interface to create all variables and enable the test of not creating variables every time. Apr 4, 2018
@Xreki Xreki requested review from Superjomn and luotao1 April 4, 2018 09:37
@@ -169,8 +169,14 @@ void TestInference(const std::string& dirname,

// 6. Run the inference program
{
const bool create_vars = false;
if (!create_vars) {
executor.CreateVariables(*inference_program, scope, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some trivial issues, !create_vars -> executor.CreateVariables( seems a little wried.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_vars意思是在executor.Run函数里面是否创建Variables,默认值为true,意思是每次Run都会create和destroy所有的Variables。如果executor.Run时设置参数create_varsfalse,那么用户需要提前手动CreateVaribales,不然就会出现变量不存在的错误。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能否增加一个单测说明create_varsfalse时,用户如何提前手动CreateVaribales

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done。在image classification里面加了create_vars为false的单测。

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luotao1 luotao1 merged commit 46d6f4c into PaddlePaddle:develop Apr 9, 2018
@Xreki Xreki moved this from Performance Tuning (DOING) to Performance Tuning (DONE) in Inference Framework Apr 12, 2018
@Xreki Xreki moved this from Performance Tuning (DONE) to Basic Usage (DONE) in Inference Framework Apr 12, 2018
@Xreki Xreki deleted the core_inference_fix_run branch November 14, 2018 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
预测 原名Inference,包含Capi预测问题等
Projects
No open projects
Inference Framework
Basic Usage (DONE)
Development

Successfully merging this pull request may close these issues.

None yet

3 participants