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

add autotest code in new test framework #5912

Closed
wants to merge 21 commits into from

Conversation

kevinzhangcode
Copy link
Contributor

@kevinzhangcode kevinzhangcode commented Aug 16, 2021

重构Module 完成情况 备注
oneflow.masked_fill y 已经被写了,合并到了master
oneflow.Tensor.masked_fill y 已经被写了,合并到了master
oneflow.sum Y
oneflow.Tensor.sum Y
oneflow.min Y torch.min(input, dim, keepdim=False, *, out=None) ,oneflow缺少dim参数、keepdim参数、out参数
oneflow.Tensor.min Y Tensor.min(dim=None, keepdim=False) ,oneflow缺少dim参数、keepdim参数
oneflow.max Y torch.max(input, dim, keepdim=False, *, out=None) ,oneflow缺少dim参数、keepdim参数、out参数
oneflow.Tensor.max Y Tensor.max(dim=None, keepdim=False) ,oneflow缺少dim参数、keepdim参数
oneflow.mul Y torch.mul(input, other, *, out=None),oneflow缺少out参数
oneflow.Tensor.mul Y
oneflow.mean Y
oneflow.Tensor.mean Y
oneflow.sub Y torch.sub(input, other, *, alpha=1, out=None),oneflow缺少alpha参数、out参数
oneflow.Tensor.sub Y Tensor.sub(other, *, alpha=1),oneflow缺少alpha参数
oneflow.div Y torch.div(input, other, *, rounding_mode=None, out=None),oneflow缺少rounding_mode参数、out参数
oneflow.Tensor.div Y Tensor.div(value, *, rounding_mode=1),oneflow缺少rounding_mode参数
oneflow.var 已修复#5973 存在问题,见comments
oneflow.Tensor.var 已修复#5973 存在问题

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

image

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


取消参数alpha:
image

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)
image

5、oneflow.var存在问题
image
image

@@ -1,12 +1,9 @@
"""
Copyright 2020 The OneFlow Authors. All rights reserved.

Copy link
Contributor

@doombeaker doombeaker Aug 17, 2021

Choose a reason for hiding this comment

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

这个版权信息为什么会被改,在 build 里 make of_format 可以本地做代码格式化

Copy link
Contributor Author

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 看见他几乎是重写了文件

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

传参带上keyword,可读性更好。

Copy link
Contributor

@doombeaker doombeaker Aug 17, 2021

Choose a reason for hiding this comment

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

测试样例不够丰富,可以多测几个形状和情况(element-wise的、scalar的、broadcast的)

@doombeaker
Copy link
Contributor

暂时不支持的参数,就不测了。不过最好要备忘一下,之后一起列个总结的单子。

@BBuf
Copy link
Contributor

BBuf commented Aug 20, 2021

masked_fill是对齐了,测试样例已经写了,在这里:python/oneflow/test/modules/test_masked_fill.py 基于Where Op的重构。https://github.com/Oneflow-Inc/oneflow/pull/5797/files

@kevinzhangcode
Copy link
Contributor Author

masked_fill是对齐了,测试样例已经写了,在这里:python/oneflow/test/modules/test_masked_fill.py 基于Where Op的重构。https://github.com/Oneflow-Inc/oneflow/pull/5797/files

好的,已经看见了,然后还有一个oneflow.var的问题。

@BBuf
Copy link
Contributor

BBuf commented Aug 20, 2021

masked_fill是对齐了,测试样例已经写了,在这里:python/oneflow/test/modules/test_masked_fill.py 基于Where Op的重构。https://github.com/Oneflow-Inc/oneflow/pull/5797/files

好的,已经看见了,然后还有一个oneflow.var的问题。

嗯,我看一下

@BBuf
Copy link
Contributor

BBuf commented Aug 20, 2021

masked_fill是对齐了,测试样例已经写了,在这里:python/oneflow/test/modules/test_masked_fill.py 基于Where Op的重构。https://github.com/Oneflow-Inc/oneflow/pull/5797/files

好的,已经看见了,然后还有一个oneflow.var的问题。

已经修复并添加测试样例。#5973

import oneflow as flow
import oneflow.unittest


Copy link
Contributor

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 *
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

div 等应该也有这类覆盖不全的问题。

如果不知道要测那些情况,就应该看文档、自己试用、看源码。了解接口的功能。

@autotest(auto_backward=False)
def test_0shape_div(test_case):
@autotest()
def test_div_with_random_data_Number(test_case):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是不是需要改一下,看起来会产生大量失败测试样例


@autotest()
Copy link
Contributor

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测试样例

@BBuf BBuf closed this Sep 17, 2021
@chengtbf chengtbf deleted the add_new_autotest_zgh branch April 13, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants