-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 remove_op, remove_var in Python end #9816
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,33 +201,13 @@ def test_remove_op(self): | |
op1.set_type("test") | ||
op2.set_type("test") | ||
|
||
var0 = block.var("var0") | ||
var1 = block.var("var1") | ||
var2 = block.var("var2") | ||
var3 = block.var("var3") | ||
var4 = block.var("var4") | ||
var5 = block.var("var5") | ||
|
||
op0.set_input("X", ["var0"]) | ||
op0.set_output("Y", ["var0"]) | ||
op1.set_input("X", ["var1", "var2"]) | ||
op1.set_output("Y", ["var3", "var4"]) | ||
op2.set_input("X", ["var1"]) | ||
op2.set_output("Y", ["var4", "var5"]) | ||
|
||
program.sync_with_cpp() | ||
|
||
# remove op1, its input var2 and output var3 will be removed at the same time, | ||
# but its input var1 and output var4 will not be removed since they are used for op2. | ||
block.remove_op(1, 2) | ||
program.sync_with_cpp() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed with @jacquesqiao, this simpler version is so dangerous since it will clear all ops. If we create an op1 first, then call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That make sense, I see |
||
|
||
all_ops = [] | ||
for idx in xrange(0, block.op_size()): | ||
all_ops.append(block.op(idx)) | ||
self.assertEqual(all_ops, [op0, op2]) | ||
all_vars = block.all_vars() | ||
self.assertEqual(set(all_vars), {var0, var1, var4, var5}) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be above those "" includes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the result of clang-format. When I move line16 above line 15, the clang-format will change to this version.
The reason is that
block_desc.h
is Related header, but<queue>
is C++ library. The order is: Related header, C library, C++ library, other libraries' .h, your project's .h. https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_IncludesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thank you.