forked from mindspore-Ecosystem/mindspore
commit
3fc897506c
|
@ -108,6 +108,7 @@ kernel::LiteKernel *KernelRegistry::GetKernel(const std::vector<tensor::Tensor *
|
|||
<< schema::EnumNamePrimitiveType((schema::PrimitiveType)primitive->Type());
|
||||
return nullptr;
|
||||
}
|
||||
this->op_parameters_.emplace_back(parameter);
|
||||
auto creator = GetCreator(key);
|
||||
if (creator != nullptr) {
|
||||
auto kernel = creator(in_tensors, out_tensors, parameter, ctx, key, primitive);
|
||||
|
@ -115,4 +116,11 @@ kernel::LiteKernel *KernelRegistry::GetKernel(const std::vector<tensor::Tensor *
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
KernelRegistry::~KernelRegistry() {
|
||||
for (auto op_parameter : op_parameters_) {
|
||||
delete(op_parameter);
|
||||
}
|
||||
op_parameters_.clear();
|
||||
}
|
||||
} // namespace mindspore::lite
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace mindspore::lite {
|
|||
class KernelRegistry {
|
||||
public:
|
||||
KernelRegistry() = default;
|
||||
virtual ~KernelRegistry() = default;
|
||||
virtual ~KernelRegistry();
|
||||
|
||||
static KernelRegistry *GetInstance();
|
||||
int Init();
|
||||
|
@ -54,6 +54,7 @@ class KernelRegistry {
|
|||
static const int op_type_length_{PrimitiveType_MAX - PrimitiveType_MIN + 1};
|
||||
static const int array_size_{device_type_length_ * data_type_length_ * op_type_length_};
|
||||
kernel::KernelCreator creator_arrays_[array_size_] = {0};
|
||||
std::vector<OpParameter *> op_parameters_;
|
||||
};
|
||||
|
||||
class KernelRegistrar {
|
||||
|
|
|
@ -57,6 +57,7 @@ struct KernelKey {
|
|||
class LiteKernel {
|
||||
public:
|
||||
LiteKernel() = default;
|
||||
// parameter should be deleted or freed by caller, and should be deleted or freed after LiteKernel is deleted
|
||||
LiteKernel(OpParameter *parameter, const std::vector<lite::tensor::Tensor *> &in_tensors,
|
||||
const std::vector<lite::tensor::Tensor *> &out_tensors, const lite::Context *ctx,
|
||||
const mindspore::lite::PrimitiveC *primitive)
|
||||
|
@ -72,12 +73,7 @@ class LiteKernel {
|
|||
this->out_kernels_.clear();
|
||||
}
|
||||
|
||||
virtual ~LiteKernel() {
|
||||
if (op_parameter_ != nullptr) {
|
||||
delete op_parameter_;
|
||||
op_parameter_ = nullptr;
|
||||
}
|
||||
}
|
||||
virtual ~LiteKernel() = default;
|
||||
|
||||
virtual int Prepare() {
|
||||
if (!InferShapeDone()) {
|
||||
|
|
Loading…
Reference in New Issue