This repository was archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[Activation] GELU precision mismatch between MXNet and PyTorch in the CPU version #18826
Labels
Comments
@sxjscience Can you confirm the operator runs into its mkldnn version? |
Sorry I do not have the bandwidth to confirm that. I think mkldnn should be turned on by default. Are you able to reproduce this?
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Tao Lv <notifications@github.com>
Sent: Wednesday, July 29, 2020 9:31:49 PM
To: apache/incubator-mxnet <incubator-mxnet@noreply.github.com>
Cc: Xingjian SHI <xshiab@connect.ust.hk>; Mention <mention@noreply.github.com>
Subject: Re: [apache/incubator-mxnet] [Activation] GELU precision mismatch between MXNet and PyTorch in the CPU version (#18826)
@sxjscience<https://github.com/sxjscience> Can you confirm the operator runs into its mkldnn version?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#18826 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABHQH3XYWAH6FQB5D4YO4DDR6DZTLANCNFSM4PMXSPLQ>.
|
In fact, I cannot correctly run the reproducer. I try to fix the precision problem with #18827. Please let me know if it works for you. Thanks. |
@TaoLv Sorry, missed some imports. import mxnet as mx
import math
from numpy.testing import assert_allclose
mx.npx.set_np()
a = mx.np.random.normal(0, 1, (10000,))
b = mx.npx.leaky_relu(a, act_type='gelu')
c = a * 0.5 * (1.0 + mx.npx.erf(a / math.sqrt(2.0)))
import torch
a_torch = torch.from_numpy(a.asnumpy())
b_torch = torch.nn.functional.gelu(a_torch)
assert_allclose(b_torch.cpu().numpy(), c.asnumpy(), 1E-4, 1E-4)
assert_allclose(b_torch.cpu().numpy(), b.asnumpy(), 1E-4, 1E-4) (Compiling MXNet takes some time for me so it will be helpful if you can check that...) |
Does the issue still exist after Tao's PR? |
Yes, it's solved. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The CPU version of
mx.npx.leaky_relu(x, act_type='gelu')
has different precision from PyTorch.The minimal reproducible example:
The GPU version has no issue:
@pengzhao-intel @ciyongch
Error:
The text was updated successfully, but these errors were encountered: