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

refine sync_with_cpp for insert_op #9747

Closed
wants to merge 1 commit into from
Closed

refine sync_with_cpp for insert_op #9747

wants to merge 1 commit into from

Conversation

luotao1
Copy link
Contributor

@luotao1 luotao1 commented Apr 8, 2018

related #9629.
When use insert_op method for stage 1, there is error in sync_with_cpp. The reason is that sync_with_cpp only consider remove_op, append_op, prepend_op, remove_var now, but don't consider insert_op.

Thus, this PR consider insert_op in sync_with_cpp, and add a unit test to check the sync_with_cpp after calling append_op, prepend_op and insert_op.

@luotao1 luotao1 mentioned this pull request Apr 8, 2018
@luotao1 luotao1 requested a review from typhoonzero April 8, 2018 15:29
if len(self.ops) != len(ops_in_cpp) and start_index == 0 and len(
self.ops) == end_index:
self.ops.clear()
for index in range(len(ops_in_cpp)):
Copy link
Contributor

Choose a reason for hiding this comment

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

For simplicity, can we only keep this and remove all above sync operations? It's slower but very easy to understand.

Copy link
Contributor Author

@luotao1 luotao1 Apr 9, 2018

Choose a reason for hiding this comment

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

Sorry, I couldn't remove all above sync operators. I tried it, but many unit tests fail. The reason I guess is:

# sync ops append to the head of cpp_ops
for index in range((start_index - 1 - 1), -1, -1):
    op_desc = ops_in_cpp[index]
    op = Operator(self, op_desc)
    self.ops.appendleft(op)

The reverse order of range((start_index - 1 - 1), -1, -1) and appendleft make the order of python_ops different from cpp_ops.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's wired. The above code still tries to make the order of self.ops the same with cpp_ops. We can merge this if it's currently a blocking feature and add some comments here.

@Xreki Xreki added the 预测 原名Inference,包含Capi预测问题等 label Apr 9, 2018
@jacquesqiao
Copy link
Member

jacquesqiao commented Apr 9, 2018

I have also add insert_op in https://github.com/PaddlePaddle/Paddle/pull/9714/files#diff-d8a7116f8835661cd9a974472e9e9f2dR834, after change block.ops from deque to list https://github.com/PaddlePaddle/Paddle/pull/9714/files#diff-d8a7116f8835661cd9a974472e9e9f2dR662, the problem is quite simple. The main problem is that ops in Python should have the same behavior with it in CPP, deque make things complex.

@luotao1
Copy link
Contributor Author

luotao1 commented Apr 9, 2018

@jacquesqiao Could you please create a PR and I can test it?

@typhoonzero
Copy link
Contributor

@luotao1 can you please update this PR to include latest changes?

@luotao1
Copy link
Contributor Author

luotao1 commented Apr 10, 2018

@typhoonzero Yes, I will follow the way like @jacquesqiao 's insert_op method (#9765 ) to write remove_op and remove_var in Python end.

@luotao1
Copy link
Contributor Author

luotao1 commented Apr 10, 2018

close due to #9816

@luotao1 luotao1 closed this Apr 10, 2018
@luotao1 luotao1 deleted the sync_with_cpp branch April 10, 2018 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
预测 原名Inference,包含Capi预测问题等
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants