Skip to content

Conversation

@gongweibao
Copy link
Contributor

@gongweibao gongweibao commented Apr 26, 2018

Fix #10221

Copy link
Contributor

@panyx0718 panyx0718 left a comment

Choose a reason for hiding this comment

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

This change seems to add a binary to run a programdesc once. Should this be put in a directory called "tools"?

bool read_from_file(const std::string& file, char** buf, int64_t* buf_len) {
FILE* f = fopen(file.c_str(), "rb");
if (NULL == f) {
printf("open %s error\n", file.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

fprintf(stderr? or LOG(ERROR)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change to fprintf(stderr.
Thanks.


using namespace paddle; // NOLINT

framework::ProgramDesc* load_desc(const std::string& file) {
Copy link
Contributor

Choose a reason for hiding this comment

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

return unique_ptr?

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.

return (new framework::ProgramDesc(proto));
}

DEFINE_string(start_up_proto, "", "start up proto file");
Copy link
Contributor

Choose a reason for hiding this comment

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

put at the file top?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.Done.

std::transform(place_str.begin(), place_str.end(), place_str.begin(),
[](unsigned char ch) { return toupper(ch); });

framework::Executor* exe = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

unique_ptr>

@@ -0,0 +1,126 @@
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

should this file by call execute_program_desc?

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.

self._feed_data(program, feed, feed_var_name, scope)

# TODO(gongwb): does a program should be saved in run function?
if len(save_program_to_file) > 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should do the save here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The programdesc is modified in run function.And sometimes a user can't get chance to save it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe run() shouldn't modify the programdesc? Or we should save after run is called?

@typhoonzero
Copy link
Contributor

Agree to put this to tools

return_numpy=True,
use_program_cache=False):
use_program_cache=False,
save_program_to_file=""):
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't want to put "save_program_to_file" as a argument to Executor. Saving program should be in a separate API, such as "save_inference_model".

@gongweibao
Copy link
Contributor Author

gongweibao commented May 7, 2018

I build debug-version Python and so close this PR.

@gongweibao gongweibao reopened this May 16, 2018
@gongweibao gongweibao closed this May 16, 2018
@gongweibao gongweibao deleted the detectmemleak2 branch January 17, 2021 07:42
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.

3 participants