-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay tests] Temporary Attr Update for Order-Independent Testing #4357
Conversation
6d727b6
to
b07d414
Compare
src/relay/ir/op.cc
Outdated
if (op_map == nullptr) { | ||
return; | ||
} | ||
op_map->data_.clear(); |
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.
per https://docs.tvm.ai/contribute/code_review.html#ensure-test-coverage
Need testcase for reset_attr.
The current implementation resets the attr of other ops along the current one, which is not correct.
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.
I see. I will take a look. I have misunderstood the registry codebase then.
@@ -31,6 +31,17 @@ def run_opt_pass(expr, passes): | |||
entry = mod["main"] | |||
return entry if isinstance(expr, relay.Function) else entry.body | |||
|
|||
def reset_retrieve_alter_op_layout(op_name, alter_layout): |
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.
Consider use RAII Pattern, this will allow the code to exit correctly even if the testcase raises an exception in the middle of the body
with TempOpAttr(name, attr):
body
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.
Now I understood what you meant. Thanks for your patience (and teaching new practices) :)
b07d414
to
faf2b8c
Compare
51f65db
to
28f5f73
Compare
28f5f73
to
7b451c3
Compare
@tqchen Can you take a look now? Thanks for your patience. |
7b451c3
to
626bfbe
Compare
|
||
class TempOpAttr(object): | ||
""" Temporarily changes the attr of an op. """ | ||
def __init__(self, op_name, attr_key): |
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.
document all the arguments https://docs.tvm.ai/contribute/document.html#document-python
"""
Parameters
----------
Examples
----------
"""
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.
Can be combine the set and reset together?
# set op attrkey to value
with TempOpAttr(op_name, attr_key, attr_value):
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.
Good idea! Will update soon.
src/relay/ir/op.cc
Outdated
Op op = args[0]; | ||
std::string attr_name = args[1]; | ||
auto& reg = | ||
OpRegistry::Registry()->__REGISTER_OR_GET__(op->name).set_name(); |
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.
.set_name() is not necessary.
|
||
# Reset log fadd1 attr. | ||
log_op = relay.op.get("log") | ||
log_op.reset_attr("fadd1") |
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.
Let us also test TempOpAttr
626bfbe
to
ef05551
Compare
@tqchen comments addressed |
@tqchen Can you please take a look?
More details at https://discuss.tvm.ai/t/ci-use-pytest-xdist-for-alteroplayout-tests/4803