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] upgrade EnqueueV2 to EnqueueV3 #59950

Merged
merged 29 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
修改enqueueV3
  • Loading branch information
lizexu123 committed Jan 9, 2024
commit 4a5b62d7d5e6f9756cad5d5ff8cf1458fa9de879
7 changes: 0 additions & 7 deletions paddle/fluid/inference/tensorrt/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,6 @@ bool TensorRTEngine::Enqueue(nvinfer1::IExecutionContext *context,
return cuda_graph_.Launch(stream);
}

#if IS_TRT_VERSION_GE(8500)
for (size_t j = 0; j < buffers->size(); ++j) {
auto name = context->getEngine().getBindingName(j);
context->setTensorAddress(name, (*buffers)[j]);
}
#endif

bool ret;
if (!with_dynamic_shape()) {
ret = context->enqueue(batch_size, buffers->data(), stream, nullptr);
Expand Down
8 changes: 0 additions & 8 deletions paddle/fluid/inference/tensorrt/test_dynamic_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,9 @@ TEST_F(TensorRTDynamicShapeValueEngineTest, test_trt_dynamic_shape_value) {
std::vector<int> shape_v = {8, 8, 4};
PrepareInputOutput(x_v, {8, 8, 4});
PrepareShapeInput(shape_v);
#if IS_TRT_VERSION_GE(6000)

#if IS_TRT_VERSION_GE(8500)
engine_->context()->setInputShape("input", nvinfer1::Dims2{8, 32});
engine_->context()->setInputShape("shape", shape_dim);
#else
engine_->context()->setBindingDimensions(0, nvinfer1::Dims2{8, 32});
engine_->context()->setBindingDimensions(1, shape_dim);
engine_->context()->setInputShapeBinding(1, shape_v.data());
#endif
#endif
auto *x_gpu_data = input_.mutable_data<float>(ctx_->GetPlace());
auto *shape_gpu_data = shape_.mutable_data<int>(ctx_->GetPlace());
auto *y_gpu_data = output_.mutable_data<float>(ctx_->GetPlace());
Expand Down
4 changes: 4 additions & 0 deletions paddle/fluid/operators/tensorrt/tensorrt_engine_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ class TensorRTEngineOp : public framework::OperatorBase {
"The TRT Engine OP only support "
"float/double/int32_t/int64_t/float16/bool input."));
}
const char *binding_name = engine->engine()->getBindingName(bind_index);
trt_context->setTensorAddress(binding_name, buffers[bind_index]);
}

// Bind output tensor to TRT.
Expand Down Expand Up @@ -769,6 +771,8 @@ class TensorRTEngineOp : public framework::OperatorBase {
buffers[bind_index] = static_cast<void *>(
fluid_t->mutable_data(dev_place, TRT2FluidDataType(trt_type)));
output_index += 1;
const char *binding_name = engine->engine()->getBindingName(bind_index);
trt_context->setTensorAddress(binding_name, buffers[bind_index]);
}

if (!engine->with_dynamic_shape()) {
Expand Down