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

fused_embedding_eltwise_layernorm_op and skip_layernorm_op support fp16 #44969

Merged
merged 17 commits into from
Aug 15, 2022

Conversation

yuanlehome
Copy link
Contributor

@yuanlehome yuanlehome commented Aug 8, 2022

PR types

Others

PR changes

Others

Describe

该PR效果:fused_embedding_eltwise_layernorm_op 和 skip_layernorm_op 算子添加对fp16的支持

测试模型:

import paddle
from paddle.static import InputSpec
import numpy as np
import os
import paddle.inference as inference

class EmbEwLnNet(paddle.nn.Layer):
    def __init__(self):
        super(EmbEwLnNet, self).__init__()
        self.embedding_layer1 = paddle.nn.Embedding(1024, 256, sparse=True)
        self.embedding_layer2 = paddle.nn.Embedding(1024, 256, sparse=True)
        self.embedding_layer3 = paddle.nn.Embedding(1024, 256, sparse=True)
        self.layer_norm = paddle.nn.LayerNorm(256)

    def forward(self, x1, x2, x3):
        x = self.embedding_layer1(x1) + self.embedding_layer2(x2)
        x = x + self.embedding_layer3(x3)
        x = self.layer_norm(x)
        return x


class SkipLnNet(paddle.nn.Layer):
    def __init__(self):
        super(SkipLnNet, self).__init__()
        self.layer_norm = paddle.nn.LayerNorm(256)

    def forward(self, x1, x2):
        x = x1 + x2
        x = self.layer_norm(x)
        return x

测试环境:
GPU Compute Capability: 7.5, Driver API Version: 11.4, Runtime API Version: 11.2, cuDNN Version: 8.1.
with warmup: 100 and repeats: 10000

fused_embedding_eltwise_layernorm_op算子

gpu原生

model gpu
float 0.336549 ms
float16 0.165548 ms

trt加速

model trt32 trt16
float 0.336706 ms 0.346024 ms
float16 0.338106 ms 0.284455 ms

skip_layernorm_op算子

gpu原生

model gpu
float 0.27069 ms
float16 0.148987 ms

trt加速

model trt32 trt16
float 0.293951 ms -
float16 - 0.307114 ms

@paddle-bot
Copy link

paddle-bot bot commented Aug 8, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@CLAassistant
Copy link

CLAassistant commented Aug 8, 2022

CLA assistant check
All committers have signed the CLA.

@yuanlehome yuanlehome force-pushed the develop branch 3 times, most recently from 0bce992 to 76c989b Compare August 8, 2022 06:36
Copy link
Contributor

@jiweibo jiweibo left a comment

Choose a reason for hiding this comment

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

LGTM

@jiweibo jiweibo merged commit ac0553a into PaddlePaddle:develop Aug 15, 2022
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.

4 participants