Skip to content

[added] gen and check script slow#2

Open
unseenme wants to merge 3 commits intotc20042008:monkeyfrom
unseenme:feature_slow
Open

[added] gen and check script slow#2
unseenme wants to merge 3 commits intotc20042008:monkeyfrom
unseenme:feature_slow

Conversation

@unseenme
Copy link
Copy Markdown

PR types

PR changes

Description

# numpy_gen = NumpyGenerator()
# script = numpy_gen.Generate(unit_test_case_spec.patched_instruction_code_gen_spec)

paddle_eager_gen = PaddleEagerGenerator()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

这里基本上跑不出BUG来,因为这是eager。
你需要写一个PaddleCinnGenerator

@tc20042008
Copy link
Copy Markdown
Owner

这个PR的描述里需要补充几个生成单测结果的示例

@tc20042008
Copy link
Copy Markdown
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()

@@ -0,0 +1,57 @@
import os
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

这个文件看起来是不太需要的。只要每个单测脚本按照python unittest规范来。它会汇报失败case。

@unseenme
Copy link
Copy Markdown
Author

增加了环境变量的配置后,报错的机率增加了不少,附件是自动筛选出的报错用例。
selection_v2.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants