diff --git a/csrc/mmdeploy/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp b/csrc/mmdeploy/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp index 587d88dfa4..e6aab92f4c 100644 --- a/csrc/mmdeploy/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp +++ b/csrc/mmdeploy/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp @@ -152,9 +152,18 @@ void TRTInstanceNormalization::attachToContext(cudnnContext* cudnnContext, // Detach the plugin object from its execution context. void TRTInstanceNormalization::detachFromContext() TRT_NOEXCEPT { - cudnnDestroyTensorDescriptor(_y_desc); - cudnnDestroyTensorDescriptor(_x_desc); - cudnnDestroyTensorDescriptor(_b_desc); + if (_y_desc) { + cudnnDestroyTensorDescriptor(_y_desc); + _y_desc = nullptr; + } + if (_x_desc) { + cudnnDestroyTensorDescriptor(_x_desc); + _x_desc = nullptr; + } + if (_b_desc) { + cudnnDestroyTensorDescriptor(_b_desc); + _b_desc = nullptr; + } } void TRTInstanceNormalization::configurePlugin(const nvinfer1::DynamicPluginTensorDesc* in,