-
Notifications
You must be signed in to change notification settings - Fork 825
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
Record autotest wrong code #5923
Conversation
@@ -33,6 +33,9 @@ | |||
def torch_tensor_to_flow(x): | |||
return flow.tensor(x.cpu().numpy()) | |||
|
|||
note_pytorch_method_names = [] |
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.
如果是作为全局的一个列表来用,我建议用全大写字母,并且放在最上面
|
||
|
||
def note_print_kwargs(x, y, end=True): | ||
if end == True: |
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.
if end == True: | |
if end: |
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.
好的
|
||
def note_print_kwargs(x, y, end=True): | ||
if end == True: | ||
if type(y) is str: |
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.
if type(y) is str: | |
if isinstance(y, str): |
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.
好的
if type(y) is str: | ||
print("\033[32m{}='{}'\033[0m".format(x, y), end="") | ||
else: | ||
print("\033[32m{}={}\033[0m".format(x, y), end="") |
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.
可以用 f-string,比 str.format 更易用一些
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.
好的
@@ -168,6 +190,7 @@ def dual_method(self, *args, **kwargs): | |||
*pytorch_args, **pytorch_kwargs | |||
) | |||
except Exception as e: | |||
clear_note_fake_program() |
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.
这和 python/oneflow/test_utils/automated_test_util/torch_flow_dual_object.py:373 的改动是不是重复了
如果代码存在多个返回点(比如多个 return、抛出异常)的话,用 with 语句块的 __exit__ 代替在每个返回点手动调用 clear_note_fake_program() 吧
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.
嗯,是重复了,想了下只需要在程序中保留一个清空函数就可以了。
有没有可能性把 module 对象的 __call__ 方法的参数也打印出来,以及对 tensor x=torch.tensor([1,2]) 调用 |
…neflow into record_autotest_wrong_code
Speed stats:
|
以Conv3d为例子,产生的代码文本如下:
log1p产生的代码文本如下:
在pow的module中制造一个bug,然后测试可以发现输出了可以帮助定位BUG的代码文本: