-
Notifications
You must be signed in to change notification settings - Fork 55
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
单测case增强4 #458
单测case增强4 #458
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 |
---|---|---|
|
@@ -70,9 +70,22 @@ def test_case_3(): | |
result = model(x) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
unsupport=True, | ||
reason="When dim is None, paddle and pytorch generate different results", | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_4(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
x = torch.tensor([[[2.0, 3.0, 4.0, 5.0], | ||
[3.0, 4.0, 5.0, 6.0], | ||
[7.0, 8.0, 8.0, 9.0]], | ||
[[1.0, 2.0, 3.0, 4.0], | ||
[5.0, 6.0, 7.0, 8.0], | ||
[6.0, 7.0, 8.0, 9.0]]]) | ||
model = nn.LogSoftmax(dim=None) | ||
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. 没有dim的情况测一下 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. testcase3就是没有dim的情况 以及这个PR修改的这个文件主要是为了防止CI报错,其实在单测case增强3这个PR中对这两个文件修改是同样的 |
||
result = model(x) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,9 +70,22 @@ def test_case_3(): | |
result = model(x) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
unsupport=True, | ||
reason="When dim is None, paddle and pytorch generate different results", | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_4(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
x = torch.tensor([[[2.0, 3.0, 4.0, 5.0], | ||
[3.0, 4.0, 5.0, 6.0], | ||
[7.0, 8.0, 8.0, 10.0]], | ||
[[1.0, 2.0, 3.0, 4.0], | ||
[5.0, 6.0, 7.0, 8.0], | ||
[6.0, 7.0, 8.0, 9.0]]]) | ||
model = nn.Softmax(dim=None) | ||
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. 没有dim的情况测一下 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. testcase3就是没有dim的情况 |
||
result = model(x) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,3 +148,72 @@ def test_case_7(): | |
unsupport=True, | ||
reason="paddle unsupport batch_first args", | ||
) | ||
|
||
|
||
def test_case_8(): | ||
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. 新加的bias参数有实质性测试到了的吗 |
||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
transformer_model = torch.nn.Transformer(d_model=512, | ||
nhead=8, num_encoder_layers=6, | ||
num_decoder_layers=6, dim_feedforward=2048, | ||
dropout=0.1, activation='relu', | ||
custom_encoder=None, custom_decoder=None, | ||
layer_norm_eps=1e-05, batch_first=False, | ||
norm_first=False, bias=False, | ||
device=None, dtype=None) | ||
src = torch.rand((10, 32, 512)) | ||
tgt = torch.rand((10, 32, 512)) | ||
result = transformer_model(src, tgt) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
check_value=False, | ||
unsupport=True, | ||
reason="paddle unsupport layer_norm_eps args", | ||
) | ||
|
||
|
||
def test_case_9(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
transformer_model = torch.nn.Transformer(512, | ||
8, 6, 6, 2048, | ||
0.1, 'relu', | ||
None, None, | ||
1e-05, False, | ||
False, False, | ||
None, None) | ||
src = torch.rand((10, 32, 512)) | ||
tgt = torch.rand((10, 32, 512)) | ||
result = transformer_model(src, tgt) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
check_value=False, | ||
unsupport=True, | ||
reason="paddle unsupport layer_norm_eps args", | ||
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. batch_first测一个 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. 这个在testcase7中有,并且paddle貌似目前也不支持这个参数 |
||
) | ||
|
||
|
||
def test_case_10(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
transformer_model = torch.nn.Transformer(d_model=512, | ||
nhead=8, num_encoder_layers=6, | ||
num_decoder_layers=6, dim_feedforward=2048, | ||
dropout=0.1, activation='relu', | ||
custom_encoder=None, custom_decoder=None, | ||
norm_first=False, bias=True, device=None, dtype=None) | ||
src = torch.rand((10, 32, 512)) | ||
tgt = torch.rand((10, 32, 512)) | ||
result = transformer_model(src, tgt) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,3 +78,60 @@ def test_case_4(): | |
unsupport=True, | ||
reason="paddle unsupport batch_first args", | ||
) | ||
|
||
|
||
def test_case_5(): | ||
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. 新加的bias参数有实质性测试到了的吗 |
||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
x = torch.ones(10, 32,512) | ||
tgt = torch.ones(10, 32, 512) | ||
model = nn.TransformerDecoderLayer(d_model=512, nhead=8,dim_feedforward=2048, dropout=0.1, | ||
activation="relu", layer_norm_eps=1e-06, batch_first=False, | ||
norm_first=False, bias=True, device=None, dtype=None) | ||
result = model(tgt,x) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
unsupport=True, | ||
reason="paddle unsupport batch_first args", | ||
) | ||
|
||
|
||
def test_case_6(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
x = torch.ones(10, 32,512) | ||
tgt = torch.ones(10, 32, 512) | ||
model = nn.TransformerDecoderLayer(512, 8,2048, 0.1, "relu", 1e-06, False, | ||
False, True, None, None) | ||
result = model(tgt,x) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
unsupport=True, | ||
reason="paddle unsupport batch_first args", | ||
) | ||
|
||
|
||
def test_case_7(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
x = torch.ones(10, 32,512) | ||
tgt = torch.ones(10, 32, 512) | ||
model = nn.TransformerDecoderLayer(d_model=512, nhead=8,dim_feedforward=2048, dropout=0.1, | ||
activation="relu", layer_norm_eps=1e-06, | ||
norm_first=False, bias=True, device=None, dtype=None) | ||
result = model(tgt,x) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,64 @@ def test_case_7(): | |
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_8(): | ||
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. 新加的bias参数有实质性测试到了的吗 |
||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
tgt = torch.ones(10, 32, 512) | ||
model = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, dropout=0.1, | ||
activation="relu", layer_norm_eps=1e-05, batch_first=False, | ||
norm_first=False, bias=True, device=None, dtype=None) | ||
result = model(tgt) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
check_value=False, | ||
unsupport=True, | ||
reason="paddle unsupport batch_first args", | ||
) | ||
|
||
|
||
def test_case_9(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
tgt = torch.ones(10, 32, 512) | ||
model = nn.TransformerEncoderLayer(512, 8, 2048, 0.1, | ||
"relu", 1e-05, False, | ||
False, True, "cpu", None) | ||
result = model(tgt) | ||
""" | ||
) | ||
obj.run( | ||
pytorch_code, | ||
["result"], | ||
check_value=False, | ||
unsupport=True, | ||
reason="paddle unsupport batch_first args", | ||
) | ||
|
||
|
||
def test_case_10(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
import torch.nn as nn | ||
tgt = torch.ones(10, 32, 512) | ||
model = nn.TransformerEncoderLayer(512, 8, | ||
2048, | ||
0.1, 'relu', | ||
norm_first=False, | ||
device=None, | ||
bias=True, | ||
dtype=torch.float32) | ||
result = model(tgt) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) |
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.
RequireDimMatcher是不是没用了可以删掉
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再删除吧,因为这个Matcher还涉及到其余几个单测,改动的话需要改其余几个算子的单测,要是都在这里改的话可能提交的文件有些过多了