未验证 提交 2d2609ea 编写于 作者: J jakpiase 提交者: GitHub

added sqrt bf16 fwd/bwd (#38599)

上级 1e3f01ed
...@@ -282,7 +282,6 @@ namespace ops = paddle::operators; ...@@ -282,7 +282,6 @@ namespace ops = paddle::operators;
__macro(swish, SwishMKLDNNFunctor, SwishMKLDNNGradFunctor); \ __macro(swish, SwishMKLDNNFunctor, SwishMKLDNNGradFunctor); \
__macro(hard_swish, HardSwishMKLDNNFunctor, HardSwishMKLDNNGradFunctor); \ __macro(hard_swish, HardSwishMKLDNNFunctor, HardSwishMKLDNNGradFunctor); \
__macro(tanh, TanhMKLDNNFunctor, TanhMKLDNNGradFunctor); \ __macro(tanh, TanhMKLDNNFunctor, TanhMKLDNNGradFunctor); \
__macro(sqrt, SqrtMKLDNNFunctor, SqrtMKLDNNGradFunctor); \
__macro(abs, AbsMKLDNNFunctor, AbsMKLDNNGradFunctor); \ __macro(abs, AbsMKLDNNFunctor, AbsMKLDNNGradFunctor); \
__macro(elu, EluMKLDNNFunctor, EluMKLDNNGradFunctor); __macro(elu, EluMKLDNNFunctor, EluMKLDNNGradFunctor);
...@@ -293,6 +292,8 @@ REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL(gelu, GeluMKLDNNFunctor, ...@@ -293,6 +292,8 @@ REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL(gelu, GeluMKLDNNFunctor,
GeluMKLDNNGradFunctor); GeluMKLDNNGradFunctor);
REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL(sigmoid, SigmoidMKLDNNFunctor, REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL(sigmoid, SigmoidMKLDNNFunctor,
SigmoidMKLDNNGradFunctor); SigmoidMKLDNNGradFunctor);
REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL(sqrt, SqrtMKLDNNFunctor,
SqrtMKLDNNGradFunctor);
namespace ops = paddle::operators; namespace ops = paddle::operators;
REGISTER_OP_KERNEL( REGISTER_OP_KERNEL(
......
...@@ -82,6 +82,20 @@ class TestMKLDNNSigmoidBF16Op(MKLDNNBF16ActivationOp, TestActivation): ...@@ -82,6 +82,20 @@ class TestMKLDNNSigmoidBF16Op(MKLDNNBF16ActivationOp, TestActivation):
return dout * self.op_forward(x) * (1 - self.op_forward(x)) return dout * self.op_forward(x) * (1 - self.op_forward(x))
class TestMKLDNNSqrtBF16Op(MKLDNNBF16ActivationOp, TestActivation):
def config(self):
self.op_type = "sqrt"
def init_data(self):
self.x = np.random.uniform(1, 2, [2, 4, 3, 5]).astype(np.float32)
def op_forward(self, x):
return np.sqrt(x)
def op_grad(self, dout, x):
return dout / (2 * np.sqrt(x))
class TestMKLDNNGeluErfBF16Op(MKLDNNBF16ActivationOp, TestActivation): class TestMKLDNNGeluErfBF16Op(MKLDNNBF16ActivationOp, TestActivation):
def config(self): def config(self):
self.op_type = "gelu" self.op_type = "gelu"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册