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

Make get_inference_program support for Evaluator. #7816

Merged
merged 3 commits into from
Jan 24, 2018

Conversation

wanghaoshuang
Copy link
Contributor

No description provided.

@wanghaoshuang wanghaoshuang requested a review from QiJune January 24, 2018 06:37
@@ -185,6 +186,8 @@ def load_persistables(executor, dirname, main_program=None):
def get_inference_program(target_vars, main_program=None):
if main_program is None:
main_program = default_main_program()
if isinstance(target_vars, Evaluator):
target_vars = target_vars.states + target_vars.metrics
if not isinstance(target_vars, list):
target_vars = [target_vars]

Copy link
Member

Choose a reason for hiding this comment

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

Maybe following implementation is more general.

if not isinstance(target_vars, list):
  target_vars = [target_vars]
vars = []
for var in target_vars:
  if isinstance(var, Evaluator):
    vars.append(var.states)
    vars.append(var.metrics)
  else:
    vars.append(var)
pruned_program = main_program.prune(targets=vars)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx. Done.

Copy link
Member

@QiJune QiJune left a comment

Choose a reason for hiding this comment

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

LGTM!

@wanghaoshuang wanghaoshuang merged commit ef8cb8f into PaddlePaddle:develop Jan 24, 2018
@wanghaoshuang wanghaoshuang deleted the infer_prog branch January 24, 2018 09:25
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

Successfully merging this pull request may close these issues.

2 participants