!9881 [MSLITE] frame package size

From: @ling_qiao_min
Reviewed-by: 
Signed-off-by:
pull/9881/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 2bf6355139

@ -31,6 +31,14 @@ using mindspore::kernel::KernelKey;
namespace mindspore::lite {
KernelRegistry *KernelRegistry::GetInstance() {
static KernelRegistry instance;
std::unique_lock<std::mutex> malloc_creator_array(instance.lock_);
if (instance.creator_arrays_ == nullptr) {
instance.creator_arrays_ = reinterpret_cast<KernelCreator *>(malloc(array_size_ * sizeof(KernelRegistry)));
if (instance.creator_arrays_ == nullptr) {
return nullptr;
}
}
return &instance;
}
@ -127,5 +135,12 @@ kernel::LiteKernel *KernelRegistry::GetKernel(const std::vector<Tensor *> &in_te
return nullptr;
}
KernelRegistry::~KernelRegistry() = default;
KernelRegistry::~KernelRegistry() {
KernelRegistry *instance = GetInstance();
std::unique_lock<std::mutex> malloc_creator_array(instance->lock_);
if (instance->creator_arrays_ != nullptr) {
free(instance->creator_arrays_);
instance->creator_arrays_ = nullptr;
}
}
} // namespace mindspore::lite

@ -50,7 +50,10 @@ class KernelRegistry {
static const int data_type_length_{kNumberTypeEnd - kNumberTypeBegin + 1};
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_] = {nullptr};
kernel::KernelCreator *creator_arrays_ = nullptr;
private:
std::mutex lock_;
};
class KernelRegistrar {

Loading…
Cancel
Save