提交 455b60c5 编写于 作者: L liuqi

Fix host runtime bug for calling SetOpenCLBinaryPaths.

上级 2b1defc7
...@@ -261,6 +261,9 @@ int Main(int argc, char **argv) { ...@@ -261,6 +261,9 @@ int Main(int argc, char **argv) {
mace::SetGPUHints( mace::SetGPUHints(
static_cast<GPUPerfHint>(FLAGS_gpu_perf_hint), static_cast<GPUPerfHint>(FLAGS_gpu_perf_hint),
static_cast<GPUPriorityHint>(FLAGS_gpu_priority_hint)); static_cast<GPUPriorityHint>(FLAGS_gpu_priority_hint));
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
} }
#endif // MACE_ENABLE_OPENCL #endif // MACE_ENABLE_OPENCL
...@@ -273,11 +276,6 @@ int Main(int argc, char **argv) { ...@@ -273,11 +276,6 @@ int Main(int argc, char **argv) {
new FileStorageFactory(kernel_file_path)); new FileStorageFactory(kernel_file_path));
SetKVStorageFactory(storage_factory); SetKVStorageFactory(storage_factory);
if (device_type == DeviceType::GPU) {
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
}
// Create Engine // Create Engine
std::shared_ptr<mace::MaceEngine> engine; std::shared_ptr<mace::MaceEngine> engine;
MaceStatus create_engine_status; MaceStatus create_engine_status;
......
...@@ -68,7 +68,7 @@ int FileStorage::Load() { ...@@ -68,7 +68,7 @@ int FileStorage::Load() {
return 0; return 0;
} else { } else {
LOG(WARNING) << "Stat file " << file_path_ LOG(WARNING) << "Stat file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
return -1; return -1;
} }
} }
...@@ -81,7 +81,7 @@ int FileStorage::Load() { ...@@ -81,7 +81,7 @@ int FileStorage::Load() {
return 0; return 0;
} else { } else {
LOG(WARNING) << "open file " << file_path_ LOG(WARNING) << "open file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
return -1; return -1;
} }
} }
...@@ -92,12 +92,12 @@ int FileStorage::Load() { ...@@ -92,12 +92,12 @@ int FileStorage::Load() {
int res = 0; int res = 0;
if (file_data == MAP_FAILED) { if (file_data == MAP_FAILED) {
LOG(WARNING) << "mmap file " << file_path_ LOG(WARNING) << "mmap file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
res = close(fd); res = close(fd);
if (res != 0) { if (res != 0) {
LOG(WARNING) << "close file " << file_path_ LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
} }
return -1; return -1;
} }
...@@ -130,18 +130,18 @@ int FileStorage::Load() { ...@@ -130,18 +130,18 @@ int FileStorage::Load() {
res = munmap(file_data, file_size); res = munmap(file_data, file_size);
if (res != 0) { if (res != 0) {
LOG(WARNING) << "munmap file " << file_path_ LOG(WARNING) << "munmap file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
res = close(fd); res = close(fd);
if (res != 0) { if (res != 0) {
LOG(WARNING) << "close file " << file_path_ LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
} }
return -1; return -1;
} }
res = close(fd); res = close(fd);
if (res != 0) { if (res != 0) {
LOG(WARNING) << "close file " << file_path_ LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
return -1; return -1;
} }
return 0; return 0;
...@@ -169,7 +169,7 @@ int FileStorage::Flush() { ...@@ -169,7 +169,7 @@ int FileStorage::Flush() {
int fd = open(file_path_.c_str(), O_WRONLY | O_CREAT, 0600); int fd = open(file_path_.c_str(), O_WRONLY | O_CREAT, 0600);
if (fd < 0) { if (fd < 0) {
LOG(WARNING) << "open file " << file_path_ LOG(WARNING) << "open file " << file_path_
<< " failed, error code:" << errno; << " failed, error code: " << strerror(errno);
return -1; return -1;
} }
...@@ -208,11 +208,11 @@ int FileStorage::Flush() { ...@@ -208,11 +208,11 @@ int FileStorage::Flush() {
res = write(fd, buffer_ptr, buffer_size); res = write(fd, buffer_ptr, buffer_size);
if (res == -1) { if (res == -1) {
LOG(WARNING) << "write file " << file_path_ LOG(WARNING) << "write file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
res = close(fd); res = close(fd);
if (res != 0) { if (res != 0) {
LOG(WARNING) << "close file " << file_path_ LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
} }
return -1; return -1;
} }
...@@ -223,7 +223,7 @@ int FileStorage::Flush() { ...@@ -223,7 +223,7 @@ int FileStorage::Flush() {
res = close(fd); res = close(fd);
if (res != 0) { if (res != 0) {
LOG(WARNING) << "close file " << file_path_ LOG(WARNING) << "close file " << file_path_
<< " failed, error code: " << errno; << " failed, error code: " << strerror(errno);
return -1; return -1;
} }
data_changed_ = false; data_changed_ = false;
......
...@@ -409,7 +409,9 @@ OpenCLRuntime::OpenCLRuntime(): ...@@ -409,7 +409,9 @@ OpenCLRuntime::OpenCLRuntime():
kStorageFactory->CreateStorage(kPrecompiledProgramFileName); kStorageFactory->CreateStorage(kPrecompiledProgramFileName);
if (cache_storage_->Load() != 0) { if (cache_storage_->Load() != 0) {
LOG(FATAL) << "Load OpenCL cached compiled kernel file failed"; LOG(WARNING) << "Load OpenCL cached compiled kernel file failed. "
<< "Please make sure the storage directory exist "
<< "and you have Write&Read permission";
} }
auto platform_info_array = auto platform_info_array =
this->cache_storage_->Find(kOpenCLPlatformInfoKey); this->cache_storage_->Find(kOpenCLPlatformInfoKey);
...@@ -428,7 +430,9 @@ OpenCLRuntime::OpenCLRuntime(): ...@@ -428,7 +430,9 @@ OpenCLRuntime::OpenCLRuntime():
precompiled_binary_storage_.reset( precompiled_binary_storage_.reset(
new FileStorage(OpenCLRuntime::kPrecompiledBinaryPath)); new FileStorage(OpenCLRuntime::kPrecompiledBinaryPath));
if (precompiled_binary_storage_->Load() != 0) { if (precompiled_binary_storage_->Load() != 0) {
LOG(FATAL) << "Load OpenCL precompiled kernel file failed"; LOG(WARNING) << "Load OpenCL precompiled kernel file failed. "
<< "Please make sure the storage directory exist "
<< "and you have Write&Read permission";
} }
auto platform_info_array = auto platform_info_array =
...@@ -657,8 +661,9 @@ void OpenCLRuntime::SaveBuiltCLProgram() { ...@@ -657,8 +661,9 @@ void OpenCLRuntime::SaveBuiltCLProgram() {
std::vector<unsigned char>(platform_info_.begin(), std::vector<unsigned char>(platform_info_.begin(),
platform_info_.end())); platform_info_.end()));
if (cache_storage_->Flush() != 0) { if (cache_storage_->Flush() != 0) {
LOG(FATAL) << "Store OPENCL compiled kernel to file failed." LOG(FATAL) << "Store OPENCL compiled kernel to file failed. "
" Please Make sure the storage directory exist."; << "Please make sure the storage directory exist "
<< "and you have Write&Read permission";
} }
} }
} }
......
...@@ -202,6 +202,9 @@ bool RunModel(const std::string &model_name, ...@@ -202,6 +202,9 @@ bool RunModel(const std::string &model_name,
mace::SetGPUHints( mace::SetGPUHints(
static_cast<GPUPerfHint>(FLAGS_gpu_perf_hint), static_cast<GPUPerfHint>(FLAGS_gpu_perf_hint),
static_cast<GPUPriorityHint>(FLAGS_gpu_priority_hint)); static_cast<GPUPriorityHint>(FLAGS_gpu_priority_hint));
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
} }
#endif // MACE_ENABLE_OPENCL #endif // MACE_ENABLE_OPENCL
...@@ -214,11 +217,6 @@ bool RunModel(const std::string &model_name, ...@@ -214,11 +217,6 @@ bool RunModel(const std::string &model_name,
new FileStorageFactory(kernel_file_path)); new FileStorageFactory(kernel_file_path));
SetKVStorageFactory(storage_factory); SetKVStorageFactory(storage_factory);
if (device_type == DeviceType::GPU) {
std::vector<std::string> opencl_binary_paths = {FLAGS_opencl_binary_file};
mace::SetOpenCLBinaryPaths(opencl_binary_paths);
}
std::vector<unsigned char> model_pb_data; std::vector<unsigned char> model_pb_data;
if (FLAGS_model_file != "") { if (FLAGS_model_file != "") {
if (!mace::ReadBinaryFile(&model_pb_data, FLAGS_model_file)) { if (!mace::ReadBinaryFile(&model_pb_data, FLAGS_model_file)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册