Skip to content

Commit

Permalink
[Paddle-TRT] fix skiplayernorm, add trt_version check (#52342)
Browse files Browse the repository at this point in the history
* fix skiplayernorm, add trt_version check
  • Loading branch information
Wangzheee authored Mar 31, 2023
1 parent 74d87a6 commit 4e23af7
Showing 1 changed file with 17 additions and 0 deletions.
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

0 comments on commit 4e23af7

Please sign in to comment.