forked from mindspore-Ecosystem/mindspore
!29283 [MSLITE] fix mem leak and diverse wide deep networks compatibility in tensorrt delegate
Merge pull request !29283 from Liu_Xuu/trt_0118_fullfusion
This commit is contained in:
commit
a929f44664
|
@ -29,6 +29,13 @@ constexpr size_t kGatherInputsSize = 3;
|
|||
}
|
||||
namespace mindspore {
|
||||
namespace cache {
|
||||
HostCacheModel::~HostCacheModel() {
|
||||
if (cache_model_ != nullptr) {
|
||||
delete cache_model_;
|
||||
MS_LOG(ERROR) << "delete cache_model_";
|
||||
cache_model_ = nullptr;
|
||||
}
|
||||
}
|
||||
MSTensor *SchemaTensorToMSTensor(lite::SchemaTensorWrapper *schema_tensor_wrapper,
|
||||
mindspore::schema::Tensor *schema_tensor) {
|
||||
std::vector<int64_t> shape;
|
||||
|
|
|
@ -30,7 +30,8 @@ namespace mindspore {
|
|||
namespace cache {
|
||||
class HostCacheModel {
|
||||
public:
|
||||
HostCacheModel() {}
|
||||
HostCacheModel() = default;
|
||||
~HostCacheModel();
|
||||
Status LoadCache(const std::string &model_path);
|
||||
Status LoadCache(DelegateModel<schema::Primitive> *model);
|
||||
bool CheckIsCacheKernel(kernel::Kernel *kernel);
|
||||
|
|
|
@ -49,6 +49,12 @@ int MatMulTensorRT::AddInnerOp(nvinfer1::INetworkDefinition *network) {
|
|||
transpose_b_ = primitive->transpose_b() ? nvinfer1::MatrixOperation::kTRANSPOSE : nvinfer1::MatrixOperation::kNONE;
|
||||
activation_ = primitive->activation_type();
|
||||
} else if (type_ == schema::PrimitiveType_FullConnection) {
|
||||
auto primitive = this->GetPrimitive()->value_as_FullConnection();
|
||||
if (primitive == nullptr) {
|
||||
MS_LOG(ERROR) << "convert to primitive FullConnection failed for " << op_name_;
|
||||
return RET_ERROR;
|
||||
}
|
||||
activation_ = primitive->activation_type();
|
||||
transpose_a_ = nvinfer1::MatrixOperation::kNONE;
|
||||
transpose_b_ = nvinfer1::MatrixOperation::kTRANSPOSE;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ nvinfer1::ICudaEngine *TensorRTSerializer::GetSerializedEngine() {
|
|||
return nullptr;
|
||||
}
|
||||
nvinfer1::ICudaEngine *engine = runtime->deserializeCudaEngine(trt_model_stream, size, nullptr);
|
||||
delete[] trt_model_stream;
|
||||
runtime->destroy();
|
||||
return engine;
|
||||
}
|
||||
|
|
|
@ -940,6 +940,8 @@ int LiteSession::DelegateInit() {
|
|||
int LiteSession::Init(InnerContext *context) {
|
||||
bool expected = false;
|
||||
if (!is_running_.compare_exchange_strong(expected, true)) {
|
||||
delete context;
|
||||
context = nullptr;
|
||||
MS_LOG(ERROR) << "Not support multi-threading";
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
@ -1784,6 +1786,7 @@ int lite::LiteSession::LoadModelAndCompileByPath(const std::string &model_path,
|
|||
(reinterpret_cast<lite::LiteModel *>(model))->set_keep_model_buf(true);
|
||||
auto ret = CompileGraph(model);
|
||||
if (ret != lite::RET_OK) {
|
||||
delete model;
|
||||
MS_LOG(ERROR) << "Compile model failed";
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
@ -1808,6 +1811,7 @@ int lite::LiteSession::LoadModelAndCompileByPath(const std::string &model_path,
|
|||
(reinterpret_cast<lite::LiteModel *>(model))->set_keep_model_buf(true);
|
||||
auto ret = CompileGraph(model);
|
||||
if (ret != lite::RET_OK) {
|
||||
delete model;
|
||||
MS_LOG(ERROR) << "Compile model failed";
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
|
|
@ -515,7 +515,12 @@ int Scheduler::InitDelegateKernels(std::vector<kernel::LiteKernel *> *dst_kernel
|
|||
}
|
||||
auto ret = ReplaceDelegateKernels(&tmp_kernels);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "NPU delegate replace delegate kernels failed.";
|
||||
dst_kernels->insert(dst_kernels->end(), src_kernels.begin(), src_kernels.end());
|
||||
dst_kernels->insert(dst_kernels->end(), tmp_kernels.begin(), tmp_kernels.end());
|
||||
if (remain_kernel != nullptr) {
|
||||
dst_kernels->push_back(remain_kernel);
|
||||
}
|
||||
MS_LOG(ERROR) << "Inner delegate replace delegate kernels failed.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue