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

Add basic functions of Program Pass #34524

Merged
merged 6 commits into from
Aug 2, 2021
Merged

Conversation

sneaxiy
Copy link
Collaborator

@sneaxiy sneaxiy commented Jul 31, 2021

PR types

New features

PR changes

Others

Describe

Add basic functions for Pass applied to ProgramDesc. More codes would be added in the next PRs.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jul 31, 2021

✅ This PR's description meets the template requirements!
Please wait for other CI results.

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@sneaxiy sneaxiy changed the title Add basic APIs of Program Pass Add basic functions of Program Pass Jul 31, 2021
@sneaxiy sneaxiy closed this Jul 31, 2021
@sneaxiy sneaxiy reopened this Jul 31, 2021
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jul 31, 2021
@PaddlePaddle PaddlePaddle unlocked this conversation Jul 31, 2021

static void GraphToBlock(const Graph &graph, proto::BlockDesc *block,
const SortKind *sort_kind) {
// Remove the unneeded variables after memory optimization.
Copy link
Member

Choose a reason for hiding this comment

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

Just for you information, nothing to change.

I don't know where did we use the kGraphToProgramVarsToRemove and var2remove ... I thought we can delete these code, but I am not sure so I didn't do it in my past PRs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your FYI! I agree with you. Just keep it as the old logic.

@@ -47,6 +47,10 @@ constexpr char kStaleProgramOpDescs[] = "stale_program_op_descs";

namespace ir {

const char kGraphToProgramVarsToRemove[] =
Copy link
Member

Choose a reason for hiding this comment

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

Should we put it at graph.h? It is only used in GraphToProgram and your PR moved the GraphToProgram to graph_helper, can we put those constant at graph_helper.h?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -4148,6 +4164,91 @@ def __init__(self):
# compiled program, i.e. Graph
self._graph = None

def _find_var_ctor_kwargs(self, new_desc):
Copy link
Member

Choose a reason for hiding this comment

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

what's the meaning of ctor? From the code, you are finding 'class' and 'kwargs', can we rename the method name as _find_var_class_kwargs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@zhhsplendid zhhsplendid left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

LGTM for the framework.py

all_new_vars.append([])
block_new_vars = all_new_vars[-1]
for new_var_desc in new_block_desc.all_vars():
if self.blocks[idx].has_var(new_var_desc.name()):
Copy link
Contributor

Choose a reason for hiding this comment

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

The block number of new_desc and old_desc is always equal?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now, it is true. We can fix this if this is not in the future.

@sneaxiy sneaxiy merged commit 145cdb5 into PaddlePaddle:develop Aug 2, 2021
@sneaxiy sneaxiy deleted the program_pass branch August 2, 2021 12: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.

3 participants