Fix run gpu model in adreno 630

This commit is contained in:
moran 2023-03-06 20:04:16 +08:00
parent 7bf397ea1c
commit 4915f749a9
4 changed files with 15 additions and 2 deletions

View File

@ -213,7 +213,11 @@ void *OpenCLAllocator::_Malloc(MemType mem_type, void *data, size_t size, const
total_size_ += size;
const uint64_t max_size = ocl_runtime_->GetGlobalMemSize() * 0.8;
UNLOCK_AND_RETURN_NULL(total_size_ >= max_size, nullptr);
if (total_size_ >= max_size) {
is_oversize_ = true;
} else {
is_oversize_ = false;
}
cl::Buffer *buffer = nullptr;
cl::Image2D *image = nullptr;

View File

@ -83,6 +83,7 @@ class OpenCLAllocator : public mindspore::Allocator {
}
return ptr;
}
bool IsOverSize() { return is_oversize_; }
private:
void Lock();
@ -117,6 +118,7 @@ class OpenCLAllocator : public mindspore::Allocator {
// 6 is empirical value
int shift_factor_ = 6;
bool lock_flag_ = true;
bool is_oversize_{false};
};
} // namespace mindspore::lite::opencl

View File

@ -277,6 +277,7 @@ int OpenCLKernel::PreProcess() {
}
output->ResetRefCount();
}
is_oversize_kernel_ = ocl_runtime_->GetAllocator()->IsOverSize();
return RET_OK;
}

View File

@ -284,7 +284,12 @@ class OpenCLKernel : public LiteKernel {
int PreProcess() override;
int ReSize() override;
int Run() override { return RET_ERROR; }
int PostProcess() override { return RET_OK; }
int PostProcess() override {
if (is_oversize_kernel_) {
return FreeInWorkTensor();
}
return RET_OK;
}
bool MallocDataDone();
std::string OpenCLKernelHeader();
@ -336,6 +341,7 @@ class OpenCLKernel : public LiteKernel {
cl::Event event_;
void *restore_quant_data_{nullptr};
bool dequant_flag_{false};
bool is_oversize_kernel_{false};
private:
lite::opencl::OpenCLRuntimeInnerWrapper ocl_runtime_wrap_;