From 128ef1ae694794c600b0595179f9a1ab0194d820 Mon Sep 17 00:00:00 2001 From: zhangxin81 <115389973+zhangxin81@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:55:36 +0800 Subject: [PATCH] fix loopup_table plugin deserialize size error (#48379) * fix loopup_table plugin deserialize size error --- paddle/fluid/inference/tensorrt/plugin/lookup_table.cu | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/inference/tensorrt/plugin/lookup_table.cu b/paddle/fluid/inference/tensorrt/plugin/lookup_table.cu index 41886d24aa1..31d599bd2a6 100644 --- a/paddle/fluid/inference/tensorrt/plugin/lookup_table.cu +++ b/paddle/fluid/inference/tensorrt/plugin/lookup_table.cu @@ -98,9 +98,11 @@ LookupTablePluginDynamic::LookupTablePluginDynamic(void const* data, deserialize_value(&data, &length, &mWeightSize); deserialize_value(&data, &length, &mWeightWidth); char const* d = static_cast(data); - cudaMalloc(&mWeightDev, mWeightSize * sizeof(mType)); - cudaMemcpy( - mWeightDev, d, mWeightSize * sizeof(mType), cudaMemcpyHostToDevice); + cudaMalloc(&mWeightDev, mWeightSize * getElementSize(mType)); + cudaMemcpy(mWeightDev, + d, + mWeightSize * getElementSize(mType), + cudaMemcpyHostToDevice); } // IPluginV2DynamicExt Methods -- GitLab