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 deformable_conv_op_plugin de/serialization and refine the data type selection #38057

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ void DeformableConvPlugin::serializeFromDevice(
PADDLE_ENFORCE_GPU_SUCCESS(
cudaMemcpy(static_cast<char*>(*hostBuffer), deviceWeights.values,
deviceWeights.count * num_bytes, cudaMemcpyDeviceToHost));
hostBuffer += deviceWeights.count * num_bytes;
*hostBuffer =
reinterpret_cast<char*>(*hostBuffer) + deviceWeights.count * num_bytes;
}

nvinfer1::Weights DeformableConvPlugin::deserializeToDevice(
const void** hostBuffer, size_t count) {
int num_bytes = (data_type_ == nvinfer1::DataType::kFLOAT ? 4 : 2);
nvinfer1::Weights w =
copyToDevice(static_cast<const char*>(*hostBuffer), count);
hostBuffer += count * num_bytes;
*hostBuffer = reinterpret_cast<const char*>(*hostBuffer) + count * num_bytes;
return w;
}

Expand Down Expand Up @@ -189,8 +190,7 @@ bool DeformableConvPlugin::supportsFormat(
nvinfer1::DataType type, nvinfer1::TensorFormat format) const TRT_NOEXCEPT {
if (with_fp16_) {
#ifdef TRT_PLUGIN_FP16_AVALIABLE
return (type == nvinfer1::DataType::kFLOAT ||
type == nvinfer1::DataType::kHALF) &&
return (type == nvinfer1::DataType::kHALF) &&
(format == nvinfer1::TensorFormat::kLINEAR);
#else
return (type == nvinfer1::DataType::kFLOAT) &&
Expand Down Expand Up @@ -615,7 +615,7 @@ const char* DeformableConvPlugin::getPluginNamespace() const TRT_NOEXCEPT {
nvinfer1::DataType DeformableConvPlugin::getOutputDataType(
int index, const nvinfer1::DataType* input_type,
int nb_inputs) const TRT_NOEXCEPT {
return data_type_;
return input_type[0];
}

bool DeformableConvPlugin::isOutputBroadcastAcrossBatch(
Expand Down