-
Notifications
You must be signed in to change notification settings - Fork 826
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 autotest code in new test framework #5912
Conversation
@@ -1,12 +1,9 @@ | |||
""" | |||
Copyright 2020 The OneFlow Authors. All rights reserved. | |||
|
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.
这个版权信息为什么会被改,在 build 里 make of_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.
抄了这个PR https://github.com/Oneflow-Inc/oneflow/pull/5799/files 看见他几乎是重写了文件
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.
那个是还没有合并的PR
@autotest() | ||
def test_sub_with_random_data(test_case): | ||
device = random_device() | ||
x = random_pytorch_tensor(2, 0, 3).to(device) |
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.
传参带上keyword,可读性更好。
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.
测试样例不够丰富,可以多测几个形状和情况(element-wise的、scalar的、broadcast的)
暂时不支持的参数,就不测了。不过最好要备忘一下,之后一起列个总结的单子。 |
…/oneflow into add_new_autotest_zgh
masked_fill是对齐了,测试样例已经写了,在这里: |
好的,已经看见了,然后还有一个 |
嗯,我看一下 |
|
import oneflow as flow | ||
import oneflow.unittest | ||
|
||
|
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.
这里的空行比较多
import unittest | ||
|
||
import numpy as np | ||
from automated_test_util import * |
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.
标准库、第三方库、oneflow 分三类,这里没分好
device = random_device() | ||
x = random_pytorch_tensor(ndim=4, dim0=1).to(device) | ||
k = random(10,100).to(int) | ||
y = torch.mul(x, k) |
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.
原测试案例覆盖了各种情况: element-wise, scalar, broadcast 的,这里只测了 element-wise的。
请自己检查其它test case
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.
div 等应该也有这类覆盖不全的问题。
如果不知道要测那些情况,就应该看文档、自己试用、看源码。了解接口的功能。
…/oneflow into add_new_autotest_zgh
@autotest(auto_backward=False) | ||
def test_0shape_div(test_case): | ||
@autotest() | ||
def test_div_with_random_data_Number(test_case): |
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 test_div_with_random_data_Number(test_case): | |
def test_div_with_random_data(test_case): |
@autotest() | ||
def test_div_with_with_broadcast(test_case): | ||
device = random_device() | ||
x = random_pytorch_tensor(ndim=4, dim0=3).to(device) |
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.
这里是不是需要改一下,看起来会产生大量失败测试样例
|
||
@autotest() |
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.
我发现你把0-dim tensor的测试删了,这个不能删啊,这是专门构造的0-dim tensor测试样例
torch.min(input, dim, keepdim=False, *, out=None)
,oneflow缺少dim参数、keepdim参数、out参数Tensor.min(dim=None, keepdim=False)
,oneflow缺少dim参数、keepdim参数torch.max(input, dim, keepdim=False, *, out=None)
,oneflow缺少dim参数、keepdim参数、out参数Tensor.max(dim=None, keepdim=False)
,oneflow缺少dim参数、keepdim参数torch.mul(input, other, *, out=None)
,oneflow缺少out参数torch.sub(input, other, *, alpha=1, out=None)
,oneflow缺少alpha参数、out参数Tensor.
sub(other, *, alpha=1),
oneflow缺少alpha参数torch.
div(input, other, *, rounding_mode=None, out=None)
,oneflow缺少rounding_mode参数、out参数Tensor.
div(value, *, rounding_mode=1),
oneflow缺少rounding_mode参数Notice:

1、
oneflow.masked_fill
和oneflow.Tensor.masked_fill
接口似乎还有问题,原来的测试文档标注了
@unittest.skip("has bug now, need rewrite")
2、

oneflow.sub
oneflow.Tensor.sub
似乎没有对齐,
torch.sub(input, other, *, alpha=1, out=None)
,onflow缺少alpha参数取消参数alpha:

3、
oneflow.min oneflow.max oneflow.Tensor.min oneflow.Tensor.max
oneflow没对齐?
torch.min(input, dim, keepdim=False, *, out=None)
4、

oneflow.div
oneflow.Tensor.div
oneflow缺少参数rounding_mode
torch.div(input, other, *, rounding_mode=None, out=None)
5、


oneflow.var
存在问题