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

[Paddle-TRT] fix skiplayernorm, add trt_version check #52342

Merged
merged 4 commits into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions paddle/fluid/framework/ir/trt_skip_layernorm_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ limitations under the License. */

#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
#include "paddle/fluid/framework/op_version_registry.h"
#ifdef PADDLE_WITH_TENSORRT
#include "paddle/fluid/inference/tensorrt/helper.h"
#endif

namespace paddle {
namespace framework {
Expand Down Expand Up @@ -105,6 +108,20 @@ void TrtSkipLayerNormFusePass::ApplyImpl(ir::Graph *graph) const {
PADDLE_ENFORCE_NOT_NULL(
graph, platform::errors::PreconditionNotMet("graph should not be null."));
FusePassBase::Init("skip_layernorm_fuse", graph);

#ifdef PADDLE_WITH_TENSORRT
auto trt_version = paddle::inference::tensorrt::GetTrtRuntimeVersion();
if (std::get<0>(trt_version) * 1000 + std::get<1>(trt_version) * 100 +
std::get<2>(trt_version) * 10 <
7200) {
VLOG(3) << "skip_layernorm oss plugin only available for trt version >= "
"7.2 Stop this pass";
return;
}
#else
// if no tensorrt, early stop
return;
#endif
int found_subgraph_count = 0;

GraphPatternDetector gpd;
Expand Down