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 op remainder #9869

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

youxiudeshouyeren
Copy link
Contributor

dim2 = random().to(int)
input = random_tensor(ndim=3, dim1=dim1, dim2=dim2).to(device)
other = random_tensor(ndim=3, dim1=dim1, dim2=dim2).to(device)
return torch.remainder(input, other)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个测试在CI报错,在我本地运行了2/30次也没有复现出来。之前有一个global测试也在CI挂了,但是可在本地复现出来,代码如下:debug出来是梯度不相等,在shape为(16, 16, 24, 24)的grad中,有一个位置的值不相等,分别是[-221.3744],[-222.08623]。这个bug不是每次都出现,但是报错后打印出的梯度都是只有一个地方的值不相等,所以应该不是梯度代码写的有问题。不太清楚是哪里有问题

@autotest(n=1, rtol=1e-3, atol=1e-2, auto_backward=True, check_graph=False)
def do_test_remainder_impl(test_case, ndim, placement, sbp):
    dims = [random(1, 4) * 8 for i in range(ndim)]
    x = random_tensor(ndim, *dims)
    x = x.to_global(placement=placement, sbp=sbp)
    y = random_tensor(ndim, *dims)
    y = y.to_global(placement=placement, sbp=sbp)

    z = torch.remainder(x, y)
    return z


class TestRemainderGlobal(flow.unittest.TestCase):
    @globaltest
    def test_remainder(test_case):
        ndim = random(1, 4).to(int).value()
        for placement in all_placement():
            for sbp in all_sbp(placement, max_dim=ndim):
                do_test_remainder_impl(test_case, ndim, placement, sbp)


if __name__ == "__main__":
    unittest.main()

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.

1 participant