Open
Conversation
tc20042008
reviewed
Apr 17, 2024
| # numpy_gen = NumpyGenerator() | ||
| # script = numpy_gen.Generate(unit_test_case_spec.patched_instruction_code_gen_spec) | ||
|
|
||
| paddle_eager_gen = PaddleEagerGenerator() |
Owner
There was a problem hiding this comment.
这里基本上跑不出BUG来,因为这是eager。
你需要写一个PaddleCinnGenerator
Owner
|
这个PR的描述里需要补充几个生成单测结果的示例 |
Owner
|
cinn 单测示例 import unittest
import numpy as np
import utils
import paddle
class CINNCosSubGraphNet(paddle.nn.Layer):
def __init__(self):
super().__init__()
def forward(self, x, y):
tmp = x * y
tmp1 = paddle.reshape(tmp, [80, 32, 4])
tmp2 = paddle.sum(tmp1, axis=2)
return tmp2
class TestCinnCos(unittest.TestCase):
def setUp(self):
paddle.seed(2024)
self.prepare_data()
def prepare_data(self):
self.x = paddle.uniform([80, 128], dtype="float32", min=-0.5, max=0.5)
self.x.stop_gradient = True
self.y = paddle.uniform([128], dtype="float32", min=-0.5, max=0.5)
self.y.stop_gradient = True
def train(self, use_cinn):
net = CINNCosSubGraphNet()
net.eval()
net = utils.apply_to_static(net, use_cinn)
for i in range(1):
out = net(self.x, self.y)
return out
def test_train(self):
cinn_out = self.train(use_cinn=True)
dy_out = self.train(use_cinn=False)
np.testing.assert_allclose(cinn_out.numpy(), dy_out.numpy(), atol=1e-5)
if __name__ == '__main__':
unittest.main() |
tc20042008
reviewed
Apr 17, 2024
| @@ -0,0 +1,57 @@ | |||
| import os | |||
Owner
There was a problem hiding this comment.
这个文件看起来是不太需要的。只要每个单测脚本按照python unittest规范来。它会汇报失败case。
Author
|
增加了环境变量的配置后,报错的机率增加了不少,附件是自动筛选出的报错用例。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR types
PR changes
Description